Closed Bug 1899344 Opened 4 months ago Closed 2 months ago

Module registry in shell module loader needs to be keyed by both module type and path

Categories

(Core :: JavaScript Engine, defect, P2)

defect

Tracking

()

RESOLVED FIXED
130 Branch
Tracking Status
firefox130 --- fixed

People

(Reporter: jon4t4n, Assigned: jon4t4n)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

If we run the code in the example below (in the JS shell), we see the JSON module printed twice. The second import should be a syntax error. The module map needs to be keyed by both the module type and path in the shell as well.

Fixing the module map showed that dynamic imports have been broken from the start but passed all tests because of this bug. We don't properly pass the attributes down into OnResolvedDynamicModule, and instead create the ModuleRequestObject without any attributes.

Example:

import a from 'test.json' with { type: 'json' }
print(valueToSource(a)); // ({a:123})

import b from 'test.json'
print(valueToSource(b)); // ({a:123})
Blocks: 1670176
Severity: -- → S3
Priority: -- → P2
Assignee: nobody → jonatan.r.klemets
Attachment #9404651 - Attachment description: WIP: Bug 1899344 - Part 1: Create module requests with attributes in OnResolvedDynamicModule r=#spidermonkey-reviewers → Bug 1899344 - Part 1: Create module requests with attributes in OnResolvedDynamicModule r=#spidermonkey-reviewers
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #9404653 - Attachment description: WIP: Bug 1899344 - Part 2: Change shell module registry to be keyed by module type and path r=#spidermonkey-reviewers → Bug 1899344 - Part 2: Change shell module registry to be keyed by module type and path r=#spidermonkey-reviewers

The attributes are currently not exposed to JS, and embedders have no way of
altering what attributes we support. We might want to go back to storing the
attributes on the module request object again when we figure out how the host
hook will work [1]. However, until then, let's only store the module type to
make the code simpler.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1840723

Attachment #9404651 - Attachment description: Bug 1899344 - Part 1: Create module requests with attributes in OnResolvedDynamicModule r=#spidermonkey-reviewers → Bug 1899344 - Part 1: Create module requests with attributes in OnResolvedDynamicModule r=jonco
Attachment #9404653 - Attachment description: Bug 1899344 - Part 2: Change shell module registry to be keyed by module type and path r=#spidermonkey-reviewers → Bug 1899344 - Part 2: Change shell module registry to be keyed by module type and path r=jonco
Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e717ebb2097e Part 0: Parse import attributes earlier and only store the module type. r=jonco,arai https://hg.mozilla.org/integration/autoland/rev/7c094d6f66b5 Part 1: Create module requests with attributes in OnResolvedDynamicModule r=jonco https://hg.mozilla.org/integration/autoland/rev/f9f78310ac05 Part 2: Change shell module registry to be keyed by module type and path r=jonco
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 130 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: