Closed Bug 1808360 Opened 1 year ago Closed 1 year ago

Add error message for importmap with src attribute

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
110 Branch
Tracking Status
firefox110 --- fixed

People

(Reporter: nchevobbe, Assigned: allstars.chh)

References

Details

Attachments

(1 file)

Steps to reproduce

  1. Open a tab on https://ffx-external-import-map.glitch.me/
  2. Open the console

Result

As I was testing out importmap, I tried declaring as we do for external script:

    <script type="importmap" src="map.json"></script>

In such case, I do get an error on the console as the importmap isn't loaded, and thus the import fails

Uncaught TypeError: The specifier “square” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”. module.js:1:27

But I don't get any error about the importmap being invalid (unlike in Bug 1808357).
It would be nice to have an error (or warning) message to indicate that the importmap can't be specified in an external file and should be inlined

Per spec, the onerror handler of the script tag will be called if it's external script with type is "importmap".

See
https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element
Step 30.1

(In reply to Yoshi Cheng-Hao Huang [:allstars.chh][:allstarschh][:yoshi] from comment #1)

Per spec, the onerror handler of the script tag will be called if it's external script with type is "importmap".

See
https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element
Step 30.1

That's good to know but do require people to know about the onerror handler too. Having a warning message would be a nice way to reduce frustration for users so they don't have to search around what's going on

I will try to dump some error message in console.

Assignee: nobody → allstars.chh
Status: NEW → ASSIGNED
Blocks: importmaps
Severity: -- → S3
Priority: -- → P3
Summary: Add error message for empty inline importmap with src attribute → Add error message for importmap with src attribute
Pushed by allstars.chh@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/302bffceb24a
Add error message for external import maps. r=jonco,flod
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 110 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: