Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/26206-cjs-entry-points.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@objectstack/metadata-core': patch
'@objectstack/service-cluster': patch
'create-objectstack': patch
---

fix(metadata-core,service-cluster,create-objectstack): ESM-only subpaths declare their types under `import`

Clause-②: no
Metadata-protocol: none

`@objectstack/metadata-core/testing`, `@objectstack/service-cluster/testing` and `create-objectstack/created-summary` are ESM-only, and now say so in their export maps: the subpath's `types` moved inside its `import` condition. `require()` of these subpaths already failed at runtime with `ERR_PACKAGE_PATH_NOT_EXPORTED`. Before this change, TypeScript under `node16`/`nodenext` resolved their declarations for a CommonJS caller anyway (attw `CJSResolvesToESM`). Now it resolves them for `import` only, which is what Node does. ESM callers, and every resolution mode that reads the `import` condition, see no change. Each package's README now says the subpath is ESM-only.
7 changes: 7 additions & 0 deletions packages/create-objectstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ npm run validate # verify metadata: schema + predicates + bindings
See the docs:
[Your First Project](https://objectstack.ai/docs/getting-started/your-first-project).

## Library subpath

`create-objectstack/created-summary` (the "what was written" tree summary that
`objectstack init` reuses) is **ESM-only**: the package is `"type": "module"`
and the subpath declares only an `import` condition. Load it with `import`;
`require()` is refused with `ERR_PACKAGE_PATH_NOT_EXPORTED`.

## License

Apache-2.0. See [LICENSING.md](../../LICENSING.md).
6 changes: 4 additions & 2 deletions packages/create-objectstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
],
"exports": {
"./created-summary": {
"types": "./dist/created-summary.d.ts",
"import": "./dist/created-summary.js"
"import": {
"types": "./dist/created-summary.d.ts",
"default": "./dist/created-summary.js"
}
}
},
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions packages/metadata-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ import {
```

See ADR-0008 §2 for the full architectural rationale.

`@objectstack/metadata-core/testing` (the repository contract suites) is
**ESM-only**: it imports `vitest`, whose own `require()` entry throws, so
the subpath declares only an `import` condition. Load it with `import`;
`require()` is refused with `ERR_PACKAGE_PATH_NOT_EXPORTED`.
6 changes: 4 additions & 2 deletions packages/metadata-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
}
},
"./testing": {
"types": "./dist/testing.d.ts",
"import": "./dist/testing.js"
"import": {
"types": "./dist/testing.d.ts",
"default": "./dist/testing.js"
}
}
},
"files": [
Expand Down
2 changes: 2 additions & 0 deletions packages/services/service-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ import { ClusterServicePlugin } from '@objectstack/service-cluster';
```

Documentation: [Cluster](https://objectstack.ai/docs/kernel/cluster)

`@objectstack/service-cluster/testing` (the pub/sub, lock, KV and counter contract suites) is **ESM-only**: it imports `vitest`, whose own `require()` entry throws, so the subpath declares only an `import` condition. Load it with `import`; `require()` is refused with `ERR_PACKAGE_PATH_NOT_EXPORTED`.
6 changes: 4 additions & 2 deletions packages/services/service-cluster/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
}
},
"./testing": {
"types": "./dist/testing.d.ts",
"import": "./dist/testing.js"
"import": {
"types": "./dist/testing.d.ts",
"default": "./dist/testing.js"
}
}
},
"scripts": {
Expand Down
Loading