admin管理员组文章数量:1323734
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
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
Share Improve this question asked Sep 25, 2018 at 18:13 Tomáš ZatoTomáš Zato 53.4k63 gold badges310 silver badges825 bronze badges 3-
MDN says that
Worker
works like that, it doesn't say that Firefox has implemented this feature already. – Bergi Commented Sep 25, 2018 at 21:49 - @Bergi It does not mention the support of the feature at all, either way. – Tomáš Zato Commented Sep 26, 2018 at 10:07
- As of today, this is still an issue, unfortunately. Tested with Firefox 75.0 – Tacticus Commented Apr 11, 2020 at 18:02
2 Answers
Reset to default 6No it currently (April 2021) does not, see this feature request for details:
https://bugzilla.mozilla/show_bug.cgi?id=1247687
Firefox resolved the support for type: module
in February 2023:
https://bugzilla.mozilla/show_bug.cgi?id=1247687
According Caniuse, this support was shipped as Firefox v114 in June 2023:
https://caniuse./mdn-api_worker_worker_ecmascript_modules
本文标签: javascriptDoes Firefox really support the type option for the Worker constructorStack Overflow
版权声明:本文标题:javascript - Does Firefox really support the `type` option for the Worker constructor? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742118899a2421600.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论