Skip to content

Single-file JS-only file has reference to non-existing .wasm file (since 4.0.6) #25012

@pasieronen

Description

@pasieronen

I'm building a single-file JS-only file (-sWASM=0 -sSINGLE_FILE=1), which eventually gets bundled with Webpack. With 4.0.5 everything works fine, but with 4.0.6, the resulting .js file has a reference to a .wasm file (which obviously does not exist with these options), and Webpack chokes on that.

The probable culprit is commit 975084c.

How to reproduce:

adder.c

int add(int a, int b) { return a + b; }

index.js

import createAdder from './adder.mjs'
(async () => {
  const Module = await createAdder()
  const add = Module.cwrap("add", "number", ["number","number"]);
  alert("2+3 = " + add(2, 3))
})();

webpack.config.cjs

module.exports = {
  mode: "development",
  entry: "./index.js",
  output: {filename: "bundle.js", path: __dirname}
}

Commands:

emcc -sENVIRONMENT=web -sWASM=0 -sMODULARIZE=1 -sEXPORT_ES6=1 -sSINGLE_FILE=1 -sEXPORTED_FUNCTIONS='["_add"]' -sEXPORTED_RUNTIME_METHODS='["cwrap", "ccall"]'  adder.c -o adder.mjs
# succeeds, nothing special in output

npx webpack-cli@6.0.1
# fails with "Module not found: Error: Can't resolve 'adder.wasm' ...'

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.6 (1ddaae4)
clang version 21.0.0git (https:/github.com/llvm/llvm-project 4775e6d9099467df9363e1a3cd5950cc3d2fde05)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: (omitted)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions