-
Notifications
You must be signed in to change notification settings - Fork 224
Description
See this comment for context: #137 (comment)
Previous toil on this issue:
Fix in this crate for Webpack 4: #137
Rustwasm bug: drager/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 annotatemodule.require
with some sort of "ignore warning" requirement - Use a Node.js dynamic
import()
call - Use
wasm_bindgen
'smodule
attribute. - Use
wasm_bindgen
'sinline_js
attribute - Get upstream Rust to finally have
wasm32-unknown-browser
andwasm32-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).