importmap is sporadically ignored if a non-module script appears before it
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
People
(Reporter: dan.abramov, Unassigned)
Details
Attachments
(1 file)
653 bytes,
application/zip
|
Details |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
Steps to reproduce:
-
Add an old-school (not module)
<script>
to<head>
. It needs to have considerable amount of code to trigger the bug. Try jQuery. -
Add an
importmap
somewhere after -
Add a
<script type=module>
tag somewhere after which uses the mapped imports
Actual results:
Firefox ignores the importmap so the module errors with:
The specifier “some-module” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.
However, it seems to successfully run if the non-module tag was fast enough to load first. This feels like a race condition.
Expected results:
Other browsers seem to handle this just fine.
If I understand the spec correctly, importmap is only supposed to appear before modules. So it's weird that putting a normal script before it breaks it.
Even if I'm wrong here, FF should have a deterministic behavior (not the case here) and print an error in all cases (if I'm doing something wrong).
Comment 1•11 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•11 months ago
|
Comment 3•11 months ago
|
||
The module script (stuff.js) is preloaded without the import-map, so it got failure when resolving the specifier 'react-dom/client'.
Description
•