Add support for Web Worker type="module" (ES6 module imports in worker scripts)
Categories
(Core :: JavaScript Engine, enhancement)
Tracking
()
People
(Reporter: u591120, Unassigned)
References
(Blocks 1 open bug)
Details
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36
Steps to reproduce:
main.js:
let w = new Worker("./myWorker.js", {type:"module"});
myWorker.js:
import MyModule from "./MyModule.js";
self.onmessage = () => {
// ...
}
Actual results:
Firefox doesn't support ES6 import statements in workers.
Expected results:
Chrome has had module workers behind a flag for a while now. It would be great if firefox could support {type:"module"} soon as well. Currently I'm forced to either not use ES6 module imports/exports in the libraries I'm making, or make two copies of the same library (one where the files are linked together with import
and export
, and another where there are no imports/exports - and instead all the scripts are imported at the top of my worker script (in the correct order, which can get complicated). There are obviously other workarounds for this (e.g. build pipelines), but it would be super nice to not have to deal with that for simple projects.
Here's the chromestatus page:
https://www.chromestatus.com/feature/5761300827209728
Here's the spec:
https://html.spec.whatwg.org/multipage/workers.html#workeroptions
Comment 1•6 years ago
|
||
Bugbug thinks this bug is a enhancement, but please change it back in case of error.
Comment 2•6 years ago
|
||
This being an enhancement I will set a component to it and further someone from dev's team could take a look on this. As well there is a meta bug about the support of ES6 modules.
Thanks.
Updated•6 years ago
|
Description
•