Skip to content

chore: migrate from CJS to ESM#456

Merged
lwasser merged 12 commits intoall-contributors:mainfrom
JoshuaKGoldberg:cjs-to-esm-2
Feb 27, 2026
Merged

chore: migrate from CJS to ESM#456
lwasser merged 12 commits intoall-contributors:mainfrom
JoshuaKGoldberg:cjs-to-esm-2

Conversation

@JoshuaKGoldberg
Copy link
Copy Markdown
Contributor

@JoshuaKGoldberg JoshuaKGoldberg commented Feb 24, 2026

What:

Switches CommonJS (CJS) module.exports = and require() syntax to ECMAScript Modules (ESM) export ... and import ....

Fixes #435

Why:

ESM is the new standard for Node.js and other JavaScript application modules. It's a more precisely defined syntax that works better with tooling.

How:

  • package.json now has "type": "module", to change files to ESM by default
  • All CJS syntax in .js files is migrated to the equivalent ESM
    • I tried to avoid default exports and imports in favor of explicitly named ones
    • A few functions had to be renamed to resolve ambiguities

I verified these changes by running commands like node dist/cli.js add joshuakgoldberg code locally.

Checklist:

  • Documentation: N/A
  • Tests
  • Ready to be merged: no, someone who's been working more deeply in the code should take a deep dive
  • Added myself to contributors table: N/A / already there

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review February 25, 2026 04:40
Copy link
Copy Markdown
Contributor

@jdalrymple jdalrymple left a comment

Choose a reason for hiding this comment

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

I've read through it a few times, nothing seems off to me. I had to brush up on some of the babel config docs, but looks good!

@jdalrymple
Copy link
Copy Markdown
Contributor

Ran it locally as well, looks good!

Copy link
Copy Markdown
Member

@lwasser lwasser left a comment

Choose a reason for hiding this comment

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

@JoshuaKGoldberg this looks great to me! I had to look up the add variable to ensure it wasn't a protected word / builtin function i'm so used to that in python. But this all looks great and i like the inline exports too!! Let's merge this given @jdalrymple already gave it a solid review and test and I just combed through the code as well. THANK YOU so much for this. It should unblock a lot of work around testing!! 🚀

@lwasser lwasser merged commit 8b11060 into all-contributors:main Feb 27, 2026
5 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the cjs-to-esm-2 branch February 28, 2026 20:02
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.

🛠️ Tooling: Switch from CJS to ESM

3 participants