Closed Bug 1873610 Opened 1 year ago Closed 11 months ago

Improve error message for import/export modules

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
126 Branch
Tracking Status
firefox126 --- fixed

People

(Reporter: allstars.chh, Assigned: allstars.chh)

References

(Blocks 1 open bug)

Details

Attachments

(3 files, 1 obsolete file)

Severity: -- → N/A
Priority: -- → P3
Assignee: nobody → allstars.chh

Refactor the error message with the adding the information from the imported
module, for example:

// a.mjs
import { a } from "./b.mjs";

// b.mjs
const b = 1;

Originally the error message is "import not found: default", now it
becomes "The request module: b.mjs doesn't provide an export named: a"

// c.mjs
import { c } from "./d.mjs";

// d.mjs
export * from "./d1.mjs";
export * from "./d2.mjs";

// d1.mjs
export const c = 1;

// d2.mjs
export const c = 2;

Originally the error message is "ambiguous import: c", now it becomes
"The requested module d.mjs contains ambiguous star export: c from
d1.mjs and d2.mjs"

Add another error message for circular import:

// e.mjs
export { e } from "f.mjs";

// f.mjs
export { e } from "e.mjs";

Originally it was "indirect export not found: e", now it is
"The request module: f.mjs contains circular import: e".

Depends on: 1880464
Attachment #9377713 - Attachment description: Bug 1873610 - Improve modules import/export error messages. → Bug 1873610 - Part 2: Improve modules import/export error messages.
Attachment #9388039 - Attachment description: Bug 1873610 - Part 1: Add ScriptOrFileNameSlot and filename method in ModuleObject. → Bug 1873610 - Part 1: Add FileNameSlot and filename method in ModuleObject.
Attachment #9388039 - Attachment description: Bug 1873610 - Part 1: Add FileNameSlot and filename method in ModuleObject. → Bug 1873610 - Part 1: Add FilenameSlot and filename method in ModuleObject.
Pushed by smolnar@mozilla.com: https://hg.mozilla.org/mozilla-central/rev/7e3d952f4a9a Part 1: Add ModuleObject::filename(). r=jonco https://hg.mozilla.org/mozilla-central/rev/f1c810bb6074 Part 2: Improve modules import/export error messages. r=jonco https://hg.mozilla.org/mozilla-central/rev/10d3a32a9211 Part 3: Pass ModuleErrorInfo to SyntheticModuleResolveExport. r=jonco
Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 126 Branch
Attachment #9388039 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: