diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 932ee14d61dc..877c5a9b0d9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: uses: actions/setup-node@v2-beta # Build Babel on latest node versions - name: Build run: | - BABEL_ENV=production make -j bootstrap + BABEL_ENV=test-legacy make -j bootstrap - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2-beta with: diff --git a/babel.config.js b/babel.config.js index e28869a0f676..f6fb35028752 100644 --- a/babel.config.js +++ b/babel.config.js @@ -17,7 +17,8 @@ module.exports = function (api) { }; const envOpts = Object.assign({}, envOptsNoTargets); - const compileDynamicImport = env === "test" || env === "development"; + const compileDynamicImport = + env === "test" || env === "development" || env === "test-legacy"; let convertESM = true; let ignoreLib = true; @@ -55,6 +56,7 @@ module.exports = function (api) { ); if (env === "rollup") envOpts.targets = { node: nodeVersion }; break; + case "test-legacy": // In test-legacy environment, we build babel on latest node but test on minimum supported legacy versions case "production": // Config during builds before publish. envOpts.targets = { @@ -109,7 +111,7 @@ module.exports = function (api) { "@babel/proposal-object-rest-spread", { useBuiltIns: true, loose: true }, ], - dynamicImportUrlToPath, + compileDynamicImport ? dynamicImportUrlToPath : null, compileDynamicImport ? "@babel/plugin-proposal-dynamic-import" : null, convertESM ? "@babel/transform-modules-commonjs" : null, @@ -170,9 +172,9 @@ module.exports = function (api) { // NOTE: This plugin must run before @babel/plugin-transform-modules-commonjs, // and assumes that the target is the current node version. function dynamicImportUrlToPath({ template, env }) { - const currentNodeSupportsURL = !!require("url").pathToFileURL; - - if (currentNodeSupportsURL && env() !== "production") { + const currentNodeSupportsURL = + !!require("url").pathToFileURL && env() !== "test-legacy"; // test-legacy is run on legacy node versions without pathToFileURL support + if (currentNodeSupportsURL) { return { visitor: { CallExpression(path) {