Skip to content

Conversation

@broofa
Copy link
Member

@broofa broofa commented Jun 20, 2025

PR showing what happens if we drop CommonJS support.

Briefly:

  • Update README verbiage. (Note: fixes minor bug in runmd setup, causing UUIDs to change)
  • Switch examples/browser-rollup config from CJS -> ESM
  • Drop CJS test from examples/browser-webpack
  • Drop examples/node-commonjs
  • Switch examples/node-jest from CJS -> ESM. (Requires upgrading to jest@30)
  • Remove CJS logic from build.sh
    • Also change from four dist subdirs - "dist/[ esm | esm-browser | cjs | cjs-browser ]" - to just "dist" and "dist-browser"
  • (cleanup) Only bundle one set of TS types (in the "dist" dir)
    • types field to explicitly point to "dist/index.d.ts"
  • Simplify package.json fields (fwiw, this is motivated by how @sindresorhus appears to be structuring package.json for his 100's of popular ESM-only packages.)
    • Remove main field (only used for CJS entry points)
    • Remove module field (it was never a standard and has been replaced by "exports")
    • In exports, remove import and require instead specify default (esm) and browser (esm-browser)
  • Replace the 4 tsconfig.* files we'd been using to handle the multiple TS configs for ESM & CJS with a single tsconfig.json file for the ESM config.

The net effect of the above:

  • Source files deleted: 8
  • Source lines of code deleted: 271
  • Installed package file size: 788K -> 312K
  • Installed package file count: 197 -> 77

Closes #881

@broofa broofa force-pushed the rm_cjs branch 3 times, most recently from 2b1b03f to 7be1146 Compare June 20, 2025 17:54
@broofa broofa changed the base branch from main to drop_node_16 June 20, 2025 22:51
@broofa broofa marked this pull request as ready for review June 20, 2025 23:35
Copy link
Member

@LinusU LinusU left a comment

Choose a reason for hiding this comment

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

Nice cleanup 🤩

@broofa broofa added this to the v12 milestone Jun 24, 2025
@broofa broofa merged commit d4ecdab into drop_node_16 Jun 28, 2025
12 checks passed
@broofa broofa deleted the rm_cjs branch June 28, 2025 20:35
@43081j
Copy link

43081j commented Jul 17, 2025

@broofa is there a plan to release this soon? 👀

@broofa
Copy link
Member Author

broofa commented Jul 17, 2025

@43081j 12.x will go out at the end of next month to allow for updating to TS 5.2 at the same time.. See #887

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.

Drop CommonJS Support

4 participants