-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat(endo): Search for index.js and implied package exports #434
Conversation
This is the remainder of #401, which I accidentally failed to hoist and squash. |
0d8a703
to
50d6fee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems familiar. LGTM.
packages/endo/DESIGN.md
Outdated
|
||
// ExitName is the name of a built-in module, to be threaded in from the | ||
// modules passed to the module executor. | ||
type ExitName string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type ExitName string; | |
type ExitName = string; |
packages/endo/src/zip.js
Outdated
@@ -7,9 +7,9 @@ export const readZip = async (data, location) => { | |||
await zip.loadAsync(data); | |||
const read = async path => { | |||
const file = zip.file(path); | |||
if (file === undefined) { | |||
if (file === undefined || file === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be simpler?
if (file === undefined || file === null) { | |
if (!file) { |
@michaelfig Yeah, I messed something up in this stack so there is duplication here, somehow. |
When asked for a module named "x", Node.js will search for "x.js" then "x/index.js". For packages that do not supply an "exports" property in their "package.json", any module contained by that package is a valid exported module. To achieve parity with these two features, Endo uses different techniques when loading from the file system and loading from an archive. When reading from the file system, Endo will search for a satsifactory candidate in each compartment's asynchronous importHook. Endo also uses the compartment's new moduleMapHook to search for dependency compartments in the "scope" of a module identifier prefix. These allow Endo to operate from an incomplete compartment map for the initial load. The Endo archiver instead creates a more complete compartment map, with every discovered module. This introduces a new kind of module to the compartment map module descriptor type union: modules with known locations and corresponding parsers. The archiver erases the "scopes", "types", and "parsers" on each compartment description since they are no longer necessary. When reading from an archive, Endo uses an importHook that consults the compartment map directly for the locations of all contained modules, and creates a complete moduleMap up front.
50d6fee
to
e4d5082
Compare
When asked for a module named "x", Node.js will search for "x.js" then "x/index.js".
For packages that do not supply an "exports" property in their "package.json", any module contained by that package is a valid exported module.
To achieve parity with these two features, Endo uses different techniques when loading from the file system and loading from an archive.
When reading from the file system, Endo will search for a satsifactory candidate in each compartment's asynchronous importHook. Endo also uses the compartment's new moduleMapHook to search for dependency compartments in the "scope" of a module identifier prefix. These allow Endo to operate from an incomplete compartment map for the initial load.
The Endo archiver instead creates a more complete compartment map, with every discovered module. This introduces a new kind of module to the compartment map module descriptor type union: modules with known locations and corresponding parsers. The archiver erases the "scopes", "types", and "parsers" on each compartment description since they are no longer necessary.
When reading from an archive, Endo uses an importHook that consults the compartment map directly for the locations of all contained modules, and creates a complete moduleMap up front.