Support of ES6 imports for webextensions

UNCONFIRMED
Unassigned

Status

()

Toolkit
WebExtensions: General
P3
enhancement
UNCONFIRMED
5 months ago
12 days ago

People

(Reporter: Rustam, Unassigned)

Tracking

(Depends on: 1 bug)

55 Branch
Points:
---

Firefox Tracking Flags

(firefox57 wontfix)

Details

Attachments

(1 attachment)

8.38 KB, application/zip
Details
(Reporter)

Description

5 months ago
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36

Steps to reproduce:

I tried to use ES6 imports in webextension like in this article https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import . 


Actual results:

Even with dom.moduleScripts.enabled flag they are not working


Expected results:

Please add support at least with dom.moduleScripts.enabled flag
(Reporter)

Comment 1

5 months ago
Created attachment 8901768 [details]
example.zip

Example of code that must work
(Reporter)

Comment 2

5 months ago
In 55th and 56th FF on win7 I am getting following error:

SyntaxError: import declarations may only appear at top level of a module
Component: General → WebExtensions: General

Updated

4 months ago
Severity: normal → enhancement
status-firefox57: --- → wontfix
Priority: -- → P3
If you want to use ES6 modules in your background page, you need to create an HTML page and use <script type="module"> in it rather than relying on the framework to generate a background page for you.
This is probably blocked until bug 1240072 is fixed, or at least far enough along.

After that, it would be a simple matter of adding `manifest.background.module` property.
Depends on: 1240072

Comment 5

a month ago
What’s missing for module support to be sufficiently far along?

I don’t see anything critical except for bug 1371551
Point is, even if we implement it, it will not work for most users until the pref is flipped on by default.

That said, bug 1428002 seems to be turning it on for Nightly only, which I guess means we could now land code behind the same pref.
You need to log in before you can comment on or make changes to this bug.