Normative: Define Module Source object identity instead of source text registry identity#58
Open
guybedford wants to merge 4 commits intomainfrom
Open
Normative: Define Module Source object identity instead of source text registry identity#58guybedford wants to merge 4 commits intomainfrom
guybedford wants to merge 4 commits intomainfrom
Conversation
ae5e047 to
6cacca6
Compare
9db9e28 to
04af421
Compare
00475a3 to
88811d7
Compare
85f5b89 to
c9974d0
Compare
88811d7 to
0a344f5
Compare
c9974d0 to
cb1a594
Compare
guybedford
added a commit
to guybedford/test262
that referenced
this pull request
Mar 5, 2026
Based to unlanded normative PR tc39/proposal-esm-phase-imports#58
guybedford
added a commit
to guybedford/test262
that referenced
this pull request
Mar 5, 2026
Based to unlanded normative PR tc39/proposal-esm-phase-imports#58
guybedford
added a commit
to guybedford/test262
that referenced
this pull request
Mar 5, 2026
Based to unlanded normative PR tc39/proposal-esm-phase-imports#58
nicolo-ribaudo
approved these changes
Mar 10, 2026
Member
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
I think this reasonable, and probably easier to implement.
cb1a594 to
5737c81
Compare
Co-authored-by: Nicolò Ribaudo <hello@nicr.dev>
5737c81 to
356538b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current specification specifies that
import(source1)andimport(source2)must return the same instance whenever the URL key matches and ALSO the[[SourceText]]matches between these sources.This design was justified based on:
(2) is not actually such an important aspect of the design - in many cases with separate module source identities (such as sources created via transfer and structured clone), the better design is to support separate instancing and not to unify the instance. In addition it's kind of strange that two module declarations with exactly the same source text will always return the same instance namespace despite being different module declarations.
Given that (1) is not longer a design goal at this point, it is worth reconsidering if we still need this invariant or can instead simplify to this new model.
Previously for eval modules and the module declarations case we discussed ways of associating evaluation indexes for disambiguation between module sources created via eval paths, which would need to be used in coordination with the existing invariants. This complexity is hard to build test coverage on and therefore becomes an implementation risk as well.
By unifying on a simpler source object instancing model here (effectively treating the JS object identity of the source phase as the source key instead of the source text) that does not perform source text equality I think this provides a more intuitive and streamlined design that is less prone to implementation bugs.
In addition we fully define the source keying property that
import(source)followed byimport(id)whereidis the string ID pointing to the same underlying module source asimport(source)must return the same module instance. This is a key property, which requires the host invariant refactoring work in #59 to be able to define this based on the concept of a Canonical ModuleRequest Record.// cc @nicolo-ribaudo