-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(compartment-mapper): Make script or functor bundles (#2707)
Refs: #2444 ## Description Toward better preserving the format of original source through the `ModuleSource` and censorship evasion transforms, we upgraded Babel and use a new code generator. The new code generator does not compose with Rollup. However, in the intervening years, we have reïmplemented every part of Rollup we find desirable and better in keeping with our integrity requirements. So, we are poised to reïmplement the `nestedEvaluate` and `getExport` formats using our own implementation. To that end, this change closes the feature parity gap needed to undertake that refactor. We refactor `makeBundle` into `makeScript` and `makeFuctor`. We effectively rename `makeBundle` to `makeScript` for clarity. The `script` form surfaces as the `endoScript` bundler format and we expect `functor` to surface in an `endoFunctor` format, in addition to replacing the implementation of `nestedEvaluate` and `getExport`. Both of these functions are extended to accept compile time `useEvaluate`, `sourceUrlPrefix`, and `format`, to exit to CommonJS `require`. We leave open the possibility of an `esm` or `mjs` format that would exit to `import` for host modules. The new `makeFunctor` is analogous but isn’t suitable for `<script>` tags and instead allows the user to supply runtime options, including `require` for CommonJS format, `evaluate` if compiled with `useEvaluate` to override indirect `eval`, and `sourceUrlPrefix` which also in combination with `useEvaluate` overrides the compile time option by the same name. Captures `sourceDirname` for each packaged compartment for improved `sourceURL` generation. So, if the directory name does not match the package name, the source URL will be more likely to united with the original sources if they are open in the developer’s IDE. Moves bundle `use strict` pragma into evaluated function expression bodies for better composition with `eval`. Improve error message for misconfigured `require` option. ### Security Considerations No impact. ### Scaling Considerations No impact. ### Documentation Considerations The new bundling features necessitate new API reference documentation, both those generated from TypeScript, and our hand-crafted README. ### Testing Considerations This change includes coverage for all essential combinations of the new bundler options, including compile time and runtime options and cases where the latter overrides the former. ### Compatibility Considerations Documentation included for was that the new features do not have parity with Rollup. This change is purely additive, but the upcoming changes to `@endo/bundle-source` will require a major version bump for not being comfortably equivalent to former behavior. We have confirmed that the new behavior produces a passing CI run in composition with usage patterns in Agoric SDK, with a couple preparatory changes to make the transition. ### Upgrade Considerations These changes will impact the formation of the Agoric SwingSet XSnap Supervisor Lockdown (bootstrap) script. They should not produce observable differences in behavior.
- Loading branch information
Showing
31 changed files
with
1,804 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
// eslint-disable-next-line import/export -- just types | ||
export * from './src/types-external.js'; | ||
|
||
export { makeBundle, writeBundle } from './src/bundle.js'; | ||
export { | ||
makeScript as makeBundle, | ||
writeScript as writeBundle, | ||
} from './src/bundle.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// eslint-disable-next-line import/export -- just types | ||
export * from './src/types-external.js'; | ||
|
||
export { makeFunctorFromMap } from './src/bundle-lite.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// eslint-disable-next-line import/export -- just types | ||
export * from './src/types-external.js'; | ||
|
||
export { makeFunctor } from './src/bundle.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// eslint-disable-next-line import/export -- just types | ||
export * from './src/types-external.js'; | ||
|
||
export { makeScriptFromMap } from './src/bundle-lite.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// eslint-disable-next-line import/export -- just types | ||
export * from './src/types-external.js'; | ||
|
||
export { makeScript } from './src/bundle.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.