emscripten-core / emscripten-core/emscripten
EXPORT_ES6=1 vs. WASM=0
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 109
Description
When `EXPORT_ES6=1` and `WASM=0` are specified together, the resulting module cannot be loaded, because it still looks for the (non-existent) `.wasm file`:
```
var wasmBinaryFile;
if (Module["locateFile"]) {
wasmBinaryFile = "index.wasm";
if (!isDataURI(wasmBinaryFile)) {
wasmBinaryFile = locateFile(wasmBinaryFile);
}
} else {
wasmBinaryFile = new URL("index.wasm", import.meta.url).href;
}
```
This can partially be worked around by adding a `--pre-js` containing:
```
Module.locateFile = () => null;
```
However, this workaround is incomplete, because Webpack will still try to follow the `import.meta.url` and bundle the non-existent wasm, resulting in failure (so you need a custom Webpack config to make it ignore that file).
Note that WASM=2 also doesn't really seem to work, at least on browsers with incomplete WebAssembly support like Safari 13, but that'll be a different bug report.
**Version of emscripten/emsdk:**
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.32 (eab98adf462c39f3c31d348331c4830bcaa36949)
clang version 17.0.0 (https://github.com/llvm/llvm-project df82394e7a2d06506718cafa347bf7827c79fc4f)
Target: wasm32-unknown-emscripten
**Full link command and output with `-v` appended:**
```/home/dhd/work/emsdk/upstream/emscripten/emcc -g @/home/dhd/work/SoundSwallower/js/linker_options.txt --extern-pre-js /home/dhd/work/SoundSwallower/js/api-web-pre.js -sENVIRONMENT=web -sWASM=0 -sMODULARIZE=1 -sEXPORT_ES6=1 -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=@/home/dhd/work/SoundSwallower/js/library_funcs.txt -sEXPORTED_FUNCTIONS=@/home/dhd/work/SoundSwallower/js/exported_functions.txt js/CMakeFiles/soundswallower.jsonly.dir/soundswallower.c.o -o jsonly/index.js -Wl,--whole-archive libsoundswallower.a -Wl,--no-whole-archive libsoundswallower.jsonly_1_api-jsonly-pre_js.a --pre-js "/home/dhd/work/SoundSwallower/js/api-jsonly-pre.js" libsoundswallower.jsonly_1_api-web_js.a --post-js "/home/dhd/work/SoundSwallower/js/api-web.js" libsoundswallower.jsonly_2_api_js.a --post-js "/home/dhd/work/SoundSwallower/js/api.js"```
Contributor guide
Assessment
This issue has not been assessed yet.