Use native ESM for dev scripts
See original GitHub issueSince 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:
-
Top-level scripts There are a bunch of scripts/tests in the
scripts
folder: they can probably all be rewritten to ES modules. We can probably add"type": "module"
to the top-levelpackage.json
, renaming config files (such as.eslintrc.js
) to.cjs
. Note that we cannot use ES modules forbabel.config.js
andjest.config.js
, because those two files are used to run tests on Node.js 6. -
babel-types/scripts
can be rewritten to ES modules. These files should be renamed to.mjs
, to keep the dist@babel/types
files with the.js
extension (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.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10 (10 by maintainers)
Note that we should also bump building requirements to
^12.16 || >= 14
in https://github.com/babel/babel/blob/main/CONTRIBUTING.md#developingWe can also update gulp to 4.2.0 which supports
.mjs
config.@nicolo-ribaudo Yes, I was stuck on an error. Could use some help definitely. Let me create a draft PR so all can have a look.