-
#3111
154102bThanks @boneskull! - Fix type ofPackageDataHook.packageDatawhich now correctly allows$root$as a key. -
#3127
6ada52bThanks @turadg! - Remove stale runtime dependencies from package manifests. -
#3115
1cd1246Thanks @boneskull! - Remove unused "error"ModuleSourceHookModuleSourcetype. -
Updated dependencies [
6ada52b,a675d8e]:- @endo/module-source@1.4.1
- ses@1.16.0
- #3082
2e00276Thanks @boneskull! - - Breaking:CompartmentMapDescriptorno longer has apathproperty.- Breaking:
CompartmentMapDescriptor'slabelproperty is now a canonical name (a string of one or more npm package names separated by>). - Breaking: The
CompartmentMapDescriptorreturned bycaptureFromMap()now uses canonical names as the keys in itscompartmentsproperty. - Breaking types:
CompartmentMapDescriptor,CompartmentDescriptor,ModuleConfiguration(renamed fromModuleDescriptor) andModuleSourcehave all been narrowed into discrete subtypes. captureFromMap(),loadLocation()andimportLocation()now accept amoduleSourceHookoption. This hook is called when processing each module source, receiving the module source data (location, language, bytes, or error information) and the canonical name of the containing package.captureFromMap()now accepts apackageConnectionsHookoption. This hook is called for each retained compartment with its canonical name and the set of canonical names of compartments it links to (its connections). Useful for analyzing or visualizing the dependency graph.mapNodeModules(),loadLocation(),importLocation(),makeScript(),makeFunctor(), andwriteScript()now accept the following hook options:unknownCanonicalNameHook: Called for each canonical name mentioned in policy but not found in the compartment map. Useful for detecting policy misconfigurations.packageDependenciesHook: Called for each package with its set of dependencies. Can return partial updates to modify the dependencies, enabling dependency filtering or injection based on policy.packageDataHook: Called once with data about all packages found while crawlingnode_modules, just prior to creation of a compartment map.
- When dynamic requires are enabled via configuration, execution now takes policy into consideration when no other relationship (for example, a dependent/dependee relationship) between two Compartments exists. When policy explicitly allows access from package A to B and A dynamically requires B (via absolute path or otherwise), the operation will succeed. This can occur if and only if dynamic requires are enabled and a policy is provided.
- Improved error messaging for policy enforcement failures.
- Breaking:
-
#3055
81b4c40Thanks @naugtur! - - Introduces additional signal to consider an export from a package an ESM module when it's selected via animportkey inexportsin package.json in case no other indication of it being an ESM module is present. -
Updated dependencies [
2e00276,a29ecd4,a7d3d26,d83b1ab]:- ses@1.15.0
- @endo/module-source@1.4.0
- @endo/zip@1.1.0
1.6.3 (2025-07-12)
- compartment-mapper: convert dynamically-required relative paths to absolute (208f2a8)
- compartment-mapper: guarantee stable paths (#2872) (5ff31f9)
1.6.2 (2025-06-17)
- Produces a stub for
require.extensionsin CommonJS modules to increase ecosystem compatibility.
1.6.1 (2025-06-02)
- The
devflag formapNodeModules()is no longer deprecated. The concept of a "condition" (conditional exports) is disinct from the flag's original meaning (instructsmapNodeModules()to considerdevDependencieswhen graphing packages). Users who have switched to using adevelopmentcondition fordev's purpose are encouraged to switch back to using thedevflag instead. In a future release, the presence of adevelopmentcondition will no longer mimic an enableddevflag and will only be considered when evaluating conditional exports.
1.6.0 (2025-03-24)
-
Accommodates CommonJS modules that use
definePropertyonexports. -
Divides the role of
makeBundleintomakeScriptandmakeFunctor. The newmakeScriptreplacesmakeBundlewithout breaking changes, producing a JavaScript string that is suitable as a<script>tag in a web page. -
The new
makeFunctorproduces a JavaScript string that, when evaluated, produces a partially applied function, so the caller can provide runtime options. -
Both
makeScriptandmakeFunctornow acceptformat,useEvaluateandsourceUrlPrefixoptions. -
The functor produced by
makeFunctornow acceptsevaluate,require, andsourceUrlPrefixruntime options. -
Both
makeScriptandmakeFunctornow accept aformatoption. Specifiying the"cjs"format allows the bundle to exit to the host's CommonJSrequirefor host modules. -
Adds
sourceDirnameto compartment descriptors in the compartment maps generated bymapNodeModulesand uses these to provide better source URL comments for bundles generated bymakeScriptandmakeFunctor, by default.
These changes collectively allow us to replace the implementation of
nestedEvaluate and getExports formats in @endo/bundle-source, including
the preservation of useful line numbers and file names in stack traces.
mapNodeModules,importLocationandloadLocationnow accept alogoption for users to define a custom logging function. As of this writing, onlymapNodeModuleswill potentially call this function if provided. Expansion of log messaging and support for thelogoption in more APIs is expected in the future.
1.5.0 (2025-01-24)
mapNodeModulesand all functions that use it now tolerate the absence of expected packages. These packages are now omitted from the generated package skeleton map. So, loading a physically missing module now occurs during the load phase instead of the mapping phase.- Adds a
strictoption to all functions thatmapNodeModulesto restore old behavior, which produces an error early if, for example, a non-optional peer dependency is missing. Peer dependencies are strictly required unlesspeerDependenciesMetahas an object with a truthyoptionalentry. Correct interpretation ofpeerDependenciesis not distributed evenly, so this behavior is no longer the default.
Experimental:
- The module
@endo/compartment-mapper/import-archive-parsers.jsdoes not support modules in archives in their original ESM (mjs) or CommonJS (cjs) formats because they entrain Babel and a full JavaScript lexer that are not suitable for use in all environments, specifically XS. This version introduces an elective@endo/compartment-mapper/import-archive-all-parsers.jsthat has all of the precompiled module parsers (pre-cjs-jsonandpre-mjs-json) that Endo's bundler currently produces by default and additionally parsers for original sources (mjs,cjs). Also, provided thexspackage condition,@endo/compartment-mapper/import-archive-parsers.jsnow falls through to the nativeModuleSourceand safely includesmjsandcjswithout entraining Babel, but is only supported in conjunction with the__native__option forCompartment,importArchive,parseArchive, andimportBundle. With thenodepackage condition (present by default when running ESM onnode),@endo/compartment-mapper/import-archive-parsers.jsalso now includesmjsandcjsby entraining Babel, which performs adequately on that platform. - Adds a
__native__: trueoption to all paths to import, that indicates that the application will fall through to the native implementation of Compartment, currently only available on XS, which lacks support for precompiled module sources (as exist in many archived applications, particularly Agoric smart contract bundles) and instead supports loading modules from original sources (which is not possible at runtime on XS).
1.4.0 (2024-11-13)
- Adds options
languageForExtension,moduleLanguageForExtension,commonjsLanguageForExtension, andlanguagestomapNodeModulesandcompartmentMapForNodeModulesallowing for certain mappings from extension (e.g.,ts) to language (e.g.,mtsorcts) to depend on the each package’stypein the way we already varyjsbetweencjsandmjs. These options enter through the high level functions includingmakeArchiveandimportLocation. - The new options
workspaceLanguageForExtension,workspaceModuleLanguageForExtension, andworkspaceCommonjsLanguageForExtensionapply like the above except more specifically and for packages that are not physically located under anode_modulesdirectory, indicating that JavaScript has not yet been generated from any non-JavaScript source files. - Omits unused module descriptors from
compartment-map.jsonin archived applications, potentially reducing file sizes. - Fixes an issue where errors thrown from exit module hooks (
importHook) would be thrown at parse-time when the parser uses heuristic import analysis instead of at runtime. Such errors will now be thrown at runtime, as originally intended. To those who expected the previous behavior: if you exist, please exercise caution when upgrading.
1.3.1 (2024-10-22)
Note: Version bump only for package @endo/compartment-mapper
1.3.0 (2024-10-10)
- Adds support for dynamic requires in CommonJS modules. This requires specific
configuration to be passed in (including new read powers), and is not
enabled by default. See the signature of
loadFromMap()inimport-lite.jsfor details.
1.2.2 (2024-08-27)
1.2.1 (2024-08-01)
Note: Version bump only for package @endo/compartment-mapper
1.2.0 (2024-07-30)
- Fixes incompatible behavior with Node.js package conditional exports #2276.
Previously, the last matching tag would override all prior matches, often
causing a bundle to adopt the
defaultinstead of a more specific condition. - Adds
parserForLanguageandlanguageForExtensionoptions to all modes of operation such that the compartment mapper can analyze and bundle languages apart from the built-in languages, which includeesmandcjs. ThelanguageForExtensionoption provides defaults for the entire application and the"parsers"property in individualpackage.jsondescriptors may extend or override using any of the configured or built-in language parser names. - Exports
import-lite.js,archive-lite.js,import-archive-lite.js,import-parsers.js,archive-parsers.js,import-archive-parsers.js, andnode-modules.js, allowing these to be mixed and matched. The existingimport.js,archive.js, andimport-archive.jsall entrain by import their corresponding default behaviors, where the new modules do not. For example,import-parsers.jsdoes not entrain Babel. The newimport-lite.jsdoes not entrainnode-modules.jsand composes with potential alternative package discovery, storage, and locks. - Adds JSON module support to
makeBundle. - Aliases and deprecates
tagsin favor ofconditionsto align with Node.js terminology. mapNodeModulesnow infers that it should includedevDependenciesfrom the entry package from the presence of"development"inconditions, if thedevoption is abseent.
1.1.5 (2024-05-07)
Note: Version bump only for package @endo/compartment-mapper
1.1.4 (2024-04-04)
Note: Version bump only for package @endo/compartment-mapper
1.1.3 (2024-03-20)
Note: Version bump only for package @endo/compartment-mapper
1.1.2 (2024-02-23)
Note: Version bump only for package @endo/compartment-mapper
1.1.1 (2024-02-15)
- Add repository directory to all package descriptors (e5f36e7)
1.1.0 (2024-01-18)
- compartment-mapper: add policy-related types (d3b49e8)
- compartment-mapper: handle implicit policy/packagePolicy (ed6f23e)
- compartment-mapper: throw if policy/packagePolicy mismatch (ece09e2)
1.0.1 (2023-12-20)
Note: Version bump only for package @endo/compartment-mapper
1.0.0 (2023-12-12)
- compartment-mapper: allow skipping powerless packages in policy resources WIP (b03efc2)
- compartment-mapper: improve unresolved module error message (323ca32)
- Adjust type generation in release process and CI (9465be3)
- compartment-mapper: correct error interpretations, negative policy enforcement test (d19afd2)
- compartment-mapper: fix archive producing invalid compartment maps (5d3a711)
- compartment-mapper: fix for bundling of appended cjs exports (65c7750)
- compartment-mapper: Import main as . (19dc5bc)
- compartment-mapper: policy - allow any packages imported in the attenuators compartment (bc5a0ae)
- compartment-mapper: Turn empty policy into a null-prototype object (db2545b)
- enable compatibility with node16/nodenext module resolution (9063c47)
0.9.2 (2023-09-12)
- compartment-mapper/policy: do not allow "resources" to be an array (42a8817)
- compartment-mapper: Update stack trace sensitive snapshots (7addc5c)
- types: SourceMapHook (cf5f226)
0.9.1 (2023-08-07)
- compartment-mapper: One concurrent read (29048a2)
- compartment-mapper: Read more carefully (edf058a)
- compartment-mapper: Revert read more carefully (cf668e2)
- compartment-mapper: Support source map generation (7f2dc59)
- compartment-mapper: Use maybeRead to better classify read errors (9bea95a)
0.9.0 (2023-08-07)
- Introduces support for source map generation.
Look for
computeSourceMapLocationandsourceMapHookinREADME.md.
0.8.5 (2023-07-19)
- Adds
importHookoption to all applicable options bags. - Bundler now supports aliases, so is now able to bundle most applications that consist entirely of CJS and ESM sources.
- Fixes archive generation, such that it throws if the entry module does not exist.
- Fixes preservation of order for imported shims.
0.8.4 (2023-04-20)
Note: Version bump only for package @endo/compartment-mapper
0.8.3 (2023-04-14)
Note: Version bump only for package @endo/compartment-mapper
0.8.2 (2023-03-07)
- compartment-mapper: add policy enforcement to compartment-mapper (9315993)
- compartment-mapper: add the ability to specify a default attenuator for the policy (95bdcc3)
- compartment-mapper: allow omitting globalThis freeze with policy (bbec3ca)
- compartment-mapper: attenuate builtins with attenuators from packages (dc8426f)
- compartment-mapper: error propagation from globalThis attenuators (43799be)
- compartment-mapper: expect independent names for globals and module attenuator (5c7e048)
- compartment-mapper: globals attenuation enabling LavaMoat feature parity (20acd6f)
- compartment-mapper: validate policy in compartment map (55a3991)
- compartment-mapper: wildcard policy specified as "any" (89e7104)
- compartment-mapper: fix naming conventions, move entry compartment policy, clean up demo and readme (35a7d8b)
- compartment-mapper: use reliable information to identify packages for policy application (2fb7900)
- Fix hackerone.com links in SECURITY.md (#1472) (389733d)
- Improve typing information (7b3fc39)
0.8.1 (2022-12-23)
- Increases ecosystem compatibility for reflective imports, the
browserfield specified ad hoc by Browserify, and a fix for differentiating module language from its extension. - Adds CommonJS support to the unsafe bootstrapping bundle format.
- Introduces usage of
__reexportsMap__from static module record to handle named reexports in the bundler.
0.8.0 (2022-11-14)
- Bundles now evaluate to their entrypoint module's namespace object.
- Removes support for
globalLexicals.
0.7.15 (2022-10-24)
Note: Version bump only for package @endo/compartment-mapper
0.7.14 (2022-10-19)
Note: Version bump only for package @endo/compartment-mapper
0.7.13 (2022-09-27)
Note: Version bump only for package @endo/compartment-mapper
0.7.12 (2022-09-14)
Note: Version bump only for package @endo/compartment-mapper
0.7.11 (2022-08-26)
Note: Version bump only for package @endo/compartment-mapper
0.7.10 (2022-08-26)
Note: Version bump only for package @endo/compartment-mapper
0.7.9 (2022-08-25)
Note: Version bump only for package @endo/compartment-mapper
0.7.8 (2022-08-23)
- compartment-mapper: avoid mislabeling cjs files as esm based on type field (5a6a501)
0.7.7 (2022-06-28)
- Adds
require.resolvesupport and provides its implementation fromreadPowers.requireResolveif available.
0.7.6 (2022-06-11)
- Adds support by default for "text" and "bytes" as file types with eponymous
parser behavior, interpreting text as exporting a UTF-8 string named default,
and bytes as exporting a default ArrayBuffer.
The
"parsers"directive inpackage.jsoncan map additional extensions to either of these types, in the scope of the declaring package. - Compartment maps in archives now only retain compartment descriptors for compartments that are necessary for the modules retained by the entry module.
- Compartment maps in archives now only include a sequence number to disambiguate compartments for which there are multiple original Node.js packages in the solution with the same version and name. We still allow for the possibility that these duplicates exist and in fact may contain different sources, since they may be retained as dependencies beyond the purview of npm.
- A package.json file with the "type" field nested within a package's folder structure a is now taken into account when determining if a .js file is an ES module.
- Adds means to make
__dirnameand__filenamework in CommonJS modules when loaded via importLocation or loadLocation. PassreadPowerswithfileURLToPathmethod present.
0.7.5 (2022-04-15)
Note: Version bump only for package @endo/compartment-mapper
0.7.4 (2022-04-14)
Note: Version bump only for package @endo/compartment-mapper
0.7.3 (2022-04-13)
- Revert dud release (c8a7101)
0.7.2 (2022-04-12)
- 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.jsextension including the referenced module will be treated an ESM, as if it had the.mjsextension. - Ensures that the
"endo","import", and"default"tags (Node.js conditions) are respected inpackage.json"exports"conditions.
0.7.1 (2022-03-07)
Note: Version bump only for package @endo/compartment-mapper
0.7.0 (2022-03-02)
- 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
makeAndHashArchivefunction that returns both the generated bytes and the SHA-512 of an archive as its created.makeArchivejust returns the bytes.
0.6.7 (2022-02-20)
- BREAKING: The
loadArchiveandparseArchivefunctions, 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 amodulesoption if the archive will expect any built-in modules. Themodulesoption 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
parseArchivefunction returns a promise for an archive. If provided acomputeSha512, regardless of whether providedexpectedSha512, the archive will have asha512property computed from the parsed archive, for the purpose of verifying integrity.
0.6.6 (2022-02-18)
- Address TypeScript recommendations (2d1e1e0)
- Make jsconfigs less brittle (861ca32)
- Make sure lint:type runs correctly in CI (a520419)
- Unify TS version to ~4.2 (5fb173c)
- compartment-mapper: change how parse-cjs.js treats exports to align with behavior of cjs in Node.js; make execute synchronous (d1eb363)
0.6.5 (2022-01-31)
0.6.4 (2022-01-27)
0.6.3 (2022-01-25)
Note: Version bump only for package @endo/compartment-mapper
0.6.2 (2022-01-23)
Note: Version bump only for package @endo/compartment-mapper
0.6.1 (2021-12-14)
Note: Version bump only for package @endo/compartment-mapper
0.6.0 (2021-12-08)
- compartment-mapper: Thread url into power makers for Windows support (fedcc8c)
- Avoid eslint globs for Windows (4b4f3cc)
- compartment-mapper: prettier bundle code, with some reduction (dc9ccaa)
- static-module-record: cleaner Babel codegen (6e22569)
0.5.6 (2021-11-16)
- compartment-mapper: Add hooks for sourceURL (#932) (a7b42ae)
- compartment-mapper: Archive source URL suffixes (#930) (0dfb83e)
0.5.5 (2021-11-02)
Note: Version bump only for package @endo/compartment-mapper
0.5.4 (2021-10-15)
Note: Version bump only for package @endo/compartment-mapper
0.5.3 (2021-09-18)
- The
node-powers.jsmodule now exportsmakeReadPowersandmakeWritePowerswhich replace the deprecated functionsmakeNodeReadPowersandmakeNodeWritePowers. The rename is necessary to facilitate a change to the signature of these methods so thaturlmay be accepted as another dependency, to facilitate Windows support. Both accept a bag of Node.js modules that must includefsandurl. The read powers may optionally take thecryptomodule.
0.5.2 (2021-08-14)
- 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).
0.5.1 (2021-08-13)
- Adds support for reflexive import specifiers, so modules in package named
@example/examplemay import@example/examplefrom their own modules. This is necessary for parity with Node.js.
0.5.0 (2021-07-22)
- 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.jscryptomodule.writeArchiveandmakeArchiveaccept acomputeSha512capability and use it to populate thecompartment-map.jsonincluded within the archive with the SHA-512 of every module in the archive. This ensures that the hash ofcompartment-map.jsonin a pair of archives is consistent only if every file is consistent.importArchive,loadArchive, andparseArchiveall optionally accept acomputeSha512capability, use it to verify the integrity of the archive and verify theexpectedSha512of the containedcompartment-map.jsonimportArchiveandloadArchivereceive the hash function as a read power.parseArchivereceives the hash function as an option since it doesn't receive read powers.hashLocationproduces 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.
0.4.1 (2021-06-20)
- Fixes internal type references.
0.4.0 (2021-06-16)
- 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
devoption to archive and import workflows to include thedevDependenciesof the entry package (but not other packages). - Fixes a missing file in the published assets for
@endo/compartment-mapper/node-powers.js.
0.3.2 (2021-06-14)
- 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 onlyreadwas accepted previously, specificallycompartmentMapFromNodeModules,makeArchive,writeArchive, andloadLocation. - Adds an
"@endo/compartment-mapper/node-powers.js"entry point utility module that exportsmakeNodeReadPowersandmakeNodeWritePowersthat adapt the Node.jsfsmodule to the promise and URL oriented interfaces expected by compartment mapper functions.
0.3.1 (2021-06-06)
Note: Version bump only for package @endo/compartment-mapper
- 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.jsto capture narrower dependency subgraphs. - BREAKING: Removes CommonJS and UMD downgrade compatibility.
Supporting both Node.js ESM and the
node -r esmshim 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 theesmJavaScript module emulator. - BREAKING: Archives created for the previous version will no longer work.
The
importArchivefeature 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
StaticModuleRecordfrom SES, and the removal of theses/lockdownlight layering (there is no heavy layer to distinguish as the weight has shifted to the@endo/static-module-recordpackage). - 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
globalThisis frozen.
- Embellishes all calls to methods named
importto work around SES-shimCompartmentcensoring 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
importto work around SES-shimCompartmentcensoring 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
importmethods now take an options bag that may containglobalsandmodulesoptions 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 esmand Rollup. CommonJS support should be restored with an alternate implementation in a future version. - The
importoptions bag now also acceptsglobalLexicals,transforms, and__shimTransforms__, passing these without alteration to eachCompartment. - The
importoptions bag now also accepts aCompartmentconstructor, 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.