-
Notifications
You must be signed in to change notification settings - Fork 74
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(module-source): Add XS specific variant #2470
Conversation
2524d16
to
0e134ba
Compare
8ddbfc3
to
70beef1
Compare
70beef1
to
5342ea3
Compare
6375752
to
a4b58b6
Compare
555ea34
to
317c723
Compare
Notes from walk thru with @erights: Add assertion to detect the XS bug for |
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.
LGTM!
packages/module-source/NEWS.md
Outdated
- Provides an XS-specific variant of `@endo/module-source` that adapts the | ||
native `ModuleSource` instead of entraining Babel. |
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.
Why is this under the # v1.1.0
heading rather than a new # Next release
heading?
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.
Legitimate error. Thanks.
/* global globalThis */ | ||
/* eslint-disable @endo/no-nullish-coalescing */ | ||
|
||
/** @typedef {{ import: string, as?: string, from: string } & { importAllFrom: string, as: string, from: string } & { export: string, as?: string, from?: string } & { exportAllFrom: string, as?: string } & {importFrom: string }} Binding */ |
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.
Illegible. Please try something like
/** @typedef {{ import: string, as?: string, from: string } & { importAllFrom: string, as: string, from: string } & { export: string, as?: string, from?: string } & { exportAllFrom: string, as?: string } & {importFrom: string }} Binding */ | |
/** | |
* @typedef {{ import: string, as?: string, from: string } & | |
* { importAllFrom: string, as: string, from: string } & | |
* { export: string, as?: string, from?: string } & | |
* { exportAllFrom: string, as?: string } & | |
* { importFrom: string } | |
* } Binding | |
*/ |
. But one that actually works. (I have no idea why the one above does not work.)
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.
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.
It likely needs to be a type union, not a type intersection.
Object.defineProperties( | ||
ModuleSource.prototype, | ||
Object.getOwnPropertyDescriptors({ | ||
get imports() { |
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.
I like this approach for adding accessors to an existing object. No change suggested.
3fe062f
to
724fec7
Compare
fa10b9b
to
9e16181
Compare
9e16181
to
53e5109
Compare
Closes: #2250
Refs: #2251
Description
Toward using native XS compartments and module sources, this change adds an XS-specific variant of
@endo/module-source
that patches the nativeModuleSource
in place instead of entraining Babel. This will allow an XS-specific@endo/import-bundle
variant to load both pre-compiled sources (pre-json-mjs
) and original ESM sources (mjs
).This change is opt-in, provided the
xs
runtime condition. These are conditions introduced by Node.js with thenode -C development entry.js
precedent and supported by@endo/compartment-mapper
for bothendoScript
andendoZipBase64
bundle formats.Security Considerations
This change increases exposure to a native ModuleSource as implemented in a memory-unsafe language.
Scaling Considerations
We expect a significant improvement in performance at both bundle time and run time upon completion of #2251 since native ModuleSource is considerably faster than a virtualization.
Documentation Considerations
Captured in NEWS.md and README.md.
Testing Considerations
This change introduces a minimal
text:xs
that runs withxst
and is exercised by Continuous Integration. This minimal test can be expanded as we make more progress with the XS-variant of SES, which will allow the virtual Compartment to opt-in to use native ModuleSource.Compatibility Considerations
The XS-specific shim is not a one-to-one replacement for the Babel implementation and does not support some of the optional arguments. Code that expects these hooks to be called will be dismayed. Despite these limitations, no existing program should break: the
xs
condition should not be present in any existing application.Upgrade Considerations
This change will not come to bear on the Agoric chain until after a new version of XS becomes available with a new XS-specific lockdown preamble.