Skip to content

Comments

refactor!: Convert to ESM package#1027

Merged
avaly merged 2 commits intomainfrom
refactor/esm-package
Jan 27, 2026
Merged

refactor!: Convert to ESM package#1027
avaly merged 2 commits intomainfrom
refactor/esm-package

Conversation

@avaly
Copy link
Collaborator

@avaly avaly commented Jan 22, 2026

BREAKING CHANGE: Published as an ESM package. Requires node.js >=22.12.0.

Since 2024 the require(esm) feature has been enabled by default in the most recent node.js LTS versions. We can now safely ship only ESM sources in our NPM package without breaking any consumers.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR converts the package from a dual ESM/CommonJS distribution to an ESM-only package, leveraging Node.js's require(esm) feature introduced in recent LTS versions (20.19.0+ and 22.12.0+).

Changes:

  • Removed CommonJS build output and configuration, keeping only ESM distribution
  • Updated all TypeScript source files to use explicit .ts extensions in import statements
  • Separated type-only imports using import type syntax for better ESM compatibility
  • Updated TypeScript compiler configurations to use nodenext module resolution and modern ESM features

Reviewed changes

Copilot reviewed 29 out of 30 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
package.json Updated Node.js engine requirements to require modern LTS versions; removed CJS exports and main entry point; simplified build script
tsconfig.json Added ESM-specific compiler options including allowImportingTsExtensions, rewriteRelativeImportExtensions, and verbatimModuleSyntax; updated to use nodenext module resolution
tsconfig-esm.json Updated module and target to use lowercase nodenext and esnext for consistency
tsconfig-cjs.json Deleted as CJS builds are no longer generated
tests/ts/tsconfig.json Updated target to es2023 and module casing to lowercase
src/**/*.ts Added .ts extensions to all relative imports; separated type-only imports using import type; removed obsolete eslint disable comments
src/tests/**/*.test.ts Updated imports to use .ts extensions and separated type-only imports
example/**/*.ts Updated all example imports to use .ts extensions
build.sh Removed as the build process is now a simple TypeScript compilation without post-processing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

BREAKING CHANGE: Published as an ESM package. Requires node.js >=22.12.0.
@avaly avaly force-pushed the refactor/esm-package branch from ca47f8d to 4fbb048 Compare January 26, 2026 03:03
@avaly avaly merged commit 097d254 into main Jan 27, 2026
15 checks passed
@avaly avaly deleted the refactor/esm-package branch January 27, 2026 06:56
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.

3 participants