Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: esm source design #3

Merged
merged 5 commits into from
Mar 27, 2024
Merged

Conversation

guybedford
Copy link
Collaborator

This outlines an initial design sketch for the ESM source phase design, covering:

  • module.exports() and module.imports() APIs
  • Internal slot for resolution
  • Dynamic import() integration rules
  • Integration with other specifications such as CSP and structured clone

In an initial version I explicitly defined the CSP property for a [[HostSrc]] internal slot that might be directly checked in the CSP policy rules for example in the Wasm ESM integration.

But on further consideration, CSP as a compilation check, means that by having a source phase import that the compilation guard has already passed - thus if you have a handle to a concrete AbstractModuleSource, then it's already passed through CSP. Similarly for JS, dynamic import of a module guards the module at fetch time, not execution time.

Therefore, it is only the new Worker(module) invocation that needs to be supported here from a CSP perspective as a new construct for permitting CSP sources that have already been vetted statically.

Then I think for that case that we can rather define that the src can be reconstructed from [[HostDefined]] in order to perform the verification here. If there are difficulties figuring that out, then I think that is a CSP integration problem we should handle when we get there, but that we don't necessarily need right now to introduce new machinery to handle it without trying the simpler approach first.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@guybedford guybedford changed the title draft: esm source design update: esm source design Mar 21, 2024
@guybedford guybedford marked this pull request as ready for review March 21, 2024 17:49
@guybedford
Copy link
Collaborator Author

@nicolo-ribaudo I have added the changes we discussed in todays meting, including the new identity handling.

README.md Outdated Show resolved Hide resolved
@lucacasonato
Copy link
Member

This document leaves open what happens when you import(esmSource).

@guybedford
Copy link
Collaborator Author

README.md Outdated Show resolved Hide resolved
@guybedford guybedford merged commit 5d4639f into tc39:main Mar 27, 2024
2 checks passed
@guybedford guybedford deleted the source-design branch March 27, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants