Skip to content

Commit

Permalink
Update all the @babel/* dependencies (#12897)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Feb 25, 2021
1 parent 0a4dc05 commit 039eb27
Show file tree
Hide file tree
Showing 18 changed files with 715 additions and 739 deletions.
79 changes: 46 additions & 33 deletions babel.config.js
Expand Up @@ -10,23 +10,49 @@ function normalize(src) {
module.exports = function (api) {
const env = api.env();

const sources = ["packages/*/src", "codemods/*/src", "eslint/*/src"];

const includeCoverage = process.env.BABEL_COVERAGE === "true";

const envOptsNoTargets = {
loose: true,
const envOpts = {
shippedProposals: true,
modules: false,
exclude: [
"transform-typeof-symbol",
// We need to enable useBuiltIns
"proposal-object-rest-spread",
// We want to enable it without `loose: true`, since it breaks
// https://github.com/npm/node-semver/blob/093b40f8a7cb67946527b739fe8f8974c888e2a0/classes/range.js#L136
// in our dependencies
"transform-spread",
],
};
const envOpts = Object.assign({}, envOptsNoTargets);

// These are "safe" assumptions, that we can enable globally
const assumptions = {
constantSuper: true,
ignoreFunctionLength: true,
ignoreToPrimitiveHint: true,
mutableTemplateObject: true,
noClassCalls: true,
noDocumentAll: true,
noNewArrows: true,
setClassMethods: true,
setComputedProperties: true,
setSpreadProperties: true,
skipForOfIteratorClosing: true,
superIsCallableConstructor: true,
};

// These are "less safe": we only enable them on our own code
// and not when compiling dependencies.
const sourceAssumptions = {
objectRestNoSymbols: true,
pureGetters: true,
setPublicClassFields: true,
};

const parserAssumptions = {
iterableIsArray: true,
};

let targets = {};
let convertESM = true;
let ignoreLib = true;
let includeRegeneratorRuntime = false;
Expand All @@ -39,11 +65,9 @@ module.exports = function (api) {
// unambiguous to keep things simple until we get around to renaming
// the modules to be more easily distinguished from CommonJS
const unambiguousSources = [
"packages/*/src",
...sources,
"packages/*/test",
"codemods/*/src",
"codemods/*/test",
"eslint/*/src",
"eslint/*/test",
];

Expand All @@ -62,27 +86,20 @@ module.exports = function (api) {
"packages/babel-preset-env/data",
"packages/babel-compat-data"
);
if (env === "rollup") envOpts.targets = { node: nodeVersion };
if (env === "rollup") targets = { node: nodeVersion };
needsPolyfillsForOldNode = true;
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 = {
node: nodeVersion,
};
targets = { node: nodeVersion };
needsPolyfillsForOldNode = true;
break;
case "development":
envOpts.debug = true;
envOpts.targets = {
node: "current",
};
break;
// fall through
case "test":
envOpts.targets = {
node: "current",
};
targets = { node: "current" };
break;
}

Expand All @@ -102,6 +119,9 @@ module.exports = function (api) {
}

const config = {
targets,
assumptions,

// Our dependencies are all standard CommonJS, along with all sorts of
// other random files in Babel's codebase, so we use script as the default,
// and then mark actual modules as modules farther down.
Expand All @@ -126,12 +146,7 @@ module.exports = function (api) {
["@babel/preset-flow", { allowDeclareFields: true }],
],
plugins: [
[
"@babel/proposal-object-rest-spread",
{ useBuiltIns: true, loose: true },
],

env === "standalone" && ["@babel/transform-spread", { loose: false }],
["@babel/proposal-object-rest-spread", { useBuiltIns: true }],

convertESM ? "@babel/proposal-export-namespace-from" : null,
convertESM ? "@babel/transform-modules-commonjs" : null,
Expand All @@ -150,10 +165,8 @@ module.exports = function (api) {
"packages/babel-parser",
"packages/babel-helper-validator-identifier",
].map(normalize),
plugins: [
"babel-plugin-transform-charcodes",
["@babel/transform-for-of", { assumeArray: true }],
],
plugins: ["babel-plugin-transform-charcodes"],
assumptions: parserAssumptions,
},
{
test: ["./packages/babel-cli", "./packages/babel-core"].map(normalize),
Expand All @@ -165,8 +178,8 @@ module.exports = function (api) {
].filter(Boolean),
},
{
test: normalize("./packages/babel-polyfill"),
presets: [["@babel/env", envOptsNoTargets]],
test: sources.map(normalize),
assumptions: sourceAssumptions,
},
{
test: unambiguousSources.map(normalize),
Expand Down
Expand Up @@ -17,7 +17,7 @@
"@babel/plugin"
],
"dependencies": {
"@babel/plugin-syntax-object-rest-spread": "^7.7.4"
"@babel/plugin-syntax-object-rest-spread": "^7.8.3"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
Expand Down
Expand Up @@ -17,7 +17,7 @@
"@babel/plugin"
],
"dependencies": {
"@babel/plugin-syntax-optional-catch-binding": "^7.7.4"
"@babel/plugin-syntax-optional-catch-binding": "^7.8.3"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
Expand Down
24 changes: 11 additions & 13 deletions package.json
Expand Up @@ -18,23 +18,21 @@
"test:runtime:node": "node test/runtime-integration/node.cjs"
},
"devDependencies": {
"@babel/cli": "^7.12.0",
"@babel/core": "^7.12.0",
"@babel/cli": "^7.13.0",
"@babel/core": "^7.13.1",
"@babel/eslint-config-internal": "workspace:*",
"@babel/eslint-parser": "workspace:*",
"@babel/eslint-plugin-development": "workspace:*",
"@babel/eslint-plugin-development-internal": "workspace:*",
"@babel/plugin-proposal-export-namespace-from": "^7.12.1",
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
"@babel/plugin-transform-for-of": "^7.10.4",
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.12.0",
"@babel/plugin-transform-spread": "^7.12.13",
"@babel/preset-env": "^7.12.0",
"@babel/preset-flow": "^7.10.4",
"@babel/preset-typescript": "^7.12.1",
"@babel/register": "^7.12.0",
"@babel/runtime": "^7.12.0",
"@babel/plugin-proposal-export-namespace-from": "^7.12.13",
"@babel/plugin-proposal-object-rest-spread": "^7.13.0",
"@babel/plugin-transform-modules-commonjs": "^7.13.0",
"@babel/plugin-transform-runtime": "^7.13.7",
"@babel/preset-env": "^7.13.5",
"@babel/preset-flow": "^7.12.13",
"@babel/preset-typescript": "^7.13.0",
"@babel/register": "^7.13.0",
"@babel/runtime": "^7.13.7",
"@rollup/plugin-babel": "^5.2.0",
"@rollup/plugin-commonjs": "patch:@rollup/plugin-commonjs@^17.1.0#./.yarn/patches/@rollup__plugin-commonjs.patch",
"@rollup/plugin-json": "^4.1.0",
Expand Down
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"@babel/helper-plugin-utils": "workspace:^7.13.0",
"@babel/helper-remap-async-to-generator": "workspace:^7.13.0",
"@babel/plugin-syntax-async-generators": "^7.8.0"
"@babel/plugin-syntax-async-generators": "^7.8.4"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-proposal-dynamic-import/package.json
Expand Up @@ -17,7 +17,7 @@
],
"dependencies": {
"@babel/helper-plugin-utils": "workspace:^7.12.13",
"@babel/plugin-syntax-dynamic-import": "^7.8.0"
"@babel/plugin-syntax-dynamic-import": "^7.8.3"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-proposal-json-strings/package.json
Expand Up @@ -18,7 +18,7 @@
],
"dependencies": {
"@babel/helper-plugin-utils": "workspace:^7.12.13",
"@babel/plugin-syntax-json-strings": "^7.8.0"
"@babel/plugin-syntax-json-strings": "^7.8.3"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
Expand Down
Expand Up @@ -26,7 +26,7 @@
"@babel/core": "workspace:*",
"@babel/helper-plugin-test-runner": "workspace:*",
"@babel/plugin-proposal-nullish-coalescing-operator": "workspace:*",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.0"
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3"
},
"homepage": "https://babel.dev/docs/en/next/babel-plugin-proposal-logical-assignment-operators"
}
Expand Up @@ -18,7 +18,7 @@
],
"dependencies": {
"@babel/helper-plugin-utils": "workspace:^7.13.0",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.0"
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
Expand Down
Expand Up @@ -18,7 +18,7 @@
],
"dependencies": {
"@babel/helper-plugin-utils": "workspace:^7.13.0",
"@babel/plugin-syntax-object-rest-spread": "^7.8.0",
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
"@babel/plugin-transform-parameters": "workspace:^7.13.0"
},
"peerDependencies": {
Expand Down
Expand Up @@ -18,7 +18,7 @@
],
"dependencies": {
"@babel/helper-plugin-utils": "workspace:^7.12.13",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.0"
"@babel/plugin-syntax-optional-catch-binding": "^7.8.3"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
Expand Down
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"@babel/helper-plugin-utils": "workspace:^7.13.0",
"@babel/helper-skip-transparent-expression-wrappers": "workspace:^7.12.1",
"@babel/plugin-syntax-optional-chaining": "^7.8.0"
"@babel/plugin-syntax-optional-chaining": "^7.8.3"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
Expand Down
Expand Up @@ -27,7 +27,7 @@
"devDependencies": {
"@babel/core": "workspace:*",
"@babel/helper-plugin-test-runner": "workspace:*",
"@babel/plugin-syntax-object-rest-spread": "^7.8.0"
"@babel/plugin-syntax-object-rest-spread": "^7.8.3"
},
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-modules-commonjs"
}
Expand Up @@ -28,7 +28,7 @@
"devDependencies": {
"@babel/core": "workspace:*",
"@babel/helper-plugin-test-runner": "workspace:*",
"@babel/plugin-syntax-dynamic-import": "^7.8.0"
"@babel/plugin-syntax-dynamic-import": "^7.8.3"
},
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-modules-systemjs"
}
18 changes: 9 additions & 9 deletions packages/babel-preset-env/package.json
Expand Up @@ -33,17 +33,17 @@
"@babel/plugin-proposal-optional-chaining": "workspace:^7.13.0",
"@babel/plugin-proposal-private-methods": "workspace:^7.13.0",
"@babel/plugin-proposal-unicode-property-regex": "workspace:^7.12.13",
"@babel/plugin-syntax-async-generators": "^7.8.0",
"@babel/plugin-syntax-async-generators": "^7.8.4",
"@babel/plugin-syntax-class-properties": "workspace:^7.12.13",
"@babel/plugin-syntax-dynamic-import": "^7.8.0",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-export-namespace-from": "^7.8.3",
"@babel/plugin-syntax-json-strings": "^7.8.0",
"@babel/plugin-syntax-json-strings": "^7.8.3",
"@babel/plugin-syntax-logical-assignment-operators": "^7.10.4",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.0",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",
"@babel/plugin-syntax-numeric-separator": "^7.10.4",
"@babel/plugin-syntax-object-rest-spread": "^7.8.0",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.0",
"@babel/plugin-syntax-optional-chaining": "^7.8.0",
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.3",
"@babel/plugin-syntax-optional-chaining": "^7.8.3",
"@babel/plugin-syntax-top-level-await": "workspace:^7.12.13",
"@babel/plugin-transform-arrow-functions": "workspace:^7.13.0",
"@babel/plugin-transform-async-to-generator": "workspace:^7.13.0",
Expand Down Expand Up @@ -77,7 +77,7 @@
"@babel/plugin-transform-typeof-symbol": "workspace:^7.12.13",
"@babel/plugin-transform-unicode-escapes": "workspace:^7.12.13",
"@babel/plugin-transform-unicode-regex": "workspace:^7.12.13",
"@babel/preset-modules": "^0.1.3",
"@babel/preset-modules": "^0.1.4",
"@babel/types": "workspace:^7.13.0",
"babel-plugin-polyfill-corejs2": "^0.1.4",
"babel-plugin-polyfill-corejs3": "^0.1.3",
Expand All @@ -91,6 +91,6 @@
"devDependencies": {
"@babel/core": "workspace:*",
"@babel/helper-plugin-test-runner": "workspace:*",
"@babel/plugin-syntax-dynamic-import": "^7.2.0"
"@babel/plugin-syntax-dynamic-import": "^7.8.3"
}
}
6 changes: 3 additions & 3 deletions packages/babel-standalone/package.json
Expand Up @@ -32,7 +32,7 @@
"@babel/plugin-proposal-private-property-in-object": "workspace:*",
"@babel/plugin-proposal-throw-expressions": "workspace:*",
"@babel/plugin-proposal-unicode-property-regex": "workspace:*",
"@babel/plugin-syntax-async-generators": "^7.8.0",
"@babel/plugin-syntax-async-generators": "^7.8.4",
"@babel/plugin-syntax-class-properties": "workspace:*",
"@babel/plugin-syntax-class-static-block": "workspace:*",
"@babel/plugin-syntax-decimal": "workspace:*",
Expand All @@ -46,8 +46,8 @@
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/plugin-syntax-jsx": "workspace:*",
"@babel/plugin-syntax-module-blocks": "workspace:*",
"@babel/plugin-syntax-object-rest-spread": "^7.8.0",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.0",
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.3",
"@babel/plugin-syntax-pipeline-operator": "workspace:*",
"@babel/plugin-syntax-record-and-tuple": "workspace:*",
"@babel/plugin-syntax-top-level-await": "workspace:*",
Expand Down
12 changes: 12 additions & 0 deletions scripts/integration-tests/e2e-babel-old-version.sh
Expand Up @@ -43,6 +43,18 @@ node "$PWD"/scripts/integration-tests/utils/bump-babel-dependencies.js
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2));
"

# Older @babel/core versions don't support "targets" and "assumptions"
# Let's just remove them when running this e2e test.
node -e "
var config = fs.readFileSync('./babel.config.js', 'utf8')
.replace(/assumptions,/, '')
.replace(/targets,/g, '')
.replace(/assumptions,/g, '')
.replace(/assumptions:[^,]*,/g, '')
.replace(/(?<=envOpts\s+=\s+\{)/, 'targets: { node: \'6.9\' },');
fs.writeFileSync('./babel.config.js', config);
"

# https://github.com/babel/babel/pull/12331 - This test is fixed in @babel/traverse 7.12.7,
# so it will fail with older versions. We can disable it.
(cd packages/babel-plugin-transform-modules-systemjs/test/fixtures/regression/; mv issue-12329 .issue-12329)
Expand Down

0 comments on commit 039eb27

Please sign in to comment.