Support multiple import maps
Categories
(Core :: JavaScript Engine, enhancement, P3)
Tracking
()
People
(Reporter: yoav, Assigned: allstars.chh)
References
(Blocks 3 open bugs)
Details
(Keywords: dev-doc-complete, parity-chrome, parity-safari)
User Story
platform-scheduled:2026-06-30
Attachments
(20 files, 1 obsolete file)
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Steps to reproduce:
Import maps currently have to load before any ES module and there can only be a single import map per document. That makes them fragile and potentially slow to use in real-life scenarios: Any module that loads before them breaks the entire app, and in apps with many modules the become a large blocking resource, as the entire map for all possible modules needs to load first.
There's a proposal [1] to enable multiple import maps per document, by merging them in a consistent and deterministic way.
Mozilla standard position - https://github.com/mozilla/standards-positions/issues/1058
[1] https://github.com/whatwg/html/pull/10528
Updated•1 year ago
|
Updated•1 year ago
|
Comment 1•1 year ago
|
||
Needinfo'ing Yoshi, as he's our expert for Import Maps
Yoshi: Not sure about your GitHub handle but you probably want to take a look at the proposal and give it some thought about implementation challenge.
| Reporter | ||
Updated•1 year ago
|
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Updated•1 year ago
|
Comment 2•1 year ago
|
||
The related MDN page already mentions multiple import maps, so there's probably no updated needed for that. Though this should be reflected in the related browser compat data.
Sebastian
Comment 3•1 year ago
|
||
Is 'Multiple import maps' supported by Firefox or not? If it is, then it is should updated in browser compat data.
Updated•11 months ago
|
Comment 4•10 months ago
|
||
Checking the code, Firefox is still sending an error message when we try to use multiple importmaps:
https://searchfox.org/mozilla-central/rev/a589ce1e3ff122d53690f101780a3b4747946d71/dom/script/ScriptLoader.cpp#1550
https://searchfox.org/mozilla-central/rev/a589ce1e3ff122d53690f101780a3b4747946d71/dom/locales/en-US/chrome/dom/dom.properties#371
Note that the code above also prevents to process import maps after a previous module import, which Yoav's PR changed too
A Document can have multiple import maps processed, which can happen either before or after any modules have been imported,
(note: I found this while writing tests for Trusted Types at https://phabricator.services.mozilla.com/D251456)
Comment 5•10 months ago
|
||
(In reply to [:anutrix] from comment #3)
Multiple import maps are not supported yet.
(In reply to Jon Coppeard (:jonco) (PTO until Friday 13th June) from comment #5)
(In reply to [:anutrix] from comment #3)
Multiple import maps are not supported yet.
Is there a PR out for multiple import maps on Firefox? Or otherwise any details on release date?
Comment 7•9 months ago
|
||
The compatibility gap with Firefox on this one is starting to grow - https://caniuse.com/mdn-html_elements_script_type_importmap_multiple_import_maps.
While we do have ES Module Shims polyfill to fill the gap, it would be a huge benefit to have these modern import maps workflows working natively.
Comment 8•9 months ago
|
||
(In reply to guybedford from comment #7)
The compatibility gap with Firefox on this one is starting to grow - https://caniuse.com/mdn-html_elements_script_type_importmap_multiple_import_maps.
While we do have ES Module Shims polyfill to fill the gap, it would be a huge benefit to have these modern import maps workflows working natively.
Can you elaborate on the huge benefit? It can help in getting the work prioritized.
Comment 9•9 months ago
|
||
Here's the article on the feature here being used by Shopify - https://shopify.engineering/resilient-import-maps.
Currently they use the polyfill to support older browsers - https://github.com/guybedford/es-module-shims, which is slower and less efficient than native.
Comment 10•9 months ago
|
||
Are there more details on the performance costs of the polyfill? (I've only skimmed the article so may have missed it)
Comment 11•9 months ago
|
||
The polyfill re-executes all modules using source text rewriting and blog URLs, effectively re-handling the entire module system. It's typically 1.5-2x slower than native modules to execute a module graph.
Comment 12•9 months ago
|
||
(In reply to Jeff Muizelaar [:jrmuizel] from comment #8)
(In reply to guybedford from comment #7)
The compatibility gap with Firefox on this one is starting to grow - https://caniuse.com/mdn-html_elements_script_type_importmap_multiple_import_maps.
While we do have ES Module Shims polyfill to fill the gap, it would be a huge benefit to have these modern import maps workflows working natively.
Can you elaborate on the huge benefit? It can help in getting the work prioritized.
I have a site that relies on import maps and won't work without them. The problem is that if users have extensions that inject import maps or modules before the site's, it'll break the page for some fraction of users and there's nothing we can do about it. Supporting multiple import maps is necessary for robustness vs. misbehaving extensions. Currently the site is working fine in browsers that support that, but Firefox is left behind.
Updated•9 months ago
|
| Comment hidden (advocacy) |
| Assignee | ||
Comment 15•5 months ago
|
||
| Assignee | ||
Comment 16•5 months ago
|
||
| Assignee | ||
Comment 17•5 months ago
|
||
Implement https://html.spec.whatwg.org/#resolved-module-set
and store it in ModuleLoaderBase
| Assignee | ||
Comment 18•5 months ago
|
||
This is to simplify ImportMap::ResolveModuleSpecifier, so we just need
to pass baseURL to it.
| Assignee | ||
Comment 19•5 months ago
|
||
This is just a minor update to the latest spec, the logic remains the same.
Before:
If found a match in scopesImportMatch, return result.
After:
If found a match in scopesImportMatch, break from the for-loop.
if result is not null, return result
| Assignee | ||
Comment 20•5 months ago
|
||
Added AddToResolvedModuleSet to complete the 'resolve a module specifier'.
| Assignee | ||
Comment 21•5 months ago
|
||
Add a request parameter to construct the ReportWarningHelper.
| Assignee | ||
Comment 22•5 months ago
|
||
| Assignee | ||
Comment 23•5 months ago
|
||
During preload, module resolution may be incomplete because import map
information is not yet available. To handle this, store the resolved
module set within the module script itself.
Later, when the preloaded request is reused during parsing, merge the
preloaded resolved module set into the global resolved module set to
ensure consistency.
| Assignee | ||
Comment 24•5 months ago
|
||
When registering an import map, we must remove any preloaded scripts
because their resolved URLs may no longer be valid under the new import
map.
If top-level module scripts have already been preloaded, we also clear
the [[LoadedModules]] slot in the ModuleObject, as well as the
[ParseError] and [ErrorToRethrow] fields in the module scripts. This
ensures that when these modules are fetched again, the entries in
mFetchedModules do not reuse stale preload data.
For entries in mFetchingModules, we verify whether each module’s
resolution remains consistent after merging the import map. If a
resolution no longer matches, the ongoing (preload) fetch request is
canceled.
We take no action on mFetchedModules entries because we cannot determine
whether their associated scripts were fetched before or after the import
map registration.
| Assignee | ||
Comment 25•5 months ago
|
||
Updating the tests with multiple import maps.
| Assignee | ||
Comment 26•5 months ago
|
||
| Assignee | ||
Comment 27•5 months ago
|
||
Even with a 0.5-second delay, preloading causes the module script to
arrive before the import map. Increase the delay to guarantee the import
map is available before module execution.
Comment 28•5 months ago
|
||
FYI, there are a couple of trusted type tests that had to place import map before a module load: https://searchfox.org/firefox-main/search?q=1916277&path=testing%2Fweb-platform%2Ftests&case=false®exp=false ; I don't know if that improved with your patches, but it would be nice to check if putting import map load after module load works and remove these comments from WPT.
Do we have a WPT test that actually checks whether import map load is possible after a module load? Probably we should add one in /import-maps
| Assignee | ||
Comment 29•5 months ago
|
||
Add multiple import maps into /trusted-types
| Assignee | ||
Comment 30•5 months ago
|
||
(In reply to Frédéric Wang (:fredw) from comment #28)
FYI, there are a couple of trusted type tests that had to place import map before a module load: https://searchfox.org/firefox-main/search?q=1916277&path=testing%2Fweb-platform%2Ftests&case=false®exp=false ; I don't know if that improved with your patches, but it would be nice to check if putting import map load after module load works and remove these comments from WPT.
Do we have a WPT test that actually checks whether import map load is possible after a module load? Probably we should add one in /import-maps
Thanks for the info.
Added/Updated WPT for /trusted-types.
Where there's a will, there's a way.
Updated•4 months ago
|
Updated•4 months ago
|
Updated•4 months ago
|
Updated•4 months ago
|
Updated•4 months ago
|
| Assignee | ||
Comment 31•4 months ago
|
||
When the preloaded request is reused during parsing, merge the preloaded
resolved module set into the global resolved module set to ensure consistency.
Updated•4 months ago
|
| Assignee | ||
Comment 32•4 months ago
|
||
Originally, RegisterImportMap was not invoked if any module requests
were in the fetching or fetched state. With this limitation removed,
the behavior is updated so that only the preloading requests are canceled.
Updated•4 months ago
|
Updated•4 months ago
|
Updated•4 months ago
|
Updated•4 months ago
|
| Assignee | ||
Comment 33•4 months ago
|
||
Updated•4 months ago
|
| Assignee | ||
Comment 34•3 months ago
|
||
Add a pref to enable support for multiple import maps.
| Assignee | ||
Comment 35•3 months ago
|
||
Calling DisallowImportMaps() conditionally if the pref is off.
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
| Assignee | ||
Comment 36•3 months ago
|
||
Reset modules information happened during preload.
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
| Assignee | ||
Comment 37•3 months ago
•
|
||
| try | ||
[Updated on 2026.Feb.23]
try: https://treeherder.mozilla.org/jobs?repo=try&revision=57a58217d982492b7b253212faad85922e9abc6a
(pref is on): https://treeherder.mozilla.org/jobs?repo=try&revision=2a7aa04de4707574ac721c94bfdd2d353e97530e
Updated•2 months ago
|
| Assignee | ||
Comment 38•2 months ago
|
||
Currently Gecko only set mIsPreload to true for the top-level preloading
load. To identify a non-top-level preload, update mIsPreload accordingly
to match the mIsPreload flag from the root module.
Updated•2 months ago
|
Updated•2 months ago
|
| Assignee | ||
Comment 39•2 months ago
|
||
This will allow us to identify the module is loaded during preloading
phase.
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
| Assignee | ||
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Comment 40•1 month ago
|
||
Comment 42•1 month ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/3a76af935b1d
https://hg.mozilla.org/mozilla-central/rev/56b312c1f37d
https://hg.mozilla.org/mozilla-central/rev/f9d983d1e3e2
https://hg.mozilla.org/mozilla-central/rev/fa2331e74853
https://hg.mozilla.org/mozilla-central/rev/15eeb297ee62
https://hg.mozilla.org/mozilla-central/rev/2c99c4ed2495
https://hg.mozilla.org/mozilla-central/rev/bc51a6464df2
https://hg.mozilla.org/mozilla-central/rev/bb6a7df845a8
https://hg.mozilla.org/mozilla-central/rev/0c2d420621fb
https://hg.mozilla.org/mozilla-central/rev/61bba4bc022d
https://hg.mozilla.org/mozilla-central/rev/89c6089e6a89
https://hg.mozilla.org/mozilla-central/rev/cb9f3ad567ab
https://hg.mozilla.org/mozilla-central/rev/a5d469a28b3a
https://hg.mozilla.org/mozilla-central/rev/3962bb975cde
https://hg.mozilla.org/mozilla-central/rev/f0f9edc6c0c2
https://hg.mozilla.org/mozilla-central/rev/c497a8561d89
https://hg.mozilla.org/mozilla-central/rev/38d64e1c3b2c
https://hg.mozilla.org/mozilla-central/rev/40e922e2c3b7
Comment 44•1 month ago
|
||
:allstars.chh is this something you want to mention in the Fx150 release notes? Feel free to nominate if so.
| Assignee | ||
Comment 46•1 month ago
•
|
||
Release Note Request (optional, but appreciated)
[Why is this notable]:
The current restriction to a single import map imposes several limitations. Enabling support for multiple import maps would lift these constraints and provide increased flexibility for web developers.
[Suggested wording]:
Multiple Import Maps
| Assignee | ||
Updated•1 month ago
|
Comment 48•1 month ago
|
||
Added to Fx150 release notes https://www.firefox.com/en-US/firefox/150.0a1/releasenotes/
| Assignee | ||
Comment 49•1 month ago
|
||
(In reply to Dianna Smith [:diannaS] from comment #48)
Added to Fx150 release notes https://www.firefox.com/en-US/firefox/150.0a1/releasenotes/
Hi, Dianna,
I'd like to remind you that the feature is behind the pref "dom.multiple_import_maps.enabled", which is still off by default.
The note doesn't mention that and I think it will cause some confusion.
Firefox now supports multiple import maps per document ...
| Assignee | ||
Updated•1 month ago
|
Comment 50•1 month ago
|
||
my apologies I didnt realize it was off by default. Is there a ticket tracking it being enabled? I can remove the relnote until that happens.
| Assignee | ||
Comment 51•1 month ago
|
||
(In reply to Dianna Smith [:diannaS] from comment #50)
my apologies I didnt realize it was off by default. Is there a ticket tracking it being enabled? I can remove the relnote until that happens.
bug 2021012, although I don't know if we should put some experienment feature (off by default) in relnote.
Comment 52•1 month ago
•
|
||
I can add something like "Starting with Firefox 150, multiple import maps per document is now supported, giving web developers more flexibility when structuring and loading modern JavaScript modules. This is considered experimental as we gather feedback before enabling it in regular releases." Please let me know how that sounds.
| Assignee | ||
Comment 53•1 month ago
|
||
(In reply to Dianna Smith [:diannaS] from comment #52)
I can add something like "Starting with Firefox 150, multiple import maps per document is now supported, giving web developers more flexibility when structuring and loading modern JavaScript modules. This is considered experimental as we gather feedback before enabling it in regular releases." Please let me know how that sounds.
That looks perfect, thanks.
(And I assume you will add it in https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/150#experimental_web_features, with mentioning the pref "dom.multiple_import_maps.enabled")
Comment 54•1 month ago
|
||
For the mdn changes, the dev-doc-needed keyword would move to
dev-doc-complete when someone from the mdn makes the change
Updated•1 month ago
|
Comment 55•11 days ago
|
||
FF150 MDN docs work for this can be tracked in https://github.com/mdn/content/issues/43551
Description
•