Skip to content

v0.5.0#19

Merged
tkoehlerlg merged 4 commits into
mainfrom
v0.5.0
Nov 19, 2025
Merged

v0.5.0#19
tkoehlerlg merged 4 commits into
mainfrom
v0.5.0

Conversation

@tkoehlerlg

@tkoehlerlg tkoehlerlg commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

Add CommonJS Support for NestJS Compatibility

Summary

Adds dual module support (ESM + CommonJS) to make the SDK compatible with CommonJS-based frameworks like NestJS while maintaining backward compatibility with ESM projects.

Changes

1. Package Configuration (package.json)

  • Dual exports: Added both import (ESM) and require (CJS) conditions
  • Module fields:
    • main./dist/index.cjs (CJS for legacy/CommonJS)
    • module./dist/index.js (ESM for modern bundlers)
    • types → Separate type definitions for each format
  • Build scripts: Refactored into modular commands
    • build:types - Generate TypeScript declarations
    • build:esm - Build ESM bundle
    • build:cjs - Build CommonJS bundle
    • build - Run all three in sequence
  • Version: Bumped to 0.5.0 (minor version for new functionality)

2. Build Output (dist/)

  • index.js - ESM bundle
  • index.cjs - CommonJS bundle
  • index.d.ts - ESM type declarations
  • index.d.cts - CommonJS type declarations

3. Compatibility Tests (tests/compatibility.test.ts)

New comprehensive test suite with 13 tests validating:

  • ESM imports: Bundle loading, exports, class instantiation
  • CommonJS imports: Bundle loading via require(), exports, class instantiation
  • Cross-module consistency: Identical APIs and behavior between ESM/CJS
  • TypeScript definitions: Valid type declarations for both formats
  • Build check: Fails fast with clear error if dist files missing

@codecov

codecov Bot commented Nov 19, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tkoehlerlg
tkoehlerlg merged commit 02e4b97 into main Nov 19, 2025
6 checks passed
@tkoehlerlg
tkoehlerlg deleted the v0.5.0 branch November 19, 2025 08:17
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.

1 participant