refactor: remove CommonJS build#609
Draft
wojtekmaj wants to merge 2 commits into
Draft
Conversation
wojtekmaj
force-pushed
the
remove-cjs-build
branch
from
July 3, 2026 07:25
4a53388 to
c617d53
Compare
Member
|
hey @wojtekmaj thanks for sharing that! I need to think about this a bit more. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is stacked on #608, so the diff currently includes that PR until it lands.
node-cron already requires Node 20+, and v5 is the right time to consider whether keeping a separate CommonJS build is still worth it. Node 20.19.0 enabled
require(esm)by default, so CommonJS consumers on the supported runtime can load the same ESM entry instead of needing a second build artifact.This removes the CJS build and points the package at the ESM output only:
To keep that technically accurate, the Node engine floor moves from
>=20to>=20.19.0, which is the Node 20 release whererequire(esm)stopped requiring--experimental-require-module. Reference: https://nodejs.org/en/blog/release/v20.19.0The package-size impact is meaningful. Measured with
npm pack --dry-run --jsonon clean temp copies:That is 25,420 fewer packed bytes (40.5% smaller) and 158,185 fewer unpacked bytes (48.3% smaller).
The deleted output is the duplicated CJS surface:
node-cron.cjs,daemon.cjs,_shared.cjs, their sourcemaps, and the CJS-only declaration file from #608. It also removes the Rollup replace plugin that only existed to rewrite ESM-specific paths for the CJS build.Checked with:
I also smoke-tested the packed package with both import styles on a Node runtime where
process.features.require_module === true:And typed CommonJS consumption in TypeScript
nodenextmode: