Closed
Description
Describe the Bug
Upgrade from 0.2.93 to 0.2.95 breaks some webpack builds
Steps to Reproduce
The following is a result of following the hello-wasm tutorial
- Compile the following code
See https://github.com/Jeroendevr/hello-wasm/tree/bug-0.2.95 for full repo
lib.rs
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern {
pub fn alert(s: &str);
}
#[wasm_bindgen]
pub fn greet(name: &str) {
alert(&format!("Hello, {}!", name));
}
cargo.toml
[package]
name = "hello-wasm"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
wasm-bindgen = "=0.2.95"
package.json
{
"name": "hello-wasm",
"version": "1.0.0",
"main": "index.js",
"author": "",
"license": "ISC",
"description": "",
"scripts": {
"build": "webpack --config webpack.config.js",
"serve": "webpack serve --config webpack.config.js --open"
},
"dependencies": {
"hello-wasm": "file:../pkg"
},
"devDependencies": {
"copy-webpack-plugin": "^11.0.0",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.2"
}
}
- Run terminal
wasm-pack build --target bundler
cd site
npm run build
- See error
Expected Behavior
Succesfull build and a webpage on localhost displaying an alert message
Actual Behavior
The following build error
❯ npm run build
> hello-wasm@1.0.0 build
> webpack --config webpack.config.js
assets by status 1.37 KiB [cached] 1 asset
asset index.js 12.2 KiB [emitted] (name: main)
asset index.html 170 bytes [compared for emit] [from: index.html] [copied]
runtime modules 1.77 KiB 4 modules
cacheable modules 3.13 KiB (javascript) 16.3 KiB (webassembly)
modules by path ../pkg/*.js 3.02 KiB
../pkg/hello_wasm.js 182 bytes [built] [code generated]
../pkg/hello_wasm_bg.js 2.84 KiB [built] [code generated]
./index.js 73 bytes [built] [code generated]
../pkg/hello_wasm_bg.wasm 40 bytes (javascript) 16.3 KiB (webassembly) [built] [code generated] [1 error]
ERROR in ../pkg/hello_wasm_bg.wasm
Module parse failed: Unknown element type in table: 0xNaN
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: Unknown element type in table: 0xNaN
at parseTableType (/Users/hayer/rust/hello-wasm/site/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1018:13)
at parseTableSection (/Users/hayer/rust/hello-wasm/site/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1274:24)
at parseSection (/Users/hayer/rust/hello-wasm/site/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1406:24)
at Object.decode (/Users/hayer/rust/hello-wasm/site/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1740:25)
at decode (/Users/hayer/rust/hello-wasm/site/node_modules/@webassemblyjs/wasm-parser/lib/index.js:253:21)
at WebAssemblyParser.parse (/Users/hayer/rust/hello-wasm/site/node_modules/webpack/lib/wasm-async/AsyncWebAssemblyParser.js:61:19)
at /Users/hayer/rust/hello-wasm/site/node_modules/webpack/lib/NormalModule.js:1309:19
at processResult (/Users/hayer/rust/hello-wasm/site/node_modules/webpack/lib/NormalModule.js:938:11)
at /Users/hayer/rust/hello-wasm/site/node_modules/webpack/lib/NormalModule.js:1036:5
at /Users/hayer/rust/hello-wasm/site/node_modules/loader-runner/lib/LoaderRunner.js:407:3
@ ../pkg/hello_wasm.js 1:0-45 4:15-19 5:0-21
@ ./index.js 1:0-35 3:0-10
webpack 5.96.1 compiled with 1 error in 112 ms
Additional Context
This works on wasm-bindgen 0.2.93
I have no experience with wasm just following the tutorial. I tried to verify that I have taken all the correct steps.