Summary
Add support for both ESM and CommonJS module systems to improve compatibility with projects using CommonJS resolution (e.g., tsx with CommonJS projects).
Background
Currently, this package is ESM-only ("type": "module"). Users with CommonJS projects encounter module resolution errors when trying to import this package.
Related: #42, PR #43
Proposed Solution
Implement dual module support following the AWS SDK pattern:
- Separate build outputs:
dist-cjs/ (CommonJS) and dist-es/ (ESM)
- Update package.json exports:
"exports": {
".": {
"require": "./dist-cjs/index.js",
"import": "./dist-es/index.js",
"types": "./dist-types/index.d.ts"
}
}
- Add separate TypeScript configs for each module format
Alternatives Considered
- Bundler approach (tsup/esbuild): Single config generates both formats
- Keep ESM-only: Document requirement for users to configure their projects for ESM
Current Workaround
Users can add "type": "module" to their project's package.json to enable ESM resolution.
Summary
Add support for both ESM and CommonJS module systems to improve compatibility with projects using CommonJS resolution (e.g., tsx with CommonJS projects).
Background
Currently, this package is ESM-only (
"type": "module"). Users with CommonJS projects encounter module resolution errors when trying to import this package.Related: #42, PR #43
Proposed Solution
Implement dual module support following the AWS SDK pattern:
dist-cjs/(CommonJS) anddist-es/(ESM)Alternatives Considered
Current Workaround
Users can add
"type": "module"to their project'spackage.jsonto enable ESM resolution.