Closed Bug 1580536 Opened 5 months ago Closed 4 months ago

Dynamic module import generates an error at parse time in contexts where it is not supported


(Core :: JavaScript Engine, task, P2)




Tracking Status
firefox71 --- fixed


(Reporter: jonco, Assigned: jonco)



(1 file)

Currently use of dynamic import causes a syntax error at parse time in web workers. Bug 1540913 comment 6 suggests that it would be more useful for this to fail at runtime as it would make it easier to provide a fallback for web worker scripts when run in FF.

Priority: -- → P2

This removes the parse-time check for whether dynamic import hook has been set. There's already a runtime check for this too, previously just to support enabling/disabling dynamic import via a pref. I updated web platform tests and expectations so that use of dynamic imports in wokers is now an expected failure (previously we would time out).

It would be very much appreciated to get the fix to replace the parse time with a run time check into FF.

I am creating a new web worker driven UI framework and this error is a big show stopper.
I had to replace several JS modules with copies (if possible), just to exclude unreachable code from FF.

In general: adding support for JS modules & dynamic imports inside the worker scope should get a high priority,
since this is a direction UI app development is moving towards to.

Thx & best regards

Pushed by
Make dynamic import a runtime error in contexts where we don't support it r=jorendorff
Created web-platform-tests PR for changes under testing/web-platform/tests
Upstream web-platform-tests status checks passed, PR will merge once commit reaches central.
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71
Upstream PR merged by moz-wptsync-bot
Assignee: nobody → jcoppeard
Pushed by
Add back test annotations lost during merge conflict. a=permafail-fix,test-only
You need to log in before you can comment on or make changes to this bug.