User-visible changes to the compartment mapper:
- Fixes treatment of packages with a
"module"
property in theirpackage.json
: When the compartment mapper encounters such a package, every module in that package with.js
extension including the referenced module will be treated an ESM, as if it had the.mjs
extension. - Ensures that the
"endo"
,"import"
, and"default"
tags (Node.js conditions) are respected inpackage.json
"exports"
conditions.
- BREAKING: Archive integrity checks now occur when the archive is loaded instead of waiting for the archive to be instantiated or executed. This will cause corrupt archives to produce errors earlier.
- Adds a
makeAndHashArchive
function that returns both the generated bytes and the SHA-512 of an archive as its created.makeArchive
just returns the bytes.
- BREAKING: The
loadArchive
andparseArchive
functions, when given acomputeSha512
, now check the integrity of every module in the archive, and forbid the presence of any unused files in the archive. So, these functions now require amodules
option if the archive will expect any built-in modules. Themodules
option is an object with a key for every built-in module the archive expects. The load and parse functions ignore corresponding values (even if they are falsey!) but will accept the same type of object as the import function. - The
parseArchive
function returns a promise for an archive. If provided acomputeSha512
, regardless of whether providedexpectedSha512
, the archive will have asha512
property computed from the parsed archive, for the purpose of verifying integrity.
- The
node-powers.js
module now exportsmakeReadPowers
andmakeWritePowers
which replace the deprecated functionsmakeNodeReadPowers
andmakeNodeWritePowers
. The rename is necessary to facilitate a change to the signature of these methods so thaturl
may be accepted as another dependency, to facilitate Windows support. Both accept a bag of Node.js modules that must includefs
andurl
. The read powers may optionally take thecrypto
module.
- Adds source URL suffixes to archives, such that the archive hash remains orthogonal to the local directory but has sufficient information that editors like VS Code can match the suffix to a file in the IDE workspace.
- Adds hooks to archive production and consumption for reading and writing
source locations, such that other tools yet to be written can use these hooks
to provide fully qualified local debug source URLs.
Archive creation functions now accept a
captureSourceLocation(compartmentName, moduleSpecifier, sourceLocation)
hook and archive parsing functions acceptcomputeSourceLocation(compartmentName, moduleSpecifier)
.
- Adds support for reflexive import specifiers, so modules in package named
@example/example
may import@example/example
from their own modules. This is necessary for parity with Node.js.
- The calling convention between SES and StaticModuleRecords has changed and this impacts the code generated by the bundler.
- Adds a support for consistent hashing (SHA-512) of applications:
nodeReadPowers(fs, crypto)
produces the necessary capabilities for hashing, when passed the Node.jscrypto
module.writeArchive
andmakeArchive
accept acomputeSha512
capability and use it to populate thecompartment-map.json
included within the archive with the SHA-512 of every module in the archive. This ensures that the hash ofcompartment-map.json
in a pair of archives is consistent only if every file is consistent.importArchive
,loadArchive
, andparseArchive
all optionally accept acomputeSha512
capability, use it to verify the integrity of the archive and verify theexpectedSha512
of the containedcompartment-map.json
importArchive
andloadArchive
receive the hash function as a read power.parseArchive
receives the hash function as an option since it doesn't receive read powers.hashLocation
produces the hash of an application off the filesystem, suitable for validating that an archive with the same hash was generated from identical files.
- Also adds
mapLocation
, which produces the compartment map that would be in the corresponding archive for a package. - Ensures that IO errors on Node.js include a meaningful stack trace.
- Fixes internal type references.
- BREAKING: When constructing an archive, the creator must provide a record of exit modules. Unlike import functions, the values of the exit module record are ignored. Any omitted exit module will cause an exception during archive creation.
- Adds a
dev
option to archive and import workflows to include thedevDependencies
of the entry package (but not other packages). - Fixes a missing file in the published assets for
@endo/compartment-mapper/node-powers.js
.
- Follows Node.js packages through symbolic links, but requires an additional
read power to do this. Some functions now accept
{ read, canonical }
powers in places onlyread
was accepted previously, specificallycompartmentMapFromNodeModules
,makeArchive
,writeArchive
, andloadLocation
. - Adds an
"@endo/compartment-mapper/node-powers.js"
entry point utility module that exportsmakeNodeReadPowers
andmakeNodeWritePowers
that adapt the Node.jsfs
module to the promise and URL oriented interfaces expected by compartment mapper functions.
- Reenables CommonJS support with a fast lexer and without a dependency on Babel.
- The Compartment Mapper now produces archives containing SES-shim pre-compiled StaticModuleRecords for ESM instead of the source.
- The Compartment Mapper can now produce bundles of concatenated modules but without Compartments and only supporting ESM but not supporting live bindings.
- Adds entrypoint modules
import.js
,archive.js
, andimport-archive.js
to capture narrower dependency subgraphs. - BREAKING: Removes CommonJS and UMD downgrade compatibility.
Supporting both Node.js ESM and the
node -r esm
shim requires the main entry point module to be ESM regardless of environment. UMD and CommonJS facets will likely return after all dependees have migrated away from depending upon theesm
JavaScript module emulator. - BREAKING: Archives created for the previous version will no longer work.
The
importArchive
feature only supports pre-compiled ESM and CJS. - BREAKING: This release parallels a breaking upgrade for SES to version
0.13. This entails the removal of
StaticModuleRecord
from SES, and the removal of theses/lockdown
light layering (there is no heavy layer to distinguish as the weight has shifted to the@endo/static-module-record
package). - Archives are now deterministic.
- Applications may now have asynchronous module transforms, per language. When applied to archive creation, the transformed sources appear in the archive.
- Every compartment's
globalThis
is frozen.
- Embellishes all calls to methods named
import
to work around SES-shimCompartment
censoring for dynamic import, using properties instead of parentheses, since the syntax transformation tools at hand do not currently simplify these.
- Embellishes all calls to methods named
import
to work around SES-shimCompartment
censoring for dynamic import.
- Changes all private fields to internal weak maps to Compartment Mapper can be read by parsers that do not yet support private fields.
- BREAKING: All
import
methods now take an options bag that may containglobals
andmodules
options if present, instead of these as positional arguments. - BREAKING: Support for CommonJS is temporarily withdrawn to relieve a
dependency on Node.js built-ins entrained by Babel that in turn make
Compartment Mapper unusable with a combination of
-r esm
and Rollup. CommonJS support should be restored with an alternate implementation in a future version. - The
import
options bag now also acceptsglobalLexicals
,transforms
, and__shimTransforms__
, passing these without alteration to eachCompartment
. - The
import
options bag now also accepts aCompartment
constructor, to use instead of the one assumed to be present globally.
- This initial relase supports importing, archiving, and importing archives with the same authorities delegated to every compartment in an application. Future releases will support the attenuation of authority per-compartment, broaden support for Node.js module conventions, address the issue of shimming, and orchestrate SES lockdown.