Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebAssembly with Reference Types cannot be parsed #931

Open
Tarnadas opened this issue Jun 12, 2021 · 1 comment
Open

WebAssembly with Reference Types cannot be parsed #931

Tarnadas opened this issue Jun 12, 2021 · 1 comment

Comments

@Tarnadas
Copy link

Bug report

WebAssembly modules with enabled Reference Types cannot be loaded.
I encountered this bug while using Webpack 5.

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

Here is the related Webpack ticket:
webpack/webpack#13559

@CryZe
Copy link

CryZe commented Nov 17, 2021

The stable versions of all major browsers support reference types now. Would be great to get this working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants