Skip to content

Support ESM package export #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

re-taro
Copy link

@re-taro re-taro commented Aug 9, 2025

Summary

Add ESM (ECMAScript Module) support alongside existing CommonJS compatibility. This change enables the package to be used with both import and require statements, providing better compatibility with modern JavaScript tooling and environments.

Resolves: #346
Resolves: #347

Changes

  • Package Configuration: Added dual package exports with proper conditional exports for ESM and CommonJS
  • Build System: Implemented custom build script to generate both ESM and CommonJS outputs
  • TypeScript Configuration: Split build configuration into separate files for ESM and CommonJS compilation targets
  • Module Type: Set package type to "module" as the primary format while maintaining CommonJS compatibility

Technical Details

  • ESM output is placed in dist/ directory as the default export
  • CommonJS output is placed in dist/cjs/ directory with its own package.json specifying "type": "commonjs"
  • Build script handles proper package.json generation for distribution
  • Size limits updated to monitor both ESM and CommonJS bundle sizes

Breaking Changes

None. This change maintains full backward compatibility with existing CommonJS consumers while adding ESM support.

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.

v7 and v8 are not tree-shakable Please add ESM export to v8
1 participant