Skip to content

Fix resolution of wasm_bindgen in js! macro#390

Open
alvinhochun wants to merge 1 commit intokoute:masterfrom
alvinhochun:fix-undeclared-wasm-bindgen
Open

Fix resolution of wasm_bindgen in js! macro#390
alvinhochun wants to merge 1 commit intokoute:masterfrom
alvinhochun:fix-undeclared-wasm-bindgen

Conversation

@alvinhochun
Copy link

This fixes an issue that, when a dependent crate depends on stdweb for the use of the js! macro but does not specify the dependency wasm_bindgen, attempting to build for the target wasm32-unknown-unknown (or using wasm-pack and friends) will yield the following error:

error[E0433]: failed to resolve: use of undeclared type or module `wasm_bindgen` 

Steps to reproduce/verify:

  1. Apply the following change:
diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 6cc4623..129d50e 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -1,2 +1,5 @@ [workspace] members = ["canvas", "drag", "echo", "futures", "gamepad", "hasher", "minimal", "todomvc", "webgl", "wasm-bindgen-minimal"] + +[patch.crates-io] +stdweb = { path = ".." } diff --git a/examples/wasm-bindgen-minimal/Cargo.toml b/examples/wasm-bindgen-minimal/Cargo.toml index 848c70e..a29056b 100644 --- a/examples/wasm-bindgen-minimal/Cargo.toml +++ b/examples/wasm-bindgen-minimal/Cargo.toml @@ -10,3 +10,4 @@ crate-type = ["cdylib"] [dependencies] wasm-bindgen = "0.2" stdweb = { path = "../.." } +instant = { version = "=0.1.2", features = [ "stdweb" ]} diff --git a/examples/wasm-bindgen-minimal/src/lib.rs b/examples/wasm-bindgen-minimal/src/lib.rs index 70c7517..bad6967 100644 --- a/examples/wasm-bindgen-minimal/src/lib.rs +++ b/examples/wasm-bindgen-minimal/src/lib.rs @@ -10,5 +10,7 @@ pub fn main() -> Result<(), JsValue> { alert( @{message} ); } + instant::Instant::now(); + Ok(()) }
  1. From the directory examples/wasm-bindgen-minimal/, execute the command cargo build --lib --target wasm32-unknown-unknown.
This fixes an issue that, when a dependent crate depends on `stdweb` for the use of the `js!` macro but does not specify the dependency `wasm_bindgen`, attempting to build for the target `wasm32-unknown-unknown` (or using `wasm-pack` and friends) will yield the following error: error[E0433]: failed to resolve: use of undeclared type or module `wasm_bindgen`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant