Since we are now only building Babel on Node.js 14 (even if we still test it on Node.js 6), we can use native ECMAScript modules for the build scripts:
There are a bunch of scripts/tests in the
scriptsfolder: they can probably all be rewritten to ES modules.
We can probably add
"type": "module"to the top-level
package.json, renaming config files (such as
.cjs. Note that we cannot use ES modules for
jest.config.js, because those two files are used to run tests on Node.js 6.
babel-types/scriptscan be rewritten to ES modules. These files should be renamed to
.mjs, to keep the dist
@babel/typesfiles with the
.jsextension (they are CJS modules).
Please note that
babel-types/scripts depends on the top-level scripts, so
babel-types/scripts must be converted first (it cannot synchronously import an ESM file while still being CJS).
In order to test if your changes are still ok, running
yarn (only when you clone the repo) and
make build && yarn jest should be enough.