Skip to content

refactor(unit,core.unit)!: migrate to NodeNext with dual CJS/ESM builds#863

Merged
omermorad merged 3 commits into
nextfrom
refactor/unit-core-nodenext-migration
Oct 17, 2025
Merged

refactor(unit,core.unit)!: migrate to NodeNext with dual CJS/ESM builds#863
omermorad merged 3 commits into
nextfrom
refactor/unit-core-nodenext-migration

Conversation

@omermorad

Copy link
Copy Markdown
Collaborator

Migrate @suites/unit and @suites/core.unit to NodeNext-compatible module resolution with dual CommonJS and ESM builds. This ensures proper module resolution in modern Node.js environments while maintaining backward compatibility with CommonJS consumers.

Changes:

  • Add dual build configurations (tsconfig.cjs.json, tsconfig.esm.json)
  • Update build scripts to generate both CJS and ESM outputs
  • Add .js extensions to all relative imports (ESM requirement)
  • Enhance package.json exports with conditional types for import/require
  • Use "module": "esnext" with "moduleResolution": "bundler" for ESM builds
  • Maintain "module": "commonjs" for CJS builds

Relates to #811

Migrate @suites/unit and @suites/core.unit to NodeNext-compatible module
resolution with dual CommonJS and ESM builds. This ensures proper module
resolution in modern Node.js environments while maintaining backward
compatibility with CommonJS consumers.

Changes:
- Add dual build configurations (tsconfig.cjs.json, tsconfig.esm.json)
- Update build scripts to generate both CJS and ESM outputs
- Add .js extensions to all relative imports (ESM requirement)
- Enhance package.json exports with conditional types for import/require
- Use "module": "esnext" with "moduleResolution": "bundler" for ESM builds
- Maintain "module": "commonjs" for CJS builds

Breaking Changes:
- Requires TypeScript 5.0+ to build from source (uses "moduleResolution": "bundler")
- Published packages remain compatible with TypeScript 4.x+ consumers

Relates to #811

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@omermorad omermorad self-assigned this Oct 17, 2025
@codecov

codecov Bot commented Oct 17, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.54%. Comparing base (624dab1) to head (6e63475).
⚠️ Report is 1 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next     #863   +/-   ##
=======================================
  Coverage   92.54%   92.54%           
=======================================
  Files          26       26           
  Lines         590      590           
  Branches       99       99           
=======================================
  Hits          546      546           
  Misses         35       35           
  Partials        9        9           
Flag Coverage Δ
core.unit 93.44% <100.00%> (ø)
di.inversify 93.68% <ø> (ø)
di.nestjs 87.25% <ø> (ø)
doubles.jest 100.00% <ø> (ø)
doubles.sinon 100.00% <ø> (ø)
doubles.vitest 100.00% <ø> (ø)
unit 77.27% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

omermorad and others added 2 commits October 18, 2025 00:50
Add moduleNameMapper to Jest configuration to handle .js extensions in
TypeScript source imports. This allows Jest with ts-jest to properly
resolve imports like `import { foo } from './bar.js'` to their
corresponding `.ts` source files.

The regex `^(\\.{1,2}/.*)\\.js$` strips .js extensions from relative
imports, enabling proper module resolution during test execution.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update Jest configuration to map workspace packages (@suites/*) to their
TypeScript source files instead of compiled dist files. This allows tests
to run without requiring packages to be built first.

Uses absolute paths from monorepo root to handle both flat (/packages/unit)
and nested (/packages/di/inversify) package structures consistently.

Mappings added:
- @suites/core.unit -> packages/core/src/index.ts
- @suites/types.common -> packages/types/common/index.ts
- @suites/types.di -> packages/types/di/src/index.ts
- @suites/types.doubles -> packages/types/doubles/index.d.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@omermorad omermorad merged commit 3b7d7c9 into next Oct 17, 2025
14 checks passed
@omermorad omermorad deleted the refactor/unit-core-nodenext-migration branch October 17, 2025 22:10
@omermorad omermorad linked an issue Oct 23, 2025 that may be closed by this pull request
omermorad added a commit that referenced this pull request Oct 24, 2025
…ds (#863)

Migrate @suites/unit and @suites/core.unit to NodeNext-compatible module resolution with dual CommonJS and ESM builds. This ensures proper module resolution in modern Node.js environments while maintaining backward
compatibility with CommonJS consumers.

Changes:
- Add dual build configurations (tsconfig.cjs.json, tsconfig.esm.json)
- Update build scripts to generate both CJS and ESM outputs
- Add .js extensions to all relative imports (ESM requirement)
- Enhance package.json exports with conditional types for import/require
- Use "module": "esnext" with "moduleResolution": "bundler" for ESM builds
- Maintain "module": "commonjs" for CJS builds

Relates to #811
omermorad added a commit that referenced this pull request Oct 26, 2025
…ds (#863)

Migrate @suites/unit and @suites/core.unit to NodeNext-compatible module resolution with dual CommonJS and ESM builds. This ensures proper module resolution in modern Node.js environments while maintaining backward
compatibility with CommonJS consumers.

Changes:
- Add dual build configurations (tsconfig.cjs.json, tsconfig.esm.json)
- Update build scripts to generate both CJS and ESM outputs
- Add .js extensions to all relative imports (ESM requirement)
- Enhance package.json exports with conditional types for import/require
- Use "module": "esnext" with "moduleResolution": "bundler" for ESM builds
- Maintain "module": "commonjs" for CJS builds

Relates to #811
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.

Suites not NodeNext ready?

1 participant