Skip to content

Commit

Permalink
Add rationale for tentatively encapsulating ModuleInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Jun 10, 2022
1 parent 0c1798f commit 8ff9951
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,31 @@ await loader.load('./thenable.js');
const thenableNamespace = loader.importNow('./thenable.js');
```

# Encapsulate or reveal ModuleInstance

This proposal tenatively hides `%ModuleInstance%` and `%Global%`.
A coherent alternate to this design could reveal both of these and hide
`Loader`.
However, a language-defined loader is better positioned to maintain
the invariant that dynamic and static import in a module should
consistently bind the same module instance to the same module specifier from
within a particular referrer module.
A reified `ModuleInstance` constructor would need to accept an arbitrary
dynamic import hook.

One motivation for revealing `ModuleInstance` would be to avoid
litigating the complications of a `Loader` definition.
However, given that loader behavior is necessarily already specified
as part of the definition of a realm, there is no version of
this proposal that can omit `Loader` entirely.

It might, however, be possible to hide `%Loader%` and avoid specifying module
descriptors.
Although that is an attractive simplification, Module descriptors are necessary
for embedded systems, such that a static module record may pass from a host
loader to a guest loader by name,
representation, and useful even when not necessary.

[browserify]: https://browserify.org/
[import-map]: https://github.com/WICG/import-maps
[jest-ses-interaction]: https://github.com/facebook/jest/issues/11952
Expand Down

0 comments on commit 8ff9951

Please sign in to comment.