Skip to content

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.

@re-taro
Copy link
Author

re-taro commented Aug 17, 2025

@blakeembrey @bjohansebas

Please let me know your thoughts at your earliest convenience.

@UlisesGascon
Copy link
Member

@re-taro there is a policy in the oven regarding ESM expressjs/discussions#323. I hope that this can give you additional context 👍

@blakeembrey
Copy link
Member

Unfortunately, as mentioned in the issues you linked to, this won't land until there's a new major. I don't believe this is backward compatible because anyone it will change the imports for anyone using ESM to import from CommonJS today.

@re-taro re-taro deleted the feat/esm branch September 15, 2025 10:00
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

3 participants