emscripten-core / emscripten-core/emscripten
Dynamic import does not work in all browsers
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
TLDR: Dynamic import does not work in all browsers, so usage of ES6 imports in workers to support pthreads is problematic
When targeting an `.mjs` output, emscripten will export JS as ES6. This mostly works, but FF does not yet support ES6 imports in workers, so I get this error in FF:
```
Error: Dynamic module import is disabled or not supported in this context
```
(from module.worker.js)
If this is a known limitation, perhaps it should be noted [here](https://emscripten.org/docs/tools_reference/emcc.html?highlight=emcc#:~:text=ES6%20JavaScript%20module).
For anyone wanting to support more than just Chrome this makes ".mjs" a non-starter when using pthreads. If pthreads workers can't be implemented without relying on ES6, perhaps emscripten could emit a big warning when this happens warning that these flags are currently incompatible with cross-browser support?
ref https://bugzilla.mozilla.org/show_bug.cgi?id=1247687
Contributor guide
Assessment
This issue has not been assessed yet.