importmaps silently fail if they are after a script that is not of type=module
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
People
(Reporter: sad, Unassigned)
References
Details
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
Steps to reproduce:
In an HTML document, add three script element:
- one script element with no type attribute with an src attribute pointing to a script
- one script element of type importmap that maps an import
- one script element of type module that makes use of that mapped import
Note that the first script should have some content, if the script is empty or very short, the error will not occur for reasons that are unclear to me. The script need not run code, declaring a function with a body that declares a variable and increments that variable repeatedly a few tens of thousands of time seems to do the trick, the function need not be called. If the first script is inline, the error does not occur.
I have created a small git repo that reproduces the error: https://github.com/sdegueldre/firefox-import-map-error
Actual results:
Firefox fails to import the module according to the import map and logs the following error:
Uncaught TypeError: The specifier “some-module” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.
Expected results:
The import map should have been taken into account and no error should have been emited.
Comment 1•2 years 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.
Hi, thanks for reporting this.
The problem is from https://github.com/sdegueldre/firefox-import-map-error/blob/main/index.html#L12
<script type="module" src="test.js"></script>
Firefox will try to preload test.js (speculative loading), but the preloading won't involve import maps, so when the preloading of test.js is done, it cannot use the specifiers from the import-map, hence causes the error.
This is filed before in bug 1803984. I'll duplicate this bug with it.
Description
•