tc39 / proposal-dynamic-code-brand-checks

TC39 proposal that enables flexible brand checks before dynamic code loading
MIT License
31 stars 5 forks source link

Intersection semantics with `ModuleSource` #8

Open caridy opened 2 years ago

caridy commented 2 years ago

As part of the modules harmony effort, we are planning to introduce a new constructor, ModuleSource, than when instantiated, parses the code, and store a Module Source Record, which can be use a later time to construct a qualifying Module Record that can participate on the module graph. This poses some challenges with respect to this proposed brand check.

Instances of SourceModule are powerless, they can only be used for a) inspecting certain aspect of the source (e.g., its exported names, etc.) and b) used to create a Module instance.

The real question is whether the host check is intended to prevent parsing, or just evaluation? At the moment, both options are analogous because they both happen one after the other. But once we have a separation between parsing and evaluation, for the Modules, this question has to be answered. IMO, parsing does not have to be prohibit, but evaluation.

How can we accommodate such feature with this proposal?

cc @kriskowal @Jack-Works @nicolo-ribaudo