Closed Bug 1837044 Opened 11 months ago Closed 11 months ago

importmap is sporadically ignored if a non-module script appears before it

Categories

(Core :: JavaScript Engine, defect)

Firefox 114
defect

Tracking

()

RESOLVED DUPLICATE of bug 1803984

People

(Reporter: dan.abramov, Unassigned)

Details

Attachments

(1 file)

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:

  1. Add an old-school (not module) <script> to <head>. It needs to have considerable amount of code to trigger the bug. Try jQuery.

  2. Add an importmap somewhere after

  3. 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).

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.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Component: DOM: Core & HTML → JavaScript Engine

Yoshi, any ideas what's happening here?

Flags: needinfo?(allstars.chh)

The module script (stuff.js) is preloaded without the import-map, so it got failure when resolving the specifier 'react-dom/client'.

Status: UNCONFIRMED → RESOLVED
Closed: 11 months ago
Duplicate of bug: 1803984
Flags: needinfo?(allstars.chh)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: