Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Firefox really support the `type` option for the Worker constructor?

I can't seem to be able to instantiate a web worker from a ES6 script file. MDN says it should be possible like this:

const worker = new Worker('my-worker.js', {type:"module"});

That doesn't work for me, I get an error:

 SyntaxError: import declarations may only appear at top level of a module

MCVE:

test.html

<html>
<head></head>
<body><script type="text/javascript">
    new Worker("worker.js", { type: "module" });

    </script></body>
</html>

worker.js

import Nothing from "./nothing.js";

Firefox version: 62.0.2

like image 640
Tomáš Zato - Reinstate Monica Avatar asked Nov 08 '22 01:11

Tomáš Zato - Reinstate Monica


1 Answers

No it currently (April 2021) does not, see this feature request for details:
https://bugzilla.mozilla.org/show_bug.cgi?id=1247687

like image 88
Ray Hulha Avatar answered Nov 13 '22 18:11

Ray Hulha