I want to develop WebAssembly in Rust.
Now I'm stuck with "wasm_bindgen". I get the following error, how can I fix it?
The "index.js" and "lib.rs" are indeed in the same folder.
to quote the section from the guide:
Paths in
module = "..."
must currently start with/
, or be rooted at the crate root. It is intended to eventually support relative paths like./
and../
, but it's currently believed that this requires more support in the Rustproc_macro
crate.
see also #1343
for discussion of a related issue
Thanks for the reply.
I made the following modifications, WebPack now gives me another error.
#[wasm_bindgen(module = "index")]
Now it seems to me that the content should be as follows...
#[wasm_bindgen(module = ". /index")]
is the module you are trying to import a local js file or external managed (e.g. npm module)?
the module
attribute can have dual purposes, if you are trying to use a local js file, the module
attribute should be the path to your js file inside the root directory (i.e. the directory containing Cargo.toml
); for npm modules, you might want to use raw_module
to avoid the ambiguity.
see the #1314
discussion linked in previous reply.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.