Closed Bug 1872671 Opened 1 year ago Closed 1 year ago

Improve error message for ambiguous indirect export

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
123 Branch
Tracking Status
firefox123 --- fixed

People

(Reporter: sebo, Assigned: allstars.chh)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

Attached file Simple test case

When trying to import the default export of a module that doesn't provide one, the error message currently says this:

Uncaught SyntaxError: ambiguous indirect export: default

The meaning of this message is unclear and it doesn't provide proper information on how to fix the error.

Chrome's error message is a little more explicit here:

Uncaught SyntaxError: The requested module './module.js' does not provide an export named 'default'

Sebastian

Attached file test.js
Severity: -- → N/A
Priority: -- → P3
Assignee: nobody → allstars.chh

Fix the wrong order of error number in ErrorNumbers.

Pushed by allstars.chh@gmail.com: https://hg.mozilla.org/integration/autoland/rev/e85cad69c36f Fix error message when import failed. r=jonco
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 123 Branch

While the change seems to fix a bug regarding which error message is displayed, the error messages themselves still lack important information how to fix the issues.

Given the attached example, I now get this error message:

Uncaught SyntaxError: import not found: default

They should provide authors with a hint what they need to change in order to fix the error.

The error message should rather provide the info about the module not providing a default export. Given the example, I'd expect something like

Uncaught SyntaxError: The requested module 'https://cdnjs.cloudflare.com/ajax/libs/ajv/8.12.0/ajv7.min.js' does not provide a default export.

And when trying to import a non-existing export, you could have the same message as Chrome provides it, i.e.

The requested module 'https://cdnjs.cloudflare.com/ajax/libs/ajv/8.12.0/ajv7.min.js' does not provide an export named 'foo'.

And for the ambiguous test case in the patch, the message still says

Uncaught SyntaxError: ambiguous indirect export: a

While that message should rather read like

Uncaught SyntaxError: The requested module './export_ambiguous.mjs' contains ambiguous star exports for name 'a' of imported modules './exportA1.mjs' and './exportA2.mjs'.

That would make it much easier to debug those exports and imports.

Sebastian

Status: RESOLVED → REOPENED
Resolution: FIXED → ---

Hi, Sebastian
This bug we do have fixed the error message, it was showing the wrong error message which caused the confusion.
To address your comment 5, I have filed a new bug for this, bug 1873610.

Status: REOPENED → RESOLVED
Closed: 1 year ago1 year ago
Resolution: --- → FIXED
Depends on: 1880464
No longer depends on: 1880464
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: