Skip to content
This repository was archived by the owner on Sep 2, 2023. It is now read-only.
This repository was archived by the owner on Sep 2, 2023. It is now read-only.

Add communications channels to loader outputs #525

@bmeck

Description

@bmeck

Right now loaders cannot directly share data from their implementation, the global preload code, or the modules that they generate. We need to add a communications channel such as a MessagePort between all of these locations (e.g. nodejs/node#31229 (comment) ).

Without these communications channels a few features are not feasible:

  1. safely saving primordials in loader code to be used in generated modules. e.g. Saving WebAssembly.instantiateStreaming() in the global preload in order to use it inside of a module source text.
  2. passing events requiring new load operations from application code to the loader. e.g. for hot reloading/mocking (e.g. testdouble )
  3. having modules directly share references between each-other. e.g. having a generated module share some under underlying state with another friendly module.

I think adding a parameter to the global preload arguments is simple enough, but I do not have a clear idea on how we want to setup a channel between modules and the others. One idea is to allow putting it on import.meta if the module loader declares it somehow. Overall, it seems we need to implement this feature regardless of other designs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions