Issue: emscripten-core/emscripten#22394 Affected versions: Emscripten >= v3.1.58
This repository is a reproduction of an issue I'm facing with Emscripten and Vite.
When code using threads is compiled with Emscripten and then bundled with Vite it does not bundle and throws the following Vite error:
[vite:worker-import-meta-url] Vite is unable to parse the worker options as the value is not static.To ignore this error, please use /* @vite-ignore */ in the worker options.
file
Vite has required static worker options for some time, over 2 years. Recent changes to Emscripten have made output code incompatible with the Vite bundler.
- (Optional) Assumes Emscripten is installed (See https://emscripten.org/docs/getting_started/downloads.html)
- Clone this repository
- Run
npm install
&&npm run build
Refactor library_pthread.js to use static values for the worker options. It'll be more verbose but it'll make the code compatible with Vite and maintain compatibility with other bundlers.