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
17 changes: 17 additions & 0 deletions .changeset/fix-cjs-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"@ciscode/cache-kit": patch
---

fix: switch build output to CommonJS and add exports field to package.json

The published package was shipping ESM-only output (`module: ESNext`) without
`"type": "module"` in package.json and without `.js` extensions on internal
imports — making the package unloadable in Node.js ESM or CJS environments.

Changes:
- `tsconfig.build.json`: switched `module` to `CommonJS` and `moduleResolution`
to `Node10` so `dist/` emits standard CJS that Node.js loads without any
configuration on the consumer side
Comment on lines +12 to +14
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

This changeset implies moduleResolution: Node10 is what makes dist/ emit CommonJS. The emitted module format is controlled by compilerOptions.module; moduleResolution only affects how TypeScript resolves imports/types during compilation. Consider rewording this bullet so the release note is technically accurate.

Suggested change
- `tsconfig.build.json`: switched `module` to `CommonJS` and `moduleResolution`
to `Node10` so `dist/` emits standard CJS that Node.js loads without any
configuration on the consumer side
- `tsconfig.build.json`: switched `module` to `CommonJS` so `dist/` emits
standard CJS that Node.js loads without any configuration on the consumer
side, and set `moduleResolution` to `Node10` to align TypeScript's
import/type resolution during compilation

Copilot uses AI. Check for mistakes.
- `package.json`: added `exports` field with `require` and `default` conditions
pointing to `./dist/index.js`, ensuring both `require()` and `import` work
correctly when consumers use the package
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"default": "./dist/index.js"
}
},
Comment on lines +21 to +26
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

exports only points to ./dist/index.js. When a package defines an exports map, TypeScript (especially with moduleResolution: node16/nodenext/bundler) may rely on it to find declaration files; without a types condition pointing at ./dist/index.d.ts, TS consumers can lose types or fail to resolve the package. Add a types entry under exports["." ] (and keep it in sync with the top-level types field).

Copilot uses AI. Check for mistakes.
"engines": {
"node": ">=20"
},
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"compilerOptions": {
"noEmit": false,
"emitDeclarationOnly": false,
"outDir": "dist"
"outDir": "dist",
"module": "CommonJS",
"moduleResolution": "Node10"
},
"include": ["src/**/*.ts"],
"exclude": ["test", "**/*.spec.ts", "**/*.test.ts", "dist", "node_modules"]
Expand Down
Loading