You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
0 commit comments