Enable PnP linker on CI build job (#12011)

* chore: use pnp when building babel artifacts

* chore: refine ci config

* fix: match any n_m as unambiguous

The pnp module path starts from global cache path, which does not
match **/n_m

* fix: remove dedupe option and abort rollup on unexpected warning messages

* chore: suppress Circular_Dependency warning

* fix build error

* replace make bootstrap-only by yarn install
This commit is contained in:
Huáng Jùnliàng 2020-12-18 19:00:43 -05:00 committed by GitHub
parent b9deeb458b
commit d28c1e52d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 10 deletions

View File

@ -30,7 +30,7 @@ jobs:
- name: Check or update Yarn cache - name: Check or update Yarn cache
env: env:
YARN_ENABLE_SCRIPTS: false # disable post-install scripts YARN_ENABLE_SCRIPTS: false # disable post-install scripts
YARN_NODE_LINKER: pnp # use pnp linker for better performance: it's meant to update yarn cache only YARN_NODE_LINKER: pnp # use pnp linker for better linking performance: it's meant to update yarn cache only
run: | run: |
yarn install --immutable --skip-builds yarn install --immutable --skip-builds
@ -65,6 +65,8 @@ jobs:
name: Build Babel Artifacts name: Build Babel Artifacts
needs: prepare-yarn-cache needs: prepare-yarn-cache
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
YARN_NODE_LINKER: pnp # use pnp linker for better linking performance and stricter checks
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -132,7 +134,7 @@ jobs:
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Use Node.js latest - name: Use Node.js latest # Run yarn on latest node
uses: actions/setup-node@v2-beta uses: actions/setup-node@v2-beta
with: with:
node-version: "*" # Build Babel on latest node LTS versions node-version: "*" # Build Babel on latest node LTS versions
@ -145,7 +147,7 @@ jobs:
key: yarn-${{ hashFiles('yarn.lock') }} key: yarn-${{ hashFiles('yarn.lock') }}
- name: Install - name: Install
run: | run: |
BABEL_ENV=test-legacy make -j bootstrap-only yarn install
- name: Downgrade Jest for node <= 8 - name: Downgrade Jest for node <= 8
if: matrix.node-version == '6' || matrix.node-version == '8' if: matrix.node-version == '6' || matrix.node-version == '8'
run: | run: |
@ -159,13 +161,15 @@ jobs:
- name: Generate runtime helpers - name: Generate runtime helpers
run: | run: |
make build-plugin-transform-runtime-dist make build-plugin-transform-runtime-dist
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }} # Checkout node version for test executor
uses: actions/setup-node@v2-beta uses: actions/setup-node@v2-beta
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- name: Test on node.js ${{ matrix.node-version }} - name: Test on node.js ${{ matrix.node-version }}
# Hack: --color has supports-color@5 returned true for GitHub CI # Hack: --color has supports-color@5 returned true for GitHub CI
# Remove once `chalk` is bumped to 4.0. # Remove once `chalk` is bumped to 4.0.
# Todo(Babel 8): Jest execution path is hardcoded because Yarn 2 does not support node 6
run: | run: |
BABEL_ENV=test node ./node_modules/.bin/jest --ci --color BABEL_ENV=test node ./node_modules/.bin/jest --ci --color

View File

@ -239,6 +239,13 @@ function buildRollup(packages, targetBrowsers) {
const bundle = await rollup.rollup({ const bundle = await rollup.rollup({
input, input,
external, external,
onwarn(warning, warn) {
if (warning.code !== "CIRCULAR_DEPENDENCY") {
warn(warning);
// https://github.com/babel/babel/pull/12011#discussion_r540434534
throw new Error("Rollup aborted due to warnings above");
}
},
plugins: [ plugins: [
rollupBabelSource(), rollupBabelSource(),
rollupReplace({ rollupReplace({
@ -257,10 +264,6 @@ function buildRollup(packages, targetBrowsers) {
extensions: [".mjs", ".cjs", ".ts", ".js", ".json"], extensions: [".mjs", ".cjs", ".ts", ".js", ".json"],
browser: nodeResolveBrowser, browser: nodeResolveBrowser,
preferBuiltins: true, preferBuiltins: true,
//todo: remove when semver and source-map are bumped to latest versions
dedupe(importee) {
return ["semver", "source-map"].includes(importee);
},
}), }),
rollupCommonJs({ rollupCommonJs({
include: [ include: [

View File

@ -49,7 +49,7 @@ module.exports = function (api) {
ignoreLib = false; ignoreLib = false;
// rollup-commonjs will converts node_modules to ESM // rollup-commonjs will converts node_modules to ESM
unambiguousSources.push( unambiguousSources.push(
"**/node_modules", "/**/node_modules",
"packages/babel-preset-env/data", "packages/babel-preset-env/data",
"packages/babel-compat-data" "packages/babel-compat-data"
); );

View File

@ -57,6 +57,7 @@
"jest": "^26.6.1", "jest": "^26.6.1",
"lerna-changelog": "^0.5.0", "lerna-changelog": "^0.5.0",
"lint-staged": "^9.2.0", "lint-staged": "^9.2.0",
"lodash": "^4.17.20",
"mergeiterator": "^1.2.5", "mergeiterator": "^1.2.5",
"prettier": "^2.0.5", "prettier": "^2.0.5",
"rollup": "^2.26.5", "rollup": "^2.26.5",

View File

@ -4851,6 +4851,7 @@ __metadata:
jest: ^26.6.1 jest: ^26.6.1
lerna-changelog: ^0.5.0 lerna-changelog: ^0.5.0
lint-staged: ^9.2.0 lint-staged: ^9.2.0
lodash: ^4.17.20
mergeiterator: ^1.2.5 mergeiterator: ^1.2.5
prettier: ^2.0.5 prettier: ^2.0.5
rollup: ^2.26.5 rollup: ^2.26.5
@ -9693,7 +9694,7 @@ fsevents@^1.2.7:
languageName: node languageName: node
linkType: hard linkType: hard
"lodash@npm:^4.17.14, lodash@npm:^4.17.15, lodash@npm:^4.17.19": "lodash@npm:^4.17.14, lodash@npm:^4.17.15, lodash@npm:^4.17.19, lodash@npm:^4.17.20":
version: 4.17.20 version: 4.17.20
resolution: "lodash@npm:4.17.20" resolution: "lodash@npm:4.17.20"
checksum: c62101d2500c383b5f174a7e9e6fe8098149ddd6e9ccfa85f36d4789446195f5c4afd3cfba433026bcaf3da271256566b04a2bf2618e5a39f6e67f8c12030cb6 checksum: c62101d2500c383b5f174a7e9e6fe8098149ddd6e9ccfa85f36d4789446195f5c4afd3cfba433026bcaf3da271256566b04a2bf2618e5a39f6e67f8c12030cb6