Improve error message for ambiguous indirect export
Categories
(Core :: JavaScript Engine, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox123 | --- | fixed |
People
(Reporter: sebo, Assigned: allstars.chh)
References
(Blocks 1 open bug)
Details
Attachments
(3 files)
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
Reporter | ||
Comment 1•1 year ago
|
||
Updated•1 year ago
|
Assignee | ||
Updated•1 year ago
|
Assignee | ||
Comment 2•1 year ago
|
||
Fix the wrong order of error number in ErrorNumbers.
Comment 4•1 year ago
|
||
bugherder |
Reporter | ||
Comment 5•1 year ago
|
||
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
Updated•1 year ago
|
Assignee | ||
Comment 6•1 year ago
|
||
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.
Assignee | ||
Updated•1 year ago
|
Description
•