feat(compartment-mapper)!: Update packaging for RESM/NESM bridge and reorg under
BREAKING CHANGE: No longer supports direct use from CommonJS
MODIFY
packages/compartment-mapper/NEWS.md
packages/compartment-mapper/NEWS.md
@@ -11,8 +11,11 @@ User-visible changes to the compartment mapper:
bindings.
* Adds entrypoint modules `import.js`, `archive.js`, and `import-archive.js`
to capture narrower dependency subgraphs.
-* *BREAKING*: This version removes UMD and CommonJS module facets, only
- exposing its JS module (ESM/MJS) support.
+* *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 the `esm` 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

MODIFY
packages/compartment-mapper/README.md
packages/compartment-mapper/README.md
@@ -20,7 +20,7 @@ compartment.
```js
import fs from "fs";
-import { importLocation } from "@agoric/compartment-mapper";
+import { importLocation } from "@endo/compartment-mapper";
// ...
@@ -66,7 +66,7 @@ Archives are `zip` files with a `compartment-map.json` manifest file.
```js
import fs from "fs";
-import { writeArchive } from "@agoric/compartment-mapper";
+import { writeArchive } from "@endo/compartment-mapper";
const read = async location =>
fs.promises.readFile(new URL(location).pathname);
@@ -89,7 +89,7 @@ Note the similarity to `importLocation`.
```js
import fs from "fs";
-import { importArchive } from "@agoric/compartment-mapper";
+import { importArchive } from "@endo/compartment-mapper";
// ...
@@ -539,6 +539,6 @@ type ModuleParameter = string;
> the same purposes, using a tool called TOFU: _trust on first use_.
[LavaMoat]: https://github.com/LavaMoat/lavamoat
- [Compartments]: https://github.com/Agoric/SES-shim/blob/master/packages/ses/README.md#compartment
+ [Compartments]: https://github.com/endojs/endo/blob/master/packages/ses/README.md#compartment
[LavaMoat]: https://github.com/LavaMoat/lavamoat
[package entry points]: https://nodejs.org/api/esm.html#esm_package_entry_points

ADD
packages/compartment-mapper/bundle.js
+export { makeBundle, writeBundle } from './src/bundle.js';

ADD
packages/compartment-mapper/index.d.ts
+export { loadLocation, importLocation } from './src/import.js';
+export { makeArchive, writeArchive } from './src/archive.js';
+export {
+ parseArchive,
+ loadArchive,
+ importArchive,
+} from './src/import-archive.js';
+export { search } from './src/search.js';
+export { compartmentMapForNodeModules } from './src/node-modules.js';
+export { makeBundle, writeBundle } from './src/bundle.js';

MODIFY
packages/compartment-mapper/jsconfig.json
packages/compartment-mapper/jsconfig.json
"strictNullChecks": true,
"moduleResolution": "node"
},
- "include": ["src/**/*.js"]
+ "include": ["src/**/*.js", "index.d.ts"]
}

MODIFY
packages/compartment-mapper/package.json
packages/compartment-mapper/package.json
{
- "name": "@agoric/compartment-mapper",
+ "name": "@endo/compartment-mapper",
"version": "0.2.4+1-dev",
"description": "The compartment mapper assembles Node applications in a sandbox",
- "author": "Agoric",
+ "keywords": [
+ "node",
+ "endo",
+ "package",
+ "compartment"
+ ],
+ "author": "Endo contributors",
"license": "Apache-2.0",
+ "homepage": "https://github.com/endojs/endo/tree/master/packages/compartment-mapper#readme",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/endojs/endo.git"
+ },
+ "bugs": {
+ "url": "https://github.com/endojs/endo/issues"
+ },
"type": "module",
"main": "./index.js",
- "module": "./index.js",
+ "types": "./index.d.ts",
"exports": {
- "./package.json": "./package.json",
- ".": {
- "import": "./index.js"
- },
- "./import.js": {
- "import": "./import.js"
- },
- "./archive.js": {
- "import": "./archive.js"
- },
- "./import-archive.js": {
- "import": "./import-archive.js"
- }
+ ".": "./index.js",
+ "./import.js": "./import.js",
+ "./archive.js": "./archive.js",
+ "./import-archive.js": "./import-archive.js",
+ "./bundle.js": "./bundle.js",
+ "./package.json": "./package.json"
},
"scripts": {
- "clean": "rm -rf dist",
+ "build": "exit 0",
"lint": "yarn lint:types && yarn lint:js",
"lint-fix": "eslint --fix '**/*.js'",
"lint:js": "eslint '**/*.js'",
},
"devDependencies": {
"@agoric/eslint-config": "^0.3.6",
- "@rollup/plugin-commonjs": "^13.0.0",
- "@rollup/plugin-json": "^4.1.0",
- "@rollup/plugin-node-resolve": "^9.0.0",
"ava": "^3.12.1",
- "rollup": "^1.31.0"
+ "babel-eslint": "^10.0.3",
+ "eslint": "^7.23.0",
+ "eslint-config-airbnb-base": "^14.0.0",
+ "eslint-config-prettier": "^6.9.0",
+ "eslint-plugin-eslint-comments": "^3.1.2",
+ "eslint-plugin-import": "^2.19.1",
+ "eslint-plugin-prettier": "^3.1.2",
+ "prettier": "^1.19.1",
+ "typescript": "^4.0.5"
},
- "ava": {
"files": [
- "test/**/test-*.js"
+ "LICENSE*",
+ "archive.js",
+ "bundle.js",
+ "import-archive.js",
+ "import.js",
+ "index.d.ts",
+ "index.js",
+ "src"
],
- "require": []
+ "publishConfig": {
+ "access": "public"
},
"eslintConfig": {
"extends": [
"trailingComma": "all",
"singleQuote": true
},
+ "ava": {
"files": [
- "LICENSE*",
- "dist",
- "src",
- "index.js",
- "index.d.ts",
- "archive.js",
- "import.js",
- "import-archive.js"
- ]
+ "test/**/test-*.js"
+ ],
+ "timeout": "2m"
+ }
}

MODIFY
packages/compartment-mapper/src/bundle.js
packages/compartment-mapper/src/bundle.js
@@ -17,7 +17,7 @@ const textEncoder = new TextEncoder();
const q = JSON.stringify;
/** @type {Record<string, ParseFn>} */
-export const parserForLanguage = {
+const parserForLanguage = {
mjs: parseArchiveMjs,
cjs: parseArchiveCjs,
json: parseJson,

MODIFY
packages/compartment-mapper/src/parse-cjs.js
packages/compartment-mapper/src/parse-cjs.js
// @ts-check
+/// <reference types="ses"/>
import { analyzeCommonJS } from '@endo/cjs-module-analyzer';

MODIFY
packages/compartment-mapper/src/types.js
packages/compartment-mapper/src/types.js
// @ts-check
+/// <reference types="ses"/>
// /////////////////////////////////////////////////////////////////////////////

MODIFY
packages/compartment-mapper/test/test-bundle.js
packages/compartment-mapper/test/test-bundle.js
@@ -42,7 +42,7 @@ const expectedLog = [
test('bundles work', async t => {
const bundle = await makeBundle(read, fixture);
- t.log(bundle);
+ // t.log(bundle);
const log = [];
const print = entry => {
log.push(entry);

feat(compartment-mapper)!: Update packaging for RESM/NESM bridge and reorg under @endo

BREAKING CHANGE: No longer supports direct use from CommonJS