From 241e466c2f04541355a983d00d79c9e514f9f060 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Wed, 14 Sep 2022 12:18:07 +0800 Subject: [PATCH 1/6] fix --- .../windows/classic-runtime-windows/output.js | 8 +-- .../complex-options-babel-7}/input.js | 0 .../complex-options-babel-7/options.json | 25 +++++++++ .../complex-options-babel-7}/output.js | 0 .../absoluteRuntime/complex-options/input.js | 9 ++++ .../complex-options}/options.json | 3 +- .../absoluteRuntime/complex-options/output.js | 54 +++++++++++++++++++ .../fixtures/absoluteRuntime/options.json | 1 - .../test/fixtures/windows/options.json | 3 -- packages/babel-preset-react/test/index.js | 2 +- 10 files changed, 95 insertions(+), 10 deletions(-) rename packages/babel-plugin-transform-runtime/test/fixtures/{windows/absoluteRuntime => absoluteRuntime/complex-options-babel-7}/input.js (100%) create mode 100644 packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options-babel-7/options.json rename packages/babel-plugin-transform-runtime/test/fixtures/{windows/absoluteRuntime => absoluteRuntime/complex-options-babel-7}/output.js (100%) create mode 100644 packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options/input.js rename packages/babel-plugin-transform-runtime/test/fixtures/{windows/absoluteRuntime => absoluteRuntime/complex-options}/options.json (91%) create mode 100644 packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options/output.js delete mode 100644 packages/babel-plugin-transform-runtime/test/fixtures/windows/options.json diff --git a/packages/babel-plugin-transform-react-jsx-development/test/fixtures/windows/classic-runtime-windows/output.js b/packages/babel-plugin-transform-react-jsx-development/test/fixtures/windows/classic-runtime-windows/output.js index 07220e9b9ba0..496139ece4e8 100644 --- a/packages/babel-plugin-transform-react-jsx-development/test/fixtures/windows/classic-runtime-windows/output.js +++ b/packages/babel-plugin-transform-react-jsx-development/test/fixtures/windows/classic-runtime-windows/output.js @@ -12,7 +12,7 @@ var x = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/Reac __source: { fileName: _jsxFileName, lineNumber: 4, - columnNumber: 9 + columnNumber: 7 } }), /*#__PURE__*/React.createElement("div", { key: "2", @@ -21,7 +21,7 @@ var x = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/Reac __source: { fileName: _jsxFileName, lineNumber: 5, - columnNumber: 9 + columnNumber: 7 } }), /*#__PURE__*/React.createElement("div", { key: "3", @@ -29,7 +29,7 @@ var x = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/Reac __source: { fileName: _jsxFileName, lineNumber: 6, - columnNumber: 9 + columnNumber: 7 } }), /*#__PURE__*/React.createElement("div", { ...props, key: "4", @@ -37,6 +37,6 @@ var x = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/Reac __source: { fileName: _jsxFileName, lineNumber: 7, - columnNumber: 9 + columnNumber: 7 } }))); diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/windows/absoluteRuntime/input.js b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options-babel-7/input.js similarity index 100% rename from packages/babel-plugin-transform-runtime/test/fixtures/windows/absoluteRuntime/input.js rename to packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options-babel-7/input.js diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options-babel-7/options.json b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options-babel-7/options.json new file mode 100644 index 000000000000..49246aaa7fdd --- /dev/null +++ b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options-babel-7/options.json @@ -0,0 +1,25 @@ +{ + "externalHelpers": false, + "presets": [ + [ + "env", + { + "corejs": 3, + "useBuiltIns": "entry" + } + ] + ], + "plugins": [ + [ + "transform-runtime", + { + "regenerator": false, + "corejs": false, + "helpers": true, + "useESModules": true, + "absoluteRuntime": true + } + ] + ], + "BABEL_8_BREAKING": false +} diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/windows/absoluteRuntime/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options-babel-7/output.js similarity index 100% rename from packages/babel-plugin-transform-runtime/test/fixtures/windows/absoluteRuntime/output.js rename to packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options-babel-7/output.js diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options/input.js b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options/input.js new file mode 100644 index 000000000000..42f8907ec4c7 --- /dev/null +++ b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options/input.js @@ -0,0 +1,9 @@ +async function test () { + console.log('test') +} + +async function main () { + console.log(await test()) +} + +main() diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/windows/absoluteRuntime/options.json b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options/options.json similarity index 91% rename from packages/babel-plugin-transform-runtime/test/fixtures/windows/absoluteRuntime/options.json rename to packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options/options.json index bed956656cb8..66a42994c5ef 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/windows/absoluteRuntime/options.json +++ b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options/options.json @@ -20,5 +20,6 @@ "absoluteRuntime": true } ] - ] + ], + "BABEL_8_BREAKING": true } diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options/output.js new file mode 100644 index 000000000000..466aea31c34e --- /dev/null +++ b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/complex-options/output.js @@ -0,0 +1,54 @@ +var _asyncToGenerator = require("/packages/babel-runtime/helpers/asyncToGenerator.js")["default"]; + +function test() { + return _test.apply(this, arguments); +} + +function _test() { + _test = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + console.log('test'); + + case 1: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + return _test.apply(this, arguments); +} + +function main() { + return _main.apply(this, arguments); +} + +function _main() { + _main = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + _context2.t0 = console; + _context2.next = 3; + return test(); + + case 3: + _context2.t1 = _context2.sent; + + _context2.t0.log.call(_context2.t0, _context2.t1); + + case 5: + case "end": + return _context2.stop(); + } + } + }, _callee2); + })); + return _main.apply(this, arguments); +} + +main(); diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/options.json b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/options.json index a7767c84c102..5d7aba56251d 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/options.json +++ b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/options.json @@ -1,5 +1,4 @@ { "externalHelpers": false, - "os": ["linux", "darwin"], "targets": { "browsers": "ie 6, ios 4" } } diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/windows/options.json b/packages/babel-plugin-transform-runtime/test/fixtures/windows/options.json deleted file mode 100644 index 2163a20634fe..000000000000 --- a/packages/babel-plugin-transform-runtime/test/fixtures/windows/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "os": ["win32"] -} diff --git a/packages/babel-preset-react/test/index.js b/packages/babel-preset-react/test/index.js index 06cd224090be..b7f5de752320 100644 --- a/packages/babel-preset-react/test/index.js +++ b/packages/babel-preset-react/test/index.js @@ -1,5 +1,5 @@ import _reactPreset from "../lib/index.js"; -const reactPreset = _reactPreset.default; +const reactPreset = _reactPreset.default || _reactPreset; describe("react preset", () => { it("does throw clear error when no options passed for Babel 6", () => { From 5421cf0155f5bf0f14b427e5bfb84105ae6eb2da Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Wed, 14 Sep 2022 15:33:23 +0800 Subject: [PATCH 2/6] test --- .github/workflows/ci.yml | 71 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0944a428714b..717028eb27b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -234,10 +234,13 @@ jobs: with: node-version: "*" - test-babel-8-breaking: - name: Test Babel 8 breaking changes + build-babel8: + name: Build Babel 8 Artifacts for tests needs: prepare-yarn-cache runs-on: ubuntu-latest + # Yarn PnP does not support native ESM yet (https://github.com/yarnpkg/berry/issues/638) + # env: + # YARN_NODE_LINKER: pnp # use pnp linker for better linking performance and stricter checks steps: - name: Checkout code uses: actions/checkout@v3 @@ -258,6 +261,67 @@ jobs: BABEL_ENV: test BABEL_8_BREAKING: true BABEL_TYPES_8_BREAKING: true + - uses: actions/upload-artifact@v3 + with: + name: babel8-test-artifact + path: | + codemods/*/lib/**/* + eslint/*/lib/**/* + packages/*/lib/**/* + packages/babel-standalone/*.js + !**/node_modules/** + + test-babel-8-breaking: + name: Test Babel 8 breaking changes + needs: build-babel8 + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Use Node.js 14.17 + uses: actions/setup-node@v3 + with: + node-version: "14.17" # Node.js 14.17 is the first LTS supported by Babel 8 + cache: "yarn" + - name: Install + run: | + yarn install + - uses: actions/download-artifact@v3 + with: + name: babel8-test-artifact + - name: Generate runtime helpers + run: make build-plugin-transform-runtime-dist + - name: Test + # Hack: --color has supports-color@5 returned true for GitHub CI + # Remove once `chalk` is bumped to 4.0. + run: | + yarn jest --ci --color + yarn test:esm + env: + BABEL_ENV: test + BABEL_8_BREAKING: true + BABEL_TYPES_8_BREAKING: true + + test-babel8-windows: + name: Test Babel 8 breaking changes on Windows + needs: build-babel8 + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Use Node.js 14.17 + uses: actions/setup-node@v3 + with: + node-version: "14.17" # Node.js 14.17 is the first LTS supported by Babel 8 + cache: "yarn" + - name: Install + run: | + yarn install + - uses: actions/download-artifact@v3 + with: + name: babel8-test-artifact + - name: Generate runtime helpers + run: make build-plugin-transform-runtime-dist - name: Test # Hack: --color has supports-color@5 returned true for GitHub CI # Remove once `chalk` is bumped to 4.0. @@ -287,8 +351,7 @@ jobs: with: name: babel-artifact - name: Generate runtime helpers - run: | - make build-plugin-transform-runtime-dist + run: make build-plugin-transform-runtime-dist - name: Test on Windows # Hack: --color has supports-color@5 returned true for GitHub CI # Remove once `chalk` is bumped to 4.0. From 78f1c45c39f20fa40c2894b8d50aa159e744bafe Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Wed, 14 Sep 2022 16:27:21 +0800 Subject: [PATCH 3/6] remove babel7 deps --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 717028eb27b6..9ece5f22eff3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -284,8 +284,7 @@ jobs: node-version: "14.17" # Node.js 14.17 is the first LTS supported by Babel 8 cache: "yarn" - name: Install - run: | - yarn install + run: yarn install - uses: actions/download-artifact@v3 with: name: babel8-test-artifact @@ -294,7 +293,9 @@ jobs: - name: Test # Hack: --color has supports-color@5 returned true for GitHub CI # Remove once `chalk` is bumped to 4.0. + # Remove babel7 deps https://github.com/babel/babel/pull/14928#issuecomment-1246375719 run: | + find . -type d -path "*/node_modules/*-BABEL_8_BREAKING-false" -exec rm -rf {} + yarn jest --ci --color yarn test:esm env: From 00b238c975054904ce60f068877aacfb681b97e0 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Wed, 14 Sep 2022 18:03:49 +0800 Subject: [PATCH 4/6] Revert "remove babel7 deps" This reverts commit 78f1c45c39f20fa40c2894b8d50aa159e744bafe. --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ece5f22eff3..717028eb27b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -284,7 +284,8 @@ jobs: node-version: "14.17" # Node.js 14.17 is the first LTS supported by Babel 8 cache: "yarn" - name: Install - run: yarn install + run: | + yarn install - uses: actions/download-artifact@v3 with: name: babel8-test-artifact @@ -293,9 +294,7 @@ jobs: - name: Test # Hack: --color has supports-color@5 returned true for GitHub CI # Remove once `chalk` is bumped to 4.0. - # Remove babel7 deps https://github.com/babel/babel/pull/14928#issuecomment-1246375719 run: | - find . -type d -path "*/node_modules/*-BABEL_8_BREAKING-false" -exec rm -rf {} + yarn jest --ci --color yarn test:esm env: From 8e6e1eaa1086ec416a7cbbf82d45c57b404d974e Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Wed, 14 Sep 2022 22:05:31 +0800 Subject: [PATCH 5/6] Update .github/workflows/ci.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Huáng Jùnliàng --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 717028eb27b6..645ca0d83c17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -274,7 +274,10 @@ jobs: test-babel-8-breaking: name: Test Babel 8 breaking changes needs: build-babel8 - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - name: Checkout code uses: actions/checkout@v3 From 176aac49fa1b720f9121837533003b6269b19a64 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Wed, 14 Sep 2022 22:12:41 +0800 Subject: [PATCH 6/6] update --- .github/workflows/ci.yml | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 645ca0d83c17..a183cbf335e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -272,7 +272,7 @@ jobs: !**/node_modules/** test-babel-8-breaking: - name: Test Babel 8 breaking changes + name: Test Babel 8 breaking changes on Node.js needs: build-babel8 strategy: matrix: @@ -305,37 +305,6 @@ jobs: BABEL_8_BREAKING: true BABEL_TYPES_8_BREAKING: true - test-babel8-windows: - name: Test Babel 8 breaking changes on Windows - needs: build-babel8 - runs-on: windows-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Use Node.js 14.17 - uses: actions/setup-node@v3 - with: - node-version: "14.17" # Node.js 14.17 is the first LTS supported by Babel 8 - cache: "yarn" - - name: Install - run: | - yarn install - - uses: actions/download-artifact@v3 - with: - name: babel8-test-artifact - - name: Generate runtime helpers - run: make build-plugin-transform-runtime-dist - - name: Test - # Hack: --color has supports-color@5 returned true for GitHub CI - # Remove once `chalk` is bumped to 4.0. - run: | - yarn jest --ci --color - yarn test:esm - env: - BABEL_ENV: test - BABEL_8_BREAKING: true - BABEL_TYPES_8_BREAKING: true - test-windows: name: Test on Windows needs: build