|
| 1 | +--- |
| 2 | +"@objectstack/metadata-core": minor |
| 3 | +"@objectstack/service-cluster": minor |
| 4 | +--- |
| 5 | + |
| 6 | +fix: the `./testing` subpaths are ESM-only — they no longer advertise a `require` condition vitest refuses to serve (#12985) |
| 7 | + |
| 8 | +Both packages published their test-harness subpath as a dual entry point: |
| 9 | + |
| 10 | +```jsonc |
| 11 | +// FROM — @objectstack/metadata-core and @objectstack/service-cluster |
| 12 | +"./testing": { |
| 13 | + "types": "./dist/testing.d.ts", |
| 14 | + "import": "./dist/testing.js", |
| 15 | + "require": "./dist/testing.cjs" |
| 16 | +} |
| 17 | + |
| 18 | +// TO |
| 19 | +"./testing": { |
| 20 | + "types": "./dist/testing.d.ts", |
| 21 | + "import": "./dist/testing.js" |
| 22 | +} |
| 23 | +``` |
| 24 | + |
| 25 | +The `require` half was a promise neither package could keep. Both subpaths |
| 26 | +re-export `vitest`, and vitest **refuses** to be loaded from CommonJS by |
| 27 | +design — its CJS entry is a single `throw`: |
| 28 | + |
| 29 | +``` |
| 30 | +node -e "require('@objectstack/metadata-core/testing')" |
| 31 | +Error: Vitest cannot be imported in a CommonJS module using require(). Please use "import" instead. |
| 32 | +``` |
| 33 | + |
| 34 | +The emitted bytes parse; the load fails inside vitest's own entry, for every |
| 35 | +consumer and every code path. So the condition could never resolve to working |
| 36 | +code, on any release, since it was first declared. It is removed rather than |
| 37 | +repaired because the failure is not ours to fix: a test harness has no business |
| 38 | +advertising a `require` condition when the test runner it re-exports does not |
| 39 | +serve one. |
| 40 | + |
| 41 | +**Nothing that worked stops working**, and that is why this is not filed as a |
| 42 | +breaking removal. A CJS consumer that resolved through the old condition got a |
| 43 | +hard `Error` at load; it now gets a resolution error from node instead — a |
| 44 | +different message for the same non-working call, and an earlier and clearer |
| 45 | +one. The `import` condition, the types and the runtime API are untouched, and |
| 46 | +every in-repo consumer already reaches these subpaths through `import` |
| 47 | +(`@objectstack/metadata-fs`, `@objectstack/metadata-protocol`, |
| 48 | +`@objectstack/rest`, `@objectstack/runtime`, `@objectstack/service-cluster-redis`). |
| 49 | + |
| 50 | +**If you did spell it as `require`** — `require('@objectstack/metadata-core/testing')` |
| 51 | +or `require('@objectstack/service-cluster/testing')` — switch the call to |
| 52 | +`await import('@objectstack/metadata-core/testing')`, or move the calling |
| 53 | +module to ESM. That is the same change the old condition already forced on |
| 54 | +you, one error message earlier. |
| 55 | + |
| 56 | +`dist/testing.cjs` is still emitted (both packages build every entry in both |
| 57 | +formats) and still parsed by `pnpm check:dual-build-cjs-loads`; it is simply no |
| 58 | +longer reachable through the manifest. Removing it from the build is a |
| 59 | +tsup-config change with its own risks and is not folded in here. |
0 commit comments