diff --git a/src/library_pthread.js b/src/library_pthread.js index 864bd7eeabed..794852e0c96e 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -452,10 +452,10 @@ var LibraryPThread = { createScriptURL: (ignored) => new URL('{{{ PTHREAD_WORKER_FILE }}}', import.meta.url); } ); - worker = new Worker(p.createScriptURL('ignored')); + worker = new Worker(p.createScriptURL('ignored'), {type: 'module'}); } else #endif - worker = new Worker(new URL('{{{ PTHREAD_WORKER_FILE }}}', import.meta.url)); + worker = new Worker(new URL('{{{ PTHREAD_WORKER_FILE }}}', import.meta.url), {type: 'module'}); } else { #endif // Allow HTML module to configure the location where the 'worker.js' file will be loaded from, @@ -568,7 +568,7 @@ var LibraryPThread = { // Called when a thread needs to be strongly referenced. // Currently only used for: // - keeping the "main" thread alive in PROXY_TO_PTHREAD mode; - // - crashed threads that needs to propagate the uncaught exception + // - crashed threads that needs to propagate the uncaught exception // back to the main thread. #if ENVIRONMENT_MAY_BE_NODE if (ENVIRONMENT_IS_NODE) { diff --git a/test/test_other.py b/test/test_other.py index 6f88b545343b..376b72434061 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -303,7 +303,7 @@ def test_emcc_output_worker_mjs(self, args): test_file('hello_world.c')] + args) src = read_file('subdir/hello_world.mjs') self.assertContained("new URL('hello_world.wasm', import.meta.url)", src) - self.assertContained("new Worker(new URL('hello_world.worker.js', import.meta.url))", src) + self.assertContained("new Worker(new URL('hello_world.worker.js', import.meta.url), {type: 'module'})", src) self.assertContained('export default Module;', src) src = read_file('subdir/hello_world.worker.js') self.assertContained("import('./hello_world.mjs')", src) @@ -317,7 +317,7 @@ def test_emcc_output_worker_mjs_single_file(self): test_file('hello_world.c'), '-sSINGLE_FILE']) src = read_file('hello_world.mjs') self.assertNotContained("new URL('data:", src) - self.assertContained("new Worker(new URL('hello_world.worker.js', import.meta.url))", src) + self.assertContained("new Worker(new URL('hello_world.worker.js', import.meta.url), {type: 'module'})", src) self.assertContained('hello, world!', self.run_js('hello_world.mjs')) def test_emcc_output_mjs_closure(self):