From f492a459cdfd7d67ee3f2c657d4243ac73a45269 Mon Sep 17 00:00:00 2001 From: Alvin Wong Date: Mon, 24 Feb 2020 22:22:20 +0800 Subject: [PATCH] Fix resolution of `wasm_bindgen` in `js!` macro 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` --- stdweb-internal-macros/src/js_shim.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/stdweb-internal-macros/src/js_shim.rs b/stdweb-internal-macros/src/js_shim.rs index 263ed4ad..8330176c 100644 --- a/stdweb-internal-macros/src/js_shim.rs +++ b/stdweb-internal-macros/src/js_shim.rs @@ -115,6 +115,7 @@ pub fn js_shim_extern_code( target: Target, code: &str, arg_count: usize, return let shim_name = &shim_name; let shim_args = &shim_args; quote! { + use ::stdweb::private::wasm_bindgen; use ::stdweb::private::wasm_bindgen::prelude::*; unsafe fn #shim_name( #(#shim_args),* ) #return_signature { #[wasm_bindgen(inline_js = #code_string)]