-
Notifications
You must be signed in to change notification settings - Fork 19
Description
As Babel explains in their blog post about Babel 8 beta, node.js 20 supports calling require() on ESM modules, so going esm-only shouldn't break any users on version 20+:
Babel 8 will ship as an ESM-only package. We've been trying to figure out how to make this work for very long time, and finally with the require(esm) support shipped in Node.js 20 we are comfortable with not providing a CommonJS alternative.
As someone with experience in this area, I can promise you it is far, far easier to maintain an ESM-only package. The slow death of CommonJS is truly something to celebrate. I tried fixing the failing test in #927 without migrating to ESM, and I could not figure out why I couldn't get built-in fetch working. Even if switching to ESM doesn't fix those problems directly, it will be a much more straightforward environment to debug (though honestly I do expect the issues I was having to go away with ESM).
#923 is already open, but it's incredibly heavy-handed, and I certainly do not fault you for not engaging with it. I wouldn't even know where to begin reviewing it.
I'm planning on submitting a series of PRs to do this, and I'll use this issue as a source of truth and discussion point for the steps to get there. That way each step can easily be reviewed. Even the final diff should be much, much smaller than #923 though (I truly do not know why it changes so many lines). I'm planning to do this work in a fork regardless of whether my PRs get merged or not.
- Update to PNPM 10:
- build: update pnpm #929
- Currently, if you have PNPM 10 installed locally, it will just mostly-silently let you use it, but everything will break because the default settings changed.
- Allow building all packages and running all tests with a single command
- Ensure local deps are up-to-date when testing or running the CLI locally #930
- This is
justto make it easier to verify locally that I haven't broken things for the other steps. - I'm actually pretty sure that the way we were running tests did not ensure that all of the latest code was being tested, so this fixes that as well.
- Update Typescript
- chore: update typescript #931
- Modern Typescript versions have better support for consolidating configuration files (see next step), and have options to support ESM in nicer ways.
- Consolidate Typescript configuration
- build: consolidate tsconfig.json files, build as unified project #932
- The ESM migration will require a lot of typescript configuration changes, and that will be easier to review if I'm only changing one file instead of like 7.
- Update
jest- This will fix access to the built-in
fetchfunction from the tests, which will fix the test that fails on node 24.
- This will fix access to the built-in
- Maybe another step or two? I've written down the stepping stones that came to mind, but I'm probably forgetting something. I'll update this issue as needed.
- Migrate to ESM
- Remove
cross-fetch, bump minimum version inenginesfield to 18 - Release with a bumped major version number