...
It seems that support `new Worker(…, {type: "module"})` is limited or missing. In a project that uses only pure ES modules served using a very basic express server (ie express.static) over http://127.0.0.1:8080 or http://localhost:8080 a worker module with static import statements: ``` import {…} from '…' ``` Throws: SyntaxError: Unexpected token '{'. import call expects exactly one argument. It should be noted that those static import statements are synthesized using rollup and the resulting files sometimes include one or more variable declarations before the occurrence of the import statements. The same project does not throw in Chrome.
Note that supporting dynamic `import()` in Web Workers can also be a first start along these lines.
Just stumbled on this ticket and am quite surprised that it did not get way more comments yet. I am crafting a web workers driven ES8 framework, so module support for workers (including dynamic imports) is one of the key features lacking in Safari. In Chrome this works already for close to a year using the experimental web plattform features and now got the Label Target-80. Without the type="module" support, applications have to use build tools like Webpack, which is slowing the web development speed down by a long shot! Please be aware, that this ticket should also include the module type for shared & service workers. I recommend to make it a high priority epic. Thanks & best regards Tobias
A quick update on the current status would be appreciated. The new framework is online now and already at 227 github stars (December 20): https://github.com/neomjs/neo Here are the online examples, which according to the specs should work in every modern browser: https://neomjs.github.io/pages/ It makes me a bit sad to see Safari falling behind on an such important topic. https://html.spec.whatwg.org/multipage/workers.html#module-worker-example Hoping you will catch up! Best regards & happy holiddays, Tobias
<rdar://problem/64348230>
Created attachment 402347 [details] Patch WIP