Normative: **Non-injective** ModuleSource identity#62
Open
guybedford wants to merge 2 commits into
Open
Conversation
6a9233e to
0a162de
Compare
0a162de to
c8436c4
Compare
nicolo-ribaudo
approved these changes
May 5, 2026
Member
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
These changes look good to me, as discussed in the modules harmony meeting I am ok with this different resolution to the trade off between raciness and cycles handling.
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.
#58 formalizes the module source identity requirement as presented at the last meeting, based on the host invariant formalization in #59.
This is a follow-on PR that removes the injective behaviour of module sources.
This was an early design decision for module source transfer, that if we had a module source for a module at
/foo.js, passing that module source into a worker, and importing its source object, would allow it to be imported by URL afterwards to get the same instance:The way this works is that importing the source object performs an injection into the module registry of the worker, provided no URL was previously defined at that key.
The reason this was designed from the start was to ensure cycles, for example if
/foo.jsimports/bar.jsand/bar.jsthen imports back to/foo.js. If the URL was not present in the registry (only the source object), then we would get two instances for foo - one for the foo source, and one for the/foo.jsURL fetched from the worker separately to the one transferred and serialized.In recent conversations and at the last module harmony meeting it was brought up that we should make sure we have talked through this constraint one last time.
The injective behaviour is racy - if the URL already existed, it would not be injected, and you would have separate instances for
import(fooSource)andimport('/foo.js')in the worker context.This PR shows that the spec change also leads to a simplification on the host normative constraint as it doesn't then need to specify the injective ordered behaviours.
We have not yet come to a conclusion over which behaviour would be preferable, so I wanted to post this for further discussion.