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.
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+: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.
justto make it easier to verify locally that I haven't broken things for the other steps.jestfetchfunction from the tests, which will fix the test that fails on node 24.cross-fetch, bump minimum version inenginesfield to 18