webpack: WebAssembly with Reference Types cannot be parsed
Reopened #13559
Bug report
WebAssembly modules with enabled Reference Types cannot be loaded. The webpack version I tested this with is 5.38.1
For a minimal reproduction I created this repository: https://github.com/Tarnadas/webpack-5-wasm-reftypes
The error message is the following:
ERROR in ./pkg/webpack_5_wasm_reftypes_bg.wasm
Module parse failed: Internal failure: parseVec could not cast the value
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Error: Internal failure: parseVec could not cast the value
at new CompileError (/home/marior/projects/webpack-5-wasm-reftypes/node_modules/@webassemblyjs/helper-api-error/lib/index.js:40:109)
at parseVec (/home/marior/projects/webpack-5-wasm-reftypes/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:328:15)
at parseTypeSection (/home/marior/projects/webpack-5-wasm-reftypes/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:360:22)
at parseSection (/home/marior/projects/webpack-5-wasm-reftypes/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1363:24)
at Object.decode (/home/marior/projects/webpack-5-wasm-reftypes/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1712:25)
at decode (/home/marior/projects/webpack-5-wasm-reftypes/node_modules/@webassemblyjs/wasm-parser/lib/index.js:248:21)
at WebAssemblyParser.parse (/home/marior/projects/webpack-5-wasm-reftypes/node_modules/webpack/lib/wasm-async/AsyncWebAssemblyParser.js:48:19)
at /home/marior/projects/webpack-5-wasm-reftypes/node_modules/webpack/lib/NormalModule.js:1018:26
at processResult (/home/marior/projects/webpack-5-wasm-reftypes/node_modules/webpack/lib/NormalModule.js:745:11)
at /home/marior/projects/webpack-5-wasm-reftypes/node_modules/webpack/lib/NormalModule.js:809:5
@ ./pkg/webpack_5_wasm_reftypes.js 1:0-58 4:0-21
@ ./src/index.js 1:0-16
webpack 5.38.1 compiled with 1 error in 572 ms
error Command failed with exit code 1.
I used Rust with wasm-bindgen, which provides a cli option to enable reference types. Instead of directly using wasm-bindgen, I’ve been using wasm-pack, but since it’s unmaintained, you will need my fork to pass the cli option down to wasm-bindgen. You can see my PR for wasm-pack here: rustwasm/wasm-pack#888
By looking at the error message, it seems to be a problem with the wasm parser library. I checked its repository and couldn’t find any mentions about reference types unfortunately, so I’m not sure how to proceed with this.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 39 (16 by maintainers)
Commits related to this issue
- Pin Rust version used in wasm CI test to 1.81 See https://github.com/webpack/webpack/issues/15566 — committed to koto-lang/koto by irh 2 years ago
- Workaround for webpack/webpack#15566 — committed to compute-toys/wgpu-compute-toy by davidar 2 years ago
- update deps seeing if this fixes supposed to fix https://github.com/webpack/webpack/issues/15566, appears not to — committed to ivnsch/molsimnext by ivnsch 2 years ago
- Workaround WebPack parser bug Based on https://github.com/webpack/webpack/issues/15566#issuecomment-2558347645 — committed to amatveiakin/bughouse-chess by amatveiakin 2 years ago
- fix gchimp-web static site compile it seems like nextjs is not updating their webpack. So for the time being, doing this will fix the issue https://github.com/webpack/webpack/issues/15566 — committed to khanghugo/gchimp by khanghugo 2 years ago
- Update @nimiq/core to v2.0.6 and update Webpack to support it Webpack was running into https://github.com/webpack/webpack/issues/15566 with the latest @nimiq/core version, but an update fixed it. — committed to nimiq/wallet by sisou 2 years ago
- upgrade Webpack from 5.94 to 5.98 Resolves https://github.com/webpack/webpack/issues/15566 — committed to initiative-sh/initiative.sh by MikkelPaulson 2 years ago
- upgrade Webpack from 5.94 to 5.98 Resolves https://github.com/webpack/webpack/issues/15566 — committed to initiative-sh/initiative.sh by MikkelPaulson 2 years ago
- upgrade Webpack from 5.94 to 5.98 Resolves https://github.com/webpack/webpack/issues/15566 — committed to initiative-sh/initiative.sh by MikkelPaulson 2 years ago
- js: Update webpack packaging tests to webpack 5.99.0 Problem: when using rustc > 1.82 and webpack < 5.97.0 the wasm file generated by wasm-bindgen can't be loaded by webpack. This is tracked by an is... — committed to automerge/automerge by alexjg 2 years ago
- js: Update webpack packaging tests to webpack 5.99.0 Problem: when using rustc > 1.82 and webpack < 5.97.0 the wasm file generated by wasm-bindgen can't be loaded by webpack. This is tracked by an is... — committed to automerge/automerge by alexjg 2 years ago
Issue was closed because of inactivity.
If you think this is still a valid issue, please file a new issue with additional information.
I’m still getting the error “Module parse failed: Internal failure: parseVec could not cast the value”
https://github.com/ivnsch/molsimnext
the only way to fix it is still the workaround
I published 1.14.1. Could you please try again @alexander-akait ?
Sorry I had some issues with my publish setup.
Stripping solves the problem:
This isn’t great for debug builds however, as you usually want the debug symbols. I believe the reason why stripping works isn’t because it does any stripping, but because it likely optimizes the overlong immediates encoding back to how it was before LLVM 19. Running
wasm-optprobably behaves the same way.Version 1.13.1 has been published with reference types support. We need to update in webpack.
In two days (2024-10-17) Rust 1.82 will be released, and reference types will be on by default. The only way to build without reference types will be to use nightly and rebuild the standard library without reference types support.
@xtuc Works for me!
https://github.com/mateuszJS/rust-webpack-v5-template/tree/webpack-v5-migration Thank you for great work 👍
On the weekend I tracked down the issue back into
wasm-bindgenwhich apparently uses thetarget_featuressection to detect if it should automatically enable its full reference types support. I opened a PR that ensures that you still have to opt into that manually, so that should fix all issues that were caused by Rust 1.82: https://github.com/rustwasm/wasm-bindgen/pull/4213Last time you at least gave a warning, and it’s marked as completed?? This has to be the worst bot ever.