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

Support Module Source Worker Instantiation #4

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

guybedford
Copy link
Owner

@guybedford guybedford commented Nov 15, 2024

This is draft HTML PR spec text to verify the cross-specification interactions of the ESM Source Phase proposal, specifying:

  • Integrating JS module sources with HTML source phase imports
  • new Worker(moduleSource) for both JS and Wasm module sources, based on the new HostGetModuleSourceModuleRecord host hook and GetModuleSourceModuleRecord concrete method.
  • import(moduleSource) based on the updated HostLoadImportedModule API, with full registry key coalescing based on module source equivalence via the new ModuleSourcesEqual concrete method.
  • postMessage(moduleSource) based on supported structured serialize and deserialize for JS ModuleSource objects (while this remains defined for Wasm in https://www.w3.org/TR/wasm-web-api-2/, but yet to be updated to support the ESM Phase Imports proposal in turn.

This is based to the latest version of ESM Phase Imports (https://tc39.es/proposal-esm-phase-imports/).

The WebAssembly ESM Integration updates to these APIs are not currently included here but should be landed along with this in due course to:

  • Support a [[ModuleRecord]] slot on WebAssembly.Module objects to enable HostGetModuleRecordFromSource
  • Implement a HostGetModuleRecordFromSource that populates this object from the Wasm side when needed (ie when previously compiled modules get passed to source functions such as import() or new Worker()
  • Update Wasm serialization to support URL serialization through this module record object when present

Finally, the main HTML questions here are around the security properties of source cloning and worker construction. A half-backed rooted source property is implemented for module scripts to distinguish between "checked URL sources" and evalish sources, but this needs to still be turned into a proper model further. In addition shared workers and worklets are not currently supported but could be additions to this spec.

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.

1 participant