Skip to content

Commit cbf98f2

Browse files
Fix: replace 'instant' dependency with 'web-time' (#296)
# The Bug While using this crate, I encounered an error with my project's wasm build that went something like this: ``` Module not found: Error: Can't resolve 'env' in 'my-project/pkg' ``` # Finding the source After a little searching, I found this [helpful issue](https://github.com/orgs/community/discussions/16289#discussion-4062908) on the wasm-bindgen repository. I used [this tool]( https://github.com/Liamolucko/find_wasm_import) (mentioned in the issue) on my project to attempt to find the source of the error, and the source was the instant crate. # Solution In all regards, web_time seems to be superior to instant. Instant even mentions in [their readme](https://github.com/sebcrozet/instant/blob/master/README.md) that the crate is unmaintained and web_time should be considered as an alternative. --------- Co-authored-by: Dmitrii Samsonov <[email protected]>
1 parent bf8a5f0 commit cbf98f2

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ petgraph = { version = "0.8", default-features = false }
4040
serde = "1.0"
4141
serde_json = "1.0"
4242
rand = "0.9"
43-
instant = { version = "0.1", features = ["wasm-bindgen"] }
43+
web-time = "1.1"
4444
crossbeam = "0.8"
4545
bevy = "0.17"
4646
bevy_egui = "0.38"

crates/demo-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ petgraph = { workspace = true, default-features = false, features = [
2020
"matrix_graph",
2121
] }
2222
rand.workspace = true
23-
instant.workspace = true
23+
web-time.workspace = true
2424
crossbeam = { workspace = true, optional = true }
2525
serde = { workspace = true, features = ["derive"] }
2626
serde_json.workspace = true

crates/demo-core/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ use egui_graphs::{
66
FruchtermanReingoldWithCenterGravityState, Graph, LayoutForceDirected, LayoutHierarchical,
77
LayoutHierarchicalOrientation, LayoutStateHierarchical,
88
};
9-
#[cfg(not(feature = "events"))]
10-
use instant::Instant;
119
use petgraph::stable_graph::{DefaultIx, EdgeIndex, NodeIndex};
1210
use petgraph::{Directed, Undirected};
1311
use rand::Rng;
1412
#[cfg(all(feature = "events", target_arch = "wasm32"))]
1513
use std::{cell::RefCell, rc::Rc};
14+
#[cfg(not(feature = "events"))]
15+
use web_time::Instant;
1616

1717
mod event_filters;
1818
mod graph_ops;

crates/demo-core/src/metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::time::Duration;
2-
use instant::Instant;
32
use std::collections::VecDeque;
3+
use web_time::Instant;
44

55
pub struct MetricsRecorder {
66
fps: f32,

crates/demo-core/src/status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use instant::Instant;
21
use std::collections::VecDeque;
2+
use web_time::Instant;
33

44
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
55
pub enum StatusKind {

crates/egui_graphs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ petgraph = { workspace = true, default-features = false, features = [
2222
"serde-1",
2323
] }
2424
serde = { workspace = true, features = ["derive"] }
25-
instant.workspace = true
25+
web-time.workspace = true
2626

2727
crossbeam = { workspace = true, optional = true }
2828

crates/egui_graphs/src/graph_view.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
};
1010

1111
use egui::{Id, PointerButton, Pos2, Rect, Response, Sense, Ui, Vec2, Widget};
12-
use instant::Instant;
12+
use web_time::Instant;
1313

1414
use petgraph::{graph::EdgeIndex, stable_graph::DefaultIx};
1515
use petgraph::{graph::IndexType, Directed};

0 commit comments

Comments
 (0)