Add yarn-plugin-conditions to update Babel 8 dependencies (#12659)

* Add `yarn-plugin-conditions` to update Babel 8 dependencies

https://github.com/nicolo-ribaudo/yarn-plugin-conditions

* Update .gitattributes
This commit is contained in:
Nicolò Ribaudo 2021-01-22 10:45:03 +01:00 committed by GitHub
parent dc4bace114
commit 2811b535d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 4 deletions

1
.gitattributes vendored
View File

@ -1 +1,2 @@
* text eol=lf
/.yarn/** linguist-vendored

File diff suppressed because one or more lines are too long

View File

@ -7,6 +7,8 @@ nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-babel-release-tool.cjs
spec: "https://raw.githubusercontent.com/nicolo-ribaudo/yarn-plugin-babel-release-tool/main/bundles/%40yarnpkg/plugin-babel-release-tool.js"
- path: .yarn/plugins/@yarnpkg/plugin-conditions.cjs
spec: "https://raw.githubusercontent.com/nicolo-ribaudo/yarn-plugin-conditions/main/bundles/%40yarnpkg/plugin-conditions.js"
releaseTool:
ignoreChanges:
@ -16,11 +18,17 @@ releaseTool:
- "**/test/**"
- codemods/**
- "@(!(native-modules|built-ins|plugins|package)).json"
implicitDependencies:
"@babel/runtime": ["@babel/helpers"]
"@babel/runtime-corejs2": ["@babel/helpers"]
"@babel/runtime-corejs3": ["@babel/helpers"]
"@babel/runtime":
- "@babel/helpers"
"@babel/runtime-corejs2":
- "@babel/helpers"
"@babel/runtime-corejs3":
- "@babel/helpers"
conditions:
BABEL_8_BREAKING:
default: false
unsafeHttpWhitelist:
- localhost

View File

@ -293,6 +293,16 @@ function pluginToggleBabel8Breaking({ types: t }, { breaking }) {
keepConsequent = !keepConsequent;
}
// yarn-plugin-conditions inject bool(process.env.BABEL_8_BREAKING)
// tests, to properly cast the env variable to a boolean.
if (
test.isCallExpression() &&
test.get("callee").isIdentifier({ name: "bool" }) &&
test.get("arguments").length === 1
) {
test = test.get("arguments")[0];
}
if (!test.matchesPattern("process.env.BABEL_8_BREAKING")) return;
path.replaceWith(