See this comment for context: #137 (comment)
Previous toil on this issue:
Fix in this crate for Webpack 4: #137
Rustwasm bug: wasm-bindgen/wasm-pack#822
Webpack bug closed as WONTFIX: webpack/webpack#8826
Advice on how to fix this issue for Webpack: webpack/webpack#8826 (comment)
Basically, our #[wasm_bindgen] declaration generates Javascript that looks like:
module.require(getStringFromWasm0(arg0, arg1));
Despite this being valid JavaScript, Webpack doesn't like it for some reason.
It seems like our options to fix this are:
- Tell users how to ignore the warning (it is just a warning after all)
- Tell users how to configure Webpack to not get this error (involves some
package.json stuff I don't understand)
- File an upstream bug with Webpack to properly support wasm
- File an upstream bug with the Rust
wasm_bindgen tool to annotate module.require with some sort of "ignore warning" requirement
- Use a Node.js dynamic
import() call
- Use
wasm_bindgen's module attribute.
- Use
wasm_bindgen's inline_js attribute
- Get upstream Rust to finally have
wasm32-unknown-browser and wasm32-unknown-node targets, so that we don't have to do browser vs Node detection at runtime.
Things we shouldn't try to do:
- Replace this with another hack to trick the bundler (I don't want to keep dealing with this issue)
eval("require(crypto)")
However, I don't have the expertise to solve this problem. If anyone (@Pauan, @huacnlee , @Herohtar) knows how to fix this issue, I would happily accept a PR provided the solution is documented and our CI keeps passing (we don't use the Webpack bundler in our CI, hence why we missed this).
See this comment for context: #137 (comment)
Previous toil on this issue:
Fix in this crate for Webpack 4: #137
Rustwasm bug: wasm-bindgen/wasm-pack#822
Webpack bug closed as WONTFIX: webpack/webpack#8826
Advice on how to fix this issue for Webpack: webpack/webpack#8826 (comment)
Basically, our
#[wasm_bindgen]declaration generates Javascript that looks like:Despite this being valid JavaScript, Webpack doesn't like it for some reason.
It seems like our options to fix this are:
package.jsonstuff I don't understand)wasm_bindgentool to annotatemodule.requirewith some sort of "ignore warning" requirementimport()callwasm_bindgen'smoduleattribute.wasm_bindgen'sinline_jsattributewasm32-unknown-browserandwasm32-unknown-nodetargets, so that we don't have to do browser vs Node detection at runtime.Things we shouldn't try to do:
eval("require(crypto)")However, I don't have the expertise to solve this problem. If anyone (@Pauan, @huacnlee , @Herohtar) knows how to fix this issue, I would happily accept a PR provided the solution is documented and our CI keeps passing (we don't use the Webpack bundler in our CI, hence why we missed this).