admin管理员组

文章数量:1410712

I'm working on a JavaScript game and it works as intended in Chrome and Safari. However, in Firefox, the page doesn't load any scripts, and the debugger is empty. I'm not seeing any errors at all. This is the entirety of the html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <canvas id="canvas"></canvas>
    <script type="module" src="foo.js"></script>
    <script type="module" src="bar.js"></script>
    <script type="module" src="baz.js"></script>
    <script type="module" src="qux.js"></script>
    <script type="module" src="foobar.js"></script>
    <script type="module" src="bazqux.js"></script>
</body>
</html>

UPDATE: Some added context for future readers: per Roko C. Buljan's answer, it turns out ES6 modules are not on by default in FireFox at the time of writing. That was the issue.

I'm working on a JavaScript game and it works as intended in Chrome and Safari. However, in Firefox, the page doesn't load any scripts, and the debugger is empty. I'm not seeing any errors at all. This is the entirety of the html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <canvas id="canvas"></canvas>
    <script type="module" src="foo.js"></script>
    <script type="module" src="bar.js"></script>
    <script type="module" src="baz.js"></script>
    <script type="module" src="qux.js"></script>
    <script type="module" src="foobar.js"></script>
    <script type="module" src="bazqux.js"></script>
</body>
</html>

UPDATE: Some added context for future readers: per Roko C. Buljan's answer, it turns out ES6 modules are not on by default in FireFox at the time of writing. That was the issue.

Share Improve this question edited Jan 12, 2018 at 0:57 PopKernel asked Jan 11, 2018 at 23:31 PopKernelPopKernel 4,2707 gold badges33 silver badges55 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 6

You're using module features not openly available in Firefox. To enable them you could go to about:config and enable them under dom.moduleScripts.enabled setting its Value to true

Meanwhile you could use a polyfill like this or use build tools that will pile your modules into a single ES5-backed production-ready file.

Some indepth readings:

https://html.spec.whatwg/multipage/webappapis.html#integration-with-the-javascript-module-system
https://developer.mozilla/en-US/docs/Web/HTML/Element/script https://jakearchibald./2017/es-modules-in-browsers/
https://medium./webpack/the-state-of-javascript-modules-4636d1774358

In my case, I needed to go to about:config, reset the devtools.debugger.project-directory-root-name setting to default and set devtools.debugger.project-directory-root value to top-level.

The problem was that I was using the "Set directory root" function on one of the sites. Firefox made it impossible (hint, please, if this is not true) to get back from this wonderful mode without going to the same site or fixing the variables associated with this mode manually.

本文标签: javascriptFirefox this page has no sourcesStack Overflow