You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regression: mainScriptUrlOrBlob ignored when USE_ES6_IMPORT_META is off #23769
The recent removal of USE_ES6_IMPORT_META broke a use case like this:
I want to host an emscripten-compiled package somewhere (e.g., a CDN) that is compiled to use pthreads
I want to instantiate a module from those scripts on another origin domain
Browsers refuse to download cross-origin workers, so I can't create threads.
This used to be supported using either an importScripts() hack in the worker or by downloading the whole script as a blob, but now that's not possible since the fix in #23171 forces the use of a specific file name.
For a bit more detail: Using a blob as the actual script means that import.meta.url is a blob, so new URL(...) can't work. Using a mainScriptBlobOrUrl is just ignored. So both of the tricks I've used in the past for cross origin workers are not available.
If mainScriptUrlOrBlob is set, create the worker as in the old non-use-import-meta case (or else deprecate that field under export_es6 and assert that mainScriptUrlOrBlob is not set)
If import.meta.url is a blob url, use it instead of creating a new URL.
Activity
JoeOsborn commentedon Feb 26, 2025
For a bit more detail: Using a blob as the actual script means that import.meta.url is a blob, so new URL(...) can't work. Using a mainScriptBlobOrUrl is just ignored. So both of the tricks I've used in the past for cross origin workers are not available.
sbc100 commentedon Feb 26, 2025
Thanks Joe! We are obviously lacking some test coverage here.
JoeOsborn commentedon Feb 27, 2025
I think a reasonable fix for this is to:
Support blob URLs on ES6 with USE_ES6_IMPORT_META enabled
Support blob URLs on ES6 with USE_ES6_IMPORT_META enabled
Support blob URLs on ES6 with USE_ES6_IMPORT_META enabled
Use mainScriptUrlOrBlob if present under EXPORT_ES6 (#23890)
sbc100 commentedon Mar 20, 2025
I believe this was fixed in #23890 and can be closed?
JoeOsborn commentedon Mar 20, 2025
Fixed in #23890