wasm-bindgen: In wasm-bindgen 0.2.84 version, webpack cannot generate wasm files
Steps to Reproduce
I created a repo with the problem here
Step1:
npm run i
Step2:
wasm-pack build
Step3:
npm run build
A dist dir contain index.js and wasm file will be generated in the project root; It is expected behavior.
When i change the wasm-bindgen version to 0.2.84 and run
rm -r pkg && wasm-pack build && npm run build
In dist dir, webpack doesn’t generate wasm files.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 7
- Comments: 15 (2 by maintainers)
Commits related to this issue
- fix(deps): temporarily pin wasm-bindgen to 0.2.83 to fix critical regression This regression rendered the OptiVorbis web demo unusable. Upstream issue: https://github.com/rustwasm/wasm-bindgen/issues... — committed to OptiVorbis/OptiVorbis by AlexTMjugador a year ago
- Fixed the HDR Histogram build for webpack - https://github.com/rustwasm/wasm-bindgen/issues/3276#issuecomment-1475805578 - https://github.com/rustwasm/wasm-pack/pull/1224 — committed to FamilySearch/pewpew by tkmcmaster a year ago
- Fix histogram (#119) * Fixed the HDR Histogram build for webpack - https://github.com/rustwasm/wasm-bindgen/issues/3276#issuecomment-1475805578 - https://github.com/rustwasm/wasm-pack/pull/1224 ... — committed to FamilySearch/pewpew by tkmcmaster a year ago
I’ve noticed this as well,
additionally: setting the version of wasm-bindgen back to 83 isn’t respected for some reason, and cargo continues building with 84 regardless.In my case, the files are being generated but they are invalid, and any use of them results in a javascript
undefined.It turns out this is happening because
wasm-packsets"sideEffects": falseforwasm-bindgengenerated code, which is a Webpack-specific flag that tells Webpack it can remove any code whose only impact is a side effect. In #3152, I unwittingly made initialisation rely on side effects, causing this problem.(So, it’s not a Webpack bug, I was a bit quick to assume that.)
I’ve opened rustwasm/wasm-pack#1224 to fix this. @alexcrichton or @drager, could you take a look at that PR?
This is now fixed in
wasm-packv0.11.0.Yeah, I will take a look soon. Thanks for looking into and fixing it!
I get issues with my own functions, or some stack pointer calls, such as
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '__wbindgen_add_to_stack_pointer')I have this exact issue, as soon as I upgrade to web_sys 0.3.61 from 0.3.60 any call to a Rust function from JavaScript results in an undefined error like:
(
on_assembly_changeis the Rust function being called, which sort of has bindings generated, as you can see)