Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/lib/libpthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ const pthreadWorkerScript = TARGET_JS_NAME;
// See https://github.com/emscripten-core/emscripten/issues/22394
const pthreadWorkerOptions = `{
#if EXPORT_ES6
#if MIN_FIREFOX_VERSION < 114
#error new Worker() supports ECMAScript module only starting from Firefox 114. Pass -sMIN_FIREFOX_VERSION=114 to target -sEXPORT_ES6 with -pthread. See https://caniuse.com/mdn-api_worker_worker_ecmascript_modules
#endif
#if MIN_CHROME_VERSION < 80
#error new Worker() supports ECMAScript module only starting from Chrome 80. Pass -sMIN_CHROME_VERSION=80 to target -sEXPORT_ES6 with -pthread. See https://caniuse.com/mdn-api_worker_worker_ecmascript_modules
#endif
#if MIN_SAFARI_VERSION < 150000
#error new Worker() supports ECMAScript module only starting from Safari 15. Pass -sMIN_SAFARI_VERSION=150000 to target -sEXPORT_ES6 with -pthread. See https://caniuse.com/mdn-api_worker_worker_ecmascript_modules
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is even possible to hit these error now that the feature is added? i.e. -sEXPORT_ES6 + -pthreads will now force the correct versions or fail, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was pondering the same, so wanted to add these in to verify that won't be the case. Doesn't hurt to have them?

Or I could remove them - but seems like they're safe to have, they could trigger on possible refactors down the road.

'type': 'module',
#endif
#if ENVIRONMENT_MAY_BE_NODE
Expand Down
9 changes: 9 additions & 0 deletions src/lib/libwasm_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@
`;
const wasmWorkerOptions = `{
#if EXPORT_ES6
#if MIN_FIREFOX_VERSION < 114
#error new Worker() supports ECMAScript module only starting from Firefox 114. Pass -sMIN_FIREFOX_VERSION=114 to target -sEXPORT_ES6 with -sWASM_WORKERS. See https://caniuse.com/mdn-api_worker_worker_ecmascript_modules
#endif
#if MIN_CHROME_VERSION < 80
#error new Worker() supports ECMAScript module only starting from Chrome 80. Pass -sMIN_CHROME_VERSION=80 to target -sEXPORT_ES6 with -sWASM_WORKERS. See https://caniuse.com/mdn-api_worker_worker_ecmascript_modules
#endif
#if MIN_SAFARI_VERSION < 150000
#error new Worker() supports ECMAScript module only starting from Safari 15. Pass -sMIN_SAFARI_VERSION=150000 to target -sEXPORT_ES6 with -sWASM_WORKERS. See https://caniuse.com/mdn-api_worker_worker_ecmascript_modules
#endif
'type': 'module',
#endif
#if ENVIRONMENT_MAY_BE_NODE
Expand Down
13 changes: 13 additions & 0 deletions tools/feature_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Feature(IntEnum):
THREADS = auto()
PROMISE_ANY = auto()
MEMORY64 = auto()
WORKER_ES6_MODULES = auto()


disable_override_features = set()
Expand Down Expand Up @@ -86,6 +87,14 @@ class Feature(IntEnum):
'safari': UNSUPPORTED,
'node': 230000,
},
# https://caniuse.com/mdn-api_worker_worker_ecmascript_modules: The ability to
# call new Worker(url, { type: 'module' });
Feature.WORKER_ES6_MODULES: {
'chrome': 80,
'firefox': 114,
'safari': 150000,
'node': 0, # This is a browser only feature, no requirements on Node.js
},
}

# Static assertion to check that we actually need each of the above feature flags
Expand Down Expand Up @@ -173,3 +182,7 @@ def apply_min_browser_versions():
enable_feature(Feature.BULK_MEMORY, 'shared-mem')
if settings.MEMORY64 == 1:
enable_feature(Feature.MEMORY64, 'MEMORY64')
if settings.EXPORT_ES6 and settings.PTHREADS:
enable_feature(Feature.WORKER_ES6_MODULES, 'EXPORT_ES6 with -pthread')
if settings.EXPORT_ES6 and settings.WASM_WORKERS:
enable_feature(Feature.WORKER_ES6_MODULES, 'EXPORT_ES6 with -sWASM_WORKERS')