refactor(compartment-mapper)!: Lean on RESM/NESM interoperability
MODIFY
packages/compartment-mapper/package.json
packages/compartment-mapper/package.json
"author": "Agoric",
"license": "Apache-2.0",
"type": "module",
- "main": "./dist/compartment-mapper.cjs",
+ "main": "./index.js",
"module": "./index.js",
- "browser": "./dist/compartment-mapper.umd.js",
- "unpkg": "./dist/compartment-mapper.umd.js",
"exports": {
"./package.json": "./package.json",
".": {
}
},
"scripts": {
- "build": "rollup --config rollup.config.js",
"clean": "rm -rf dist",
"lint": "yarn lint:types && yarn lint:js",
"lint-fix": "eslint --fix '**/*.js'",
"lint:js": "eslint '**/*.js'",
"lint:types": "tsc --build jsconfig.json",
- "prepublish": "yarn clean && yarn build",
"test": "ava"
},
"dependencies": {

DELETE
packages/compartment-mapper/rollup.config.js
-import resolve from '@rollup/plugin-node-resolve';
-import commonjs from '@rollup/plugin-commonjs';
-import json from '@rollup/plugin-json';
-import fs from 'fs';
-
-const metaPath = new URL('package.json', import.meta.url).pathname;
-const meta = JSON.parse(fs.readFileSync(metaPath, 'utf-8'));
-const name = meta.name.split('/').pop();
-
-const resolveWithBuiltins = () => resolve({ preferBuiltins: true });
-const external = ['buffer', 'events', 'os', 'stream', 'tty', 'util'];
-
-export default [
- {
- input: 'index.js',
- output: [
- {
- file: `dist/${name}.cjs`,
- format: 'cjs',
- },
- ],
- external,
- plugins: [resolveWithBuiltins(), commonjs(), json()],
- },
-];

refactor(compartment-mapper)!: Lean on RESM/NESM interoperability