Skip to content

Commit

Permalink
Fix dependency issues
Browse files Browse the repository at this point in the history
1. Reorganize dependencies and remove requirements ("=") on wasm-bindgen
   and js-sys, due to conflicts that can occur when using this crate.
2. Replace wasm-bindgen's "serde-serialize" feature with
   serde-wasm-bindgen due to cyclical dependency issue.

Relates to:
tkaitchuck/aHash#95
rustwasm/wasm-bindgen#3031
  • Loading branch information
trevor-crypto committed Aug 26, 2022
1 parent 8b0a2b2 commit b72e364
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
18 changes: 14 additions & 4 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ num-integer = "0.1.45"
# feature or this one
clear_on_drop = { version = "0.2", features = ["no_cc"] }
itertools = "0.10.1"
getrandom = { version = "0.2.3", features = ["js"] }
rand = "0.8.4"
schemars = "0.8.8"
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -41,12 +40,15 @@ serde = { version = "1.0", features = ["derive"] }
[target.'cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))'.dependencies]
rand_os = "0.1"
noop_proc_macro = "0.3.0"
getrandom = "0.2.3"

# wasm
[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies]
wasm-bindgen = { version = "=0.2.78", features = ["serde-serialize"] }
serde-wasm-bindgen = "0.4.3"
wasm-bindgen = "=0.2.78"
rand_os = { version = "0.1", features = ["wasm-bindgen"] }
js-sys = "=0.3.51"
js-sys = "0.3.51"
getrandom = { version = "0.2.3", features = ["js"] }

[profile.release]
# Tell `rustc` to optimize for small code size.
Expand Down
2 changes: 1 addition & 1 deletion rust/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ macro_rules! to_from_json {

#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
pub fn to_js_value(&self) -> Result<JsValue, JsError> {
JsValue::from_serde(&self)
serde_wasm_bindgen::to_value(&self)
.map_err(|e| JsError::from_str(&format!("to_js_value: {}", e)))
}

Expand Down

0 comments on commit b72e364

Please sign in to comment.