Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resolution of wasm_bindgen in js! macro #390

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant