Skip to content

Ship ESM only - #308

Merged
keichi merged 1 commit into
masterfrom
esm-only
Oct 15, 2026
Merged

keichi merged 1 commit into
masterfrom
esm-only

Conversation

@keichi

@keichi keichi commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Node.js 22.12+ (and 20.19+) can require() ES modules without a flag, so the separate CommonJS build is no longer needed.

  • Set "type": "module" and build once with tsc (module: nodenext) into dist/
  • Remove the module field and the require/import conditions in exports
  • Bump engines.node to >=22.12
  • Update README to show import first

This also removes the dual package hazard (two copies of Parser when both formats get loaded) and the types mismatch where the ESM entry used CJS typings.

Verified locally: npm run build, npm test (166 passed), and both require("binary-parser") and import { Parser } from "binary-parser" resolve Parser on Node.

Since engines is raised, this should be released as a major version.

Node.js 22.12+ can require() ES modules, so the separate CommonJS build is
no longer needed. Drop it and the dual package hazard that came with it.
@keichi
keichi merged commit a8937b2 into master Oct 15, 2026
7 checks passed
@keichi
keichi deleted the esm-only branch October 15, 2026 14:25
@keichi keichi mentioned this pull request Oct 15, 2026
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