Skip to content

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

Merged
y-aithnini merged 1 commit intodevelopfrom
fix/cjs-build-and-publish-fields
Apr 7, 2026
Merged

fix: switch build to CommonJS and add exports field to package.json#20
y-aithnini merged 1 commit intodevelopfrom
fix/cjs-build-and-publish-fields

Conversation

@y-aithnini
Copy link
Copy Markdown
Contributor

The package was shipping ESM output without 'type: module' and without .js extensions on internal imports — making it unloadable in Node.js.

  • tsconfig.build.json: module=CommonJS, moduleResolution=Node10
  • package.json: added exports field with require/default conditions

Summary

  • What does this PR change?

Why

  • Why is this change needed?

Checklist

  • Added/updated tests (if behavior changed)
  • npm run lint passes
  • npm run typecheck passes
  • npm test passes
  • npm run build passes
  • Added a changeset (npx changeset) if this affects consumers

Notes

  • Anything reviewers should pay attention to?

The package was shipping ESM output without 'type: module' and without
.js extensions on internal imports — making it unloadable in Node.js.

- tsconfig.build.json: module=CommonJS, moduleResolution=Node10
- package.json: added exports field with require/default conditions
Copilot AI review requested due to automatic review settings April 7, 2026 12:15
@y-aithnini y-aithnini requested a review from a team as a code owner April 7, 2026 12:15
@y-aithnini y-aithnini merged commit c7846e2 into develop Apr 7, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the library’s packaging/build configuration so it can be loaded reliably by Node.js consumers by emitting CommonJS output and defining an explicit package entrypoint via exports.

Changes:

  • Update tsconfig.build.json to emit CommonJS output (and adjust module resolution).
  • Add an exports map in package.json for the package root entry.
  • Add a changeset documenting the packaging fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tsconfig.build.json Switch build output to CommonJS for Node-friendly dist/ artifacts.
package.json Define package root entry via exports to control consumer resolution.
.changeset/fix-cjs-build.md Release note describing the packaging/build fix.

Comment on lines +21 to +26
"exports": {
".": {
"require": "./dist/index.js",
"default": "./dist/index.js"
}
},
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.
Comment on lines +12 to +14
- `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
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.
Zaiidmo added a commit that referenced this pull request Apr 7, 2026
* ops: UPDATED publish workflow and dependabot PR limits

* ops (ci): standardize publish validation and dependabot across all packages

- Replace git tag --list strategy with package.json-driven tag validation
  in all 16 publish workflows; use git rev-parse to verify the exact tag
  exists rather than guessing the latest repo-wide tag
- Update error guidance to reflect feat/** → develop → master flow
- Standardize dependabot to npm-only, grouped, monthly cadence across
  all 16 packages; remove github-actions ecosystem updates
- Add missing dependabot.yml to AuthKit-UI, ChartKit-UI, HealthKit,
  HooksKit, paymentkit, StorageKit

* security: added CODEOWNER file for branches security

* ops: updated relese check workflow#

* feat(COMPT-55): add ICacheStore port and Redis/InMemory adapters (#1)

* Feature/compt 56 cache module service (#2)

* feat(COMPT-55): add ICacheStore port and Redis/InMemory adapters

* feat(COMPT-56): add CacheModule, CacheService, and DI tokens

* style: fix Prettier formatting across all files

* style: fix Prettier formatting after develop merge

* fix(lint): fix import order and replace any types with proper NestJS types

* Feature/compt 57 cacheable cacheevict decorators (#3)

* feat(COMPT-55): add ICacheStore port and Redis/InMemory adapters

* feat(COMPT-56): add CacheModule, CacheService, and DI tokens

* style: fix Prettier formatting across all files

* style: fix Prettier formatting after develop merge

* fix(lint): fix import order and replace any types with proper NestJS types

* feat(COMPT-57): add @Cacheable and @CacheEvict decorators with key interpolation

* Feature/compt 58 test suite (#4)

* feat(COMPT-55): add ICacheStore port and Redis/InMemory adapters

* feat(COMPT-56): add CacheModule, CacheService, and DI tokens

* style: fix Prettier formatting across all files

* style: fix Prettier formatting after develop merge

* fix(lint): fix import order and replace any types with proper NestJS types

* feat(COMPT-57): add @Cacheable and @CacheEvict decorators with key interpolation

* test(COMPT-58): add full test suite with 95%+ coverage across all adapters, service, and decorators

* fix(lint): fix import/order and no-require-imports violations in spec files

* docs(COMPT-59): add README, update peer deps, create v0.1.0 changeset (#5)

* docs(COMPT-59): add README, update peer deps, create v0.1.0 changeset

* style: fix Prettier formatting across all files

* improvement: replace KEYS with SCAN, fix @Cacheable null-return bug, clean up index exports (#6)

* ci: update release check workflow

* fix(ci): fix SonarCloud coverage — use src/**/*.spec.ts instead of test/ (#8)

* ops: updated release check jobs ]

* install dep

* Fix/sonar test inclusions (#10)

* fix(ci): fix SonarCloud coverage — use src/**/*.spec.ts instead of test/

* chore: set version to 0.0.1 for initial publish

* Fix/sonar test inclusions (#12)

* fix(ci): fix SonarCloud coverage — use src/**/*.spec.ts instead of test/

* Develop (#7)

* ops: UPDATED publish workflow and dependabot PR limits

* ops (ci): standardize publish validation and dependabot across all packages

- Replace git tag --list strategy with package.json-driven tag validation
  in all 16 publish workflows; use git rev-parse to verify the exact tag
  exists rather than guessing the latest repo-wide tag
- Update error guidance to reflect feat/** → develop → master flow
- Standardize dependabot to npm-only, grouped, monthly cadence across
  all 16 packages; remove github-actions ecosystem updates
- Add missing dependabot.yml to AuthKit-UI, ChartKit-UI, HealthKit,
  HooksKit, paymentkit, StorageKit

* security: added CODEOWNER file for branches security

* ops: updated relese check workflow#

* feat(COMPT-55): add ICacheStore port and Redis/InMemory adapters (#1)

* Feature/compt 56 cache module service (#2)

* feat(COMPT-55): add ICacheStore port and Redis/InMemory adapters

* feat(COMPT-56): add CacheModule, CacheService, and DI tokens

* style: fix Prettier formatting across all files

* style: fix Prettier formatting after develop merge

* fix(lint): fix import order and replace any types with proper NestJS types

* Feature/compt 57 cacheable cacheevict decorators (#3)

* feat(COMPT-55): add ICacheStore port and Redis/InMemory adapters

* feat(COMPT-56): add CacheModule, CacheService, and DI tokens

* style: fix Prettier formatting across all files

* style: fix Prettier formatting after develop merge

* fix(lint): fix import order and replace any types with proper NestJS types

* feat(COMPT-57): add @Cacheable and @CacheEvict decorators with key interpolation

* Feature/compt 58 test suite (#4)

* feat(COMPT-55): add ICacheStore port and Redis/InMemory adapters

* feat(COMPT-56): add CacheModule, CacheService, and DI tokens

* style: fix Prettier formatting across all files

* style: fix Prettier formatting after develop merge

* fix(lint): fix import order and replace any types with proper NestJS types

* feat(COMPT-57): add @Cacheable and @CacheEvict decorators with key interpolation

* test(COMPT-58): add full test suite with 95%+ coverage across all adapters, service, and decorators

* fix(lint): fix import/order and no-require-imports violations in spec files

* docs(COMPT-59): add README, update peer deps, create v0.1.0 changeset (#5)

* docs(COMPT-59): add README, update peer deps, create v0.1.0 changeset

* style: fix Prettier formatting across all files

* improvement: replace KEYS with SCAN, fix @Cacheable null-return bug, clean up index exports (#6)

* ci: update release check workflow

* fix(ci): fix SonarCloud coverage — use src/**/*.spec.ts instead of test/ (#8)

* ops: updated release check jobs ]

---------

Co-authored-by: Zaiidmo <zaiidmoumnii@gmail.com>

* chore: set version to 0.0.1 for initial publish

---------

Co-authored-by: Zaiidmo <zaiidmoumnii@gmail.com>

* Fix/sonar test inclusions (#14)

* fix(ci): fix SonarCloud coverage — use src/**/*.spec.ts instead of test/

* Develop (#7)

* ops: UPDATED publish workflow and dependabot PR limits

* ops (ci): standardize publish validation and dependabot across all packages

- Replace git tag --list strategy with package.json-driven tag validation
  in all 16 publish workflows; use git rev-parse to verify the exact tag
  exists rather than guessing the latest repo-wide tag
- Update error guidance to reflect feat/** → develop → master flow
- Standardize dependabot to npm-only, grouped, monthly cadence across
  all 16 packages; remove github-actions ecosystem updates
- Add missing dependabot.yml to AuthKit-UI, ChartKit-UI, HealthKit,
  HooksKit, paymentkit, StorageKit

* security: added CODEOWNER file for branches security

* ops: updated relese check workflow#

* feat(COMPT-55): add ICacheStore port and Redis/InMemory adapters (#1)

* Feature/compt 56 cache module service (#2)

* feat(COMPT-55): add ICacheStore port and Redis/InMemory adapters

* feat(COMPT-56): add CacheModule, CacheService, and DI tokens

* style: fix Prettier formatting across all files

* style: fix Prettier formatting after develop merge

* fix(lint): fix import order and replace any types with proper NestJS types

* Feature/compt 57 cacheable cacheevict decorators (#3)

* feat(COMPT-55): add ICacheStore port and Redis/InMemory adapters

* feat(COMPT-56): add CacheModule, CacheService, and DI tokens

* style: fix Prettier formatting across all files

* style: fix Prettier formatting after develop merge

* fix(lint): fix import order and replace any types with proper NestJS types

* feat(COMPT-57): add @Cacheable and @CacheEvict decorators with key interpolation

* Feature/compt 58 test suite (#4)

* feat(COMPT-55): add ICacheStore port and Redis/InMemory adapters

* feat(COMPT-56): add CacheModule, CacheService, and DI tokens

* style: fix Prettier formatting across all files

* style: fix Prettier formatting after develop merge

* fix(lint): fix import order and replace any types with proper NestJS types

* feat(COMPT-57): add @Cacheable and @CacheEvict decorators with key interpolation

* test(COMPT-58): add full test suite with 95%+ coverage across all adapters, service, and decorators

* fix(lint): fix import/order and no-require-imports violations in spec files

* docs(COMPT-59): add README, update peer deps, create v0.1.0 changeset (#5)

* docs(COMPT-59): add README, update peer deps, create v0.1.0 changeset

* style: fix Prettier formatting across all files

* improvement: replace KEYS with SCAN, fix @Cacheable null-return bug, clean up index exports (#6)

* ci: update release check workflow

* fix(ci): fix SonarCloud coverage — use src/**/*.spec.ts instead of test/ (#8)

* ops: updated release check jobs ]

---------

Co-authored-by: Zaiidmo <zaiidmoumnii@gmail.com>

* chore: set version to 0.0.1 for initial publish

---------

Co-authored-by: Zaiidmo <zaiidmoumnii@gmail.com>

* Fix/align version 1.0.0 (#17)

* chore: align version to 1.0.0 to match master

* chore: revert version to 0.0.1 as required

* fix(chore): reverted versions tags and fixed merge conflits

* 0.0.1

* chore: dump version 1

* fix: switch build to CommonJS and add exports field to package.json (#20)

The package was shipping ESM output without 'type: module' and without
.js extensions on internal imports — making it unloadable in Node.js.

- tsconfig.build.json: module=CommonJS, moduleResolution=Node10
- package.json: added exports field with require/default conditions

* Fix/cjs build and publish fields (#22)

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

The package was shipping ESM output without 'type: module' and without
.js extensions on internal imports — making it unloadable in Node.js.

- tsconfig.build.json: module=CommonJS, moduleResolution=Node10
- package.json: added exports field with require/default conditions

* chore: bump version to 0.0.2

---------

Co-authored-by: Zaiidmo <zaiidmoumnii@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants