Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(compartment-map): Decouple discovery and languages #2306

Merged
merged 9 commits into from
Jun 4, 2024
9 changes: 9 additions & 0 deletions packages/compartment-mapper/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ User-visible changes to the compartment mapper:
application and the `"parsers"` property in individual `package.json`
descriptors 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`, and
`node-modules.js`, allowing these to be mixed and matched.
The existing `import.js`, `archive.js`, and `import-archive.js` all entrain
by import their corresponding default behaviors, where the new modules do
not.
For example, `import-parsers.js` does not entrain Babel.
The new `import-lite.js` does not entrain `node-modules.js` and composes
with potential alternative package discovery, storage, and locks.

# 0.9.0 (2023-08-07)

Expand Down
7 changes: 7 additions & 0 deletions packages/compartment-mapper/archive-lite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export {
makeArchiveFromMap,
makeAndHashArchiveFromMap,
writeArchiveFromMap,
mapFromMap,
hashFromMap,
} from './src/archive-lite.js';
1 change: 1 addition & 0 deletions packages/compartment-mapper/archive-parsers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { defaultParserForLanguage } from './src/archive-parsers.js';
5 changes: 5 additions & 0 deletions packages/compartment-mapper/import-archive-lite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export {
parseArchive,
loadArchive,
importArchive,
} from './src/import-archive-lite.js';
1 change: 1 addition & 0 deletions packages/compartment-mapper/import-archive-parsers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { defaultParserForLanguage } from './src/import-archive-parsers.js';
1 change: 1 addition & 0 deletions packages/compartment-mapper/import-lite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { loadFromMap, importFromMap } from './src/import-lite.js';
1 change: 1 addition & 0 deletions packages/compartment-mapper/import-parsers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { defaultParserForLanguage } from './src/import-parsers.js';
1 change: 1 addition & 0 deletions packages/compartment-mapper/node-modules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { mapNodeModules } from './src/node-modules.js';
7 changes: 7 additions & 0 deletions packages/compartment-mapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@
"default": "./index.js"
},
"./import.js": "./import.js",
"./import-lite.js": "./import-lite.js",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(suggestion/observation/trolling) there's obviously a convention at play here, but I'd omit the .js from the keys

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I very much want to. It’s not just convention, though. This makes the Compartment Mapper continue to work when used on some older foundations like node -r esm that do not read the "exports" directive, so we can’t use it for aliases, just to limit exposure. We have one lingering integration test that needs to be replaced before we can drop this pattern.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't realize that esm was a target

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be reasonable to provide both extension-laden and extension-free exports?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that’s reasonable when after eliminate standardthings/esm from our toolchain. Until then, better to encourage usage patterns that are portable.

"./import-parsers.js": "./import-parsers.js",
"./archive.js": "./archive.js",
"./archive-lite.js": "./archive-lite.js",
"./archive-parsers.js": "./archive-parsers.js",
"./import-archive.js": "./import-archive.js",
"./import-archive-lite.js": "./import-archive-lite.js",
"./import-archive-parsers.js": "./import-archive-parsers.js",
"./bundle.js": "./bundle.js",
"./node-powers.js": "./node-powers.js",
"./node-modules.js": "./node-modules.js",
"./package.json": "./package.json"
},
"scripts": {
Expand Down
Loading
Loading