refactor(compartment-mapper)!: Rearrange entry point modules
MODIFY
packages/compartment-mapper/NEWS.md
packages/compartment-mapper/NEWS.md
@@ -9,6 +9,10 @@ User-visible changes to the compartment mapper:
* 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`, 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*: 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

ADD
packages/compartment-mapper/archive.js
+export { makeArchive, writeArchive } from './src/archive.js';

ADD
packages/compartment-mapper/import-archive.js
+export {
+ parseArchive,
+ loadArchive,
+ importArchive,
+} from './src/import-archive.js';

ADD
packages/compartment-mapper/import.js
+export { loadLocation, importLocation } from './src/import.js';

ADD
packages/compartment-mapper/index.js
+// @ts-check
+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/package.json
packages/compartment-mapper/package.json
"license": "Apache-2.0",
"type": "module",
"main": "./dist/compartment-mapper.cjs",
- "module": "./src/main.js",
+ "module": "./index.js",
"browser": "./dist/compartment-mapper.umd.js",
"unpkg": "./dist/compartment-mapper.umd.js",
"exports": {
- "import": "./src/main.js",
- "require": "./dist/compartment-mapper.cjs",
- "browser": "./dist/compartment-mapper.umd.js"
+ "./package.json": "./package.json",
+ ".": {
+ "import": "./index.js"
+ },
+ "./import.js": {
+ "import": "./import.js"
+ },
+ "./archive.js": {
+ "import": "./archive.js"
+ },
+ "./import-archive.js": {
+ "import": "./import-archive.js"
+ }
},
"scripts": {
"build": "rollup --config rollup.config.js",
"files": [
"LICENSE*",
"dist",
- "src"
+ "src",
+ "index.js",
+ "index.d.ts",
+ "archive.js",
+ "import.js",
+ "import-archive.js"
]
}

MODIFY
packages/compartment-mapper/rollup.config.js
packages/compartment-mapper/rollup.config.js
@@ -12,7 +12,7 @@ const external = ['buffer', 'events', 'os', 'stream', 'tty', 'util'];
export default [
{
- input: 'src/main.js',
+ input: 'index.js',
output: [
{
file: `dist/${name}.cjs`,

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

MODIFY
packages/compartment-mapper/test/app.agar-make.js
packages/compartment-mapper/test/app.agar-make.js
import 'ses';
import fs from 'fs';
-import { writeArchive } from '../src/main.js';
+import { writeArchive } from '../archive.js';
const fixture = new URL('node_modules/app/main.js', import.meta.url).toString();
const archiveFixture = new URL('app.agar', import.meta.url).toString();

MODIFY
packages/compartment-mapper/test/test-bundle.js
packages/compartment-mapper/test/test-bundle.js
import 'ses';
import fs from 'fs';
import test from 'ava';
-import { makeBundle, makeArchive, parseArchive } from '../src/main.js';
+import { makeBundle, makeArchive, parseArchive } from '../index.js';
const fixture = new URL(
'node_modules/bundle/main.js',

MODIFY
packages/compartment-mapper/test/test-main.js
packages/compartment-mapper/test/test-main.js
@@ -9,7 +9,7 @@ import {
parseArchive,
loadArchive,
importArchive,
-} from '../src/main.js';
+} from '../index.js';
const fixture = new URL('node_modules/app/main.js', import.meta.url).toString();
const archiveFixture = new URL('app.agar', import.meta.url).toString();

MODIFY
packages/compartment-mapper/test/test-transform.js
packages/compartment-mapper/test/test-transform.js
import 'ses';
import fs from 'fs';
import test from 'ava';
-import { loadLocation } from '../src/main.js';
+import { loadLocation } from '../src/import.js';
import { makeArchive } from '../src/archive.js';
import { parseArchive } from '../src/import-archive.js';

refactor(compartment-mapper)!: Rearrange entry point modules