Repository navigation
[Old] Fix pthread worker options usage with Vite bundler - #22834
jamsinclair wants to merge 17 commits into
Conversation
| } | ||
| ); | ||
| worker = new Worker(p.createScriptURL('ignored'), workerOptions); | ||
| worker = new Worker(p.createScriptURL('ignored'), {{{ WORKER_OPTIONS }}}); |
There was a problem hiding this comment.
I simpler way to do this would be to define a new macro here at the top of this file. e.g.
{{{
globalThis.WORKER_OPTIONS = {
...
};
null;
}}}
There was a problem hiding this comment.
Thank you so much! I wasn't too sure how the templating works in these files 😅 . I'll update the PR with this approach when I get a chance.
|
Edit: I do wonder if we can work with Vite to allow dynamic values and only require the worker Edit 2: Proposed changes to Vite are likely to be accepted that would allow us support dynamic name fields (See: vitejs/vite#19010). I'll update this merge request with this in mind. |
|
Superseded by #23607 |
Overview
An attempt at solving #22394.
When code using threads is compiled with Emscripten and then bundled with Vite it does not bundle and throws an error.
This is due to a variable reference for worker options being used during worker construction. Vite needs static worker options to bundle the code successfully.
As discussed in the issue, the easiest solution would be to switch to using an object literal for each worker construction.