Closed Bug 1385219 Opened 3 years ago Closed 3 years ago

WebExtension: can’t import a module

Categories

(WebExtensions :: Untriaged, enhancement)

enhancement
Not set

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: olivier.dev, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0
Build ID: 20170628075643

Steps to reproduce:

Building a WebExtension, I tried to import a module in a background script.

Example:
`import { myfunction } from "./mymodule/helpers.js";`



Actual results:

Whatever I tried, I got the following error message:

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

Even if the import statement were at line 1.


Expected results:

We should have the behavior described there:
https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Instructions/import

We should also be able to import in BrowserAction script and Content script.
Severity: normal → enhancement
Component: Untriaged → WebExtensions: Untriaged
Product: Firefox → Toolkit
Version: 54 Branch → Trunk
See the "Browser Compatibility" section of the MDN page you linked to, import isn't (yet) supported.
Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → INVALID
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.