Skip to content

Commit e52356a

Browse files
[breaking] Use Babel 8 (#257)
1 parent bac4f17 commit e52356a

314 files changed

Lines changed: 2278 additions & 1319 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,43 @@ jobs:
7676
- name: Test the esm build
7777
run: yarn test:esm
7878

79+
test-babel7:
80+
name: Test with Babel 7
81+
needs: prepare-yarn-cache
82+
runs-on: ubuntu-latest
83+
steps:
84+
- name: Checkout code
85+
uses: actions/checkout@v3
86+
- name: Use Node.js latest
87+
uses: actions/setup-node@v3
88+
with:
89+
cache: "yarn"
90+
- name: Install
91+
run: yarn install
92+
- name: Build
93+
run: yarn build
94+
env:
95+
BABEL_ENV: production
96+
- name: Downgrade to Babel 7
97+
run: |
98+
node scripts/downgrade-babel-to-v7.mjs
99+
YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
100+
- name: Delete tests that import .ts files
101+
run: rm packages/babel-helper-define-polyfill-provider/test/meta-resolver.js packages/babel-plugin-polyfill-corejs3/test/check-builtin-definitions.test.js
102+
- name: Remove Babel 8-specific fixtures
103+
run: |
104+
# These fixtures produce different output with Babel 7 due to
105+
# behavioral changes in @babel/helper-compilation-targets and
106+
# @babel/plugin-transform-classes between Babel 7 and 8.
107+
rm -rf packages/babel-plugin-polyfill-corejs3/test/fixtures/regression/usage-pure-in-helpers
108+
rm -rf packages/babel-plugin-polyfill-corejs3/test/fixtures/usage-global/browserslist-config-ignore
109+
rm -rf packages/babel-plugin-polyfill-corejs3/test/fixtures/usage-global/dynamic-import
110+
rm -rf packages/babel-plugin-polyfill-corejs3/test/fixtures/usage-global/dynamic-import-webpack
111+
- name: Test
112+
run: yarn jest --ci --color --maxWorkers=2
113+
- name: Test the esm build
114+
run: yarn test:esm
115+
79116
test-windows:
80117
name: Test on Windows
81118
needs: prepare-yarn-cache

babel.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"sourceType": "unambiguous",
33
"presets": [
4-
["@babel/preset-env", { "loose": true }],
4+
"@babel/preset-env",
55
"@babel/preset-typescript"
66
],
77
"plugins": ["./scripts/babel-plugin-compat-core-import"],

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
"watch": "gulp watch"
1919
},
2020
"devDependencies": {
21-
"@babel/cli": "^7.28.6",
22-
"@babel/core": "^7.28.6",
23-
"@babel/eslint-parser": "^7.28.6",
24-
"@babel/eslint-plugin-development": "^7.28.6",
25-
"@babel/plugin-transform-runtime": "^7.28.5",
26-
"@babel/preset-env": "^7.28.6",
27-
"@babel/preset-typescript": "^7.28.5",
28-
"@babel/runtime": "^7.28.6",
21+
"@babel/cli": "^8.0.0-rc.3 <8.0.0",
22+
"@babel/core": "^8.0.0-rc.3 <8.0.0",
23+
"@babel/eslint-parser": "^8.0.0-rc.3 <8.0.0",
24+
"@babel/eslint-plugin-development": "^8.0.0-rc.3 <8.0.0",
25+
"@babel/plugin-transform-runtime": "^8.0.0-rc.3 <8.0.0",
26+
"@babel/preset-env": "^8.0.0-rc.3 <8.0.0",
27+
"@babel/preset-typescript": "^8.0.0-rc.3 <8.0.0",
28+
"@babel/runtime": "^8.0.0-rc.3 <8.0.0",
2929
"@rollup/plugin-babel": "^7.0.0",
3030
"@rollup/plugin-json": "^6.1.0",
3131
"@rollup/plugin-node-resolve": "^16.0.3",

packages/babel-helper-define-polyfill-provider/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@
2626
"./package.json": "./package.json"
2727
},
2828
"dependencies": {
29-
"@babel/helper-compilation-targets": "^7.28.6",
30-
"@babel/helper-plugin-utils": "^7.28.6",
29+
"@babel/helper-compilation-targets": "^8.0.0-rc.3 <8.0.0",
30+
"@babel/helper-plugin-utils": "^8.0.0-rc.3 <8.0.0",
3131
"lodash.debounce": "^4.0.8"
3232
},
3333
"peerDependencies": {
34-
"@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0"
34+
"@babel/core": "^7.4.0 || ^8.0.0-rc.3"
3535
},
3636
"devDependencies": {
37-
"@babel/cli": "^7.28.6",
38-
"@babel/core": "^7.28.6",
39-
"@babel/generator": "^7.28.6",
40-
"@babel/plugin-transform-modules-commonjs": "^7.28.6",
41-
"@babel/traverse": "^7.28.6",
37+
"@babel/cli": "^8.0.0-rc.3 <8.0.0",
38+
"@babel/core": "^8.0.0-rc.3 <8.0.0",
39+
"@babel/generator": "^8.0.0-rc.3 <8.0.0",
40+
"@babel/plugin-transform-modules-commonjs": "^8.0.0-rc.3 <8.0.0",
41+
"@babel/traverse": "^8.0.0-rc.3 <8.0.0",
4242
"@rollup/plugin-babel": "^7.0.0",
4343
"babel-loader": "^10.1.0",
4444
"rollup": "^4.59.0",

packages/babel-helper-define-polyfill-provider/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { declare } from "@babel/helper-plugin-utils";
22
import type { NodePath } from "@babel/traverse";
33

4-
import _getTargets, {
4+
import getTargets, {
55
isRequired,
66
getInclusionReasons,
77
} from "@babel/helper-compilation-targets";
8-
const getTargets = _getTargets.default || _getTargets;
98

109
import { createUtilsGetter } from "./utils";
1110
import ImportsCachedInjector from "./imports-injector";

packages/babel-helper-define-polyfill-provider/test/helpers/ast-to-code-serializer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { types as t } from "@babel/core";
22
import _generator from "@babel/generator";
3-
const generator = _generator.default;
3+
// For compatibility when running tests with Babel 7
4+
const generator = _generator.default || _generator;
45

56
export default {
67
test: v => t.isNode(v),

packages/babel-plugin-polyfill-corejs3/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@
2727
"core-js-compat": "^3.48.0"
2828
},
2929
"devDependencies": {
30-
"@babel/core": "^7.28.6",
31-
"@babel/helper-plugin-test-runner": "^7.27.1",
32-
"@babel/plugin-proposal-decorators": "^7.28.6",
33-
"@babel/plugin-transform-class-properties": "^7.28.6",
34-
"@babel/plugin-transform-classes": "^7.28.6",
35-
"@babel/plugin-transform-for-of": "^7.27.1",
36-
"@babel/plugin-transform-modules-commonjs": "^7.28.6",
37-
"@babel/plugin-transform-runtime": "^7.28.5",
38-
"@babel/plugin-transform-spread": "^7.28.6",
30+
"@babel/core": "^8.0.0-rc.3 <8.0.0",
31+
"@babel/helper-plugin-test-runner": "^8.0.0-rc.3 <8.0.0",
32+
"@babel/plugin-proposal-decorators": "^8.0.0-rc.3 <8.0.0",
33+
"@babel/plugin-transform-class-properties": "^8.0.0-rc.3 <8.0.0",
34+
"@babel/plugin-transform-classes": "^8.0.0-rc.3 <8.0.0",
35+
"@babel/plugin-transform-for-of": "^8.0.0-rc.3 <8.0.0",
36+
"@babel/plugin-transform-modules-commonjs": "^8.0.0-rc.3 <8.0.0",
37+
"@babel/plugin-transform-runtime": "^8.0.0-rc.3 <8.0.0",
38+
"@babel/plugin-transform-spread": "^8.0.0-rc.3 <8.0.0",
3939
"core-js": "^3.48.0",
4040
"core-js-pure": "^3.48.0"
4141
},
4242
"peerDependencies": {
43-
"@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0"
43+
"@babel/core": "^7.4.0 || ^8.0.0-rc.3"
4444
}
4545
}

packages/babel-plugin-polyfill-corejs3/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export default defineProvider<Options>(function (
270270
coreJSPureHelper("get-iterator", useBabelRuntime, ext),
271271
"getIterator",
272272
),
273-
[node.object],
273+
[node.object as t.Expression],
274274
),
275275
);
276276
path.skip();
@@ -345,7 +345,7 @@ export default defineProvider<Options>(function (
345345
parentPath.type === "OptionalMemberExpression"
346346
? "MemberExpression"
347347
: "CallExpression";
348-
delete parentAsNotOptional.node.optional;
348+
delete parentPath.node.optional;
349349

350350
({ parentPath } = parentPath);
351351
} while (
@@ -400,7 +400,7 @@ export default defineProvider<Options>(function (
400400
path.replaceWith(check(t.callExpression(id, [node.object])));
401401
if (t.isOptionalMemberExpression(parent)) parent.optional = true;
402402
} else {
403-
path.replaceWith(t.callExpression(id, [node.object]));
403+
path.replaceWith(t.callExpression(id, [node.object as t.Expression]));
404404
}
405405
}
406406
},

packages/babel-plugin-polyfill-corejs3/src/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export function maybeMemoizeContext(
3737
context1 = t.cloneNode(object);
3838
} else {
3939
context2 = scope.generateDeclaredUidIdentifier("context");
40-
context1 = t.assignmentExpression("=", t.cloneNode(context2), object);
40+
context1 = t.assignmentExpression(
41+
"=",
42+
t.cloneNode(context2),
43+
object as t.Expression,
44+
);
4145
}
4246

4347
return [context1, context2];

packages/babel-plugin-polyfill-corejs3/test/fixtures/absolute-imports/global/options.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"externalHelpers": false,
3+
"targets": { "ie": "5" },
34
"plugins": [
45
[
56
"@@/polyfill-corejs3",

0 commit comments

Comments
 (0)