Skip to content

Commit 98d18aa

Browse files
authored
Misc: Cleanup Babel 8 tasks (#17429)
1 parent 64ec61e commit 98d18aa

28 files changed

Lines changed: 265 additions & 75 deletions

File tree

packages/babel-cli/src/babel/util.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ export function hasDataSourcemap(code: string): boolean {
9898

9999
const CALLER = {
100100
name: "@babel/cli",
101+
supportsStaticESM: false,
102+
supportsDynamicImport: false,
103+
supportsExportNamespaceFrom: false,
101104
};
102105

103106
export function transformRepl(filename: string, code: string, opts: any) {

packages/babel-cli/test/fixtures/babel/env - SHOW_CONFIG_FOR with multiple files-windows/stdout.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ programmatic options from @babel/cli
2525
],
2626
"sourceFileName": "src/foo.js",
2727
"caller": {
28-
"name": "@babel/cli"
28+
"name": "@babel/cli",
29+
"supportsStaticESM": false,
30+
"supportsDynamicImport": false,
31+
"supportsExportNamespaceFrom": false
2932
},
3033
"filename": "src//foo.js"
3134
}

packages/babel-cli/test/fixtures/babel/env - SHOW_CONFIG_FOR with multiple files/stdout.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ programmatic options from @babel/cli
2525
],
2626
"sourceFileName": "src/foo.js",
2727
"caller": {
28-
"name": "@babel/cli"
28+
"name": "@babel/cli",
29+
"supportsStaticESM": false,
30+
"supportsDynamicImport": false,
31+
"supportsExportNamespaceFrom": false
2932
},
3033
"filename": "src/foo.js"
3134
}

packages/babel-cli/test/fixtures/babel/env - SHOW_CONFIG_FOR-windows/stdout.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ programmatic options from @babel/cli
2525
],
2626
"sourceFileName": "../src/foo.js",
2727
"caller": {
28-
"name": "@babel/cli"
28+
"name": "@babel/cli",
29+
"supportsStaticESM": false,
30+
"supportsDynamicImport": false,
31+
"supportsExportNamespaceFrom": false
2932
},
3033
"filename": "src//foo.js"
3134
}

packages/babel-cli/test/fixtures/babel/env - SHOW_CONFIG_FOR/stdout.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ programmatic options from @babel/cli
120120
"configFile": "./my-config.js",
121121
"sourceFileName": "./src/index.js",
122122
"caller": {
123-
"name": "@babel/cli"
123+
"name": "@babel/cli",
124+
"supportsStaticESM": false,
125+
"supportsDynamicImport": false,
126+
"supportsExportNamespaceFrom": false
124127
},
125128
"filename": "./src/index.js"
126129
}

packages/babel-core/src/config/validation/options.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ export type CallerMetadata = {
203203
// If 'caller' is specified, require that the name is given for debugging
204204
// messages.
205205
name: string;
206+
supportsStaticESM?: boolean;
207+
supportsDynamicImport?: boolean;
208+
supportsTopLevelAwait?: boolean;
209+
supportsExportNamespaceFrom?: boolean;
206210
};
207211
export type EnvSet<T> = {
208212
[x: string]: T;

packages/babel-generator/src/generators/expressions.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,10 @@ export function NewExpression(
9797
if (!process.env.BABEL_8_BREAKING) {
9898
// @ts-ignore(Babel 7 vs Babel 8) Removed in Babel 8
9999
this.print(node.typeParameters); // Legacy TS AST
100-
}
101-
102-
// @ts-ignore(Babel 7 vs Babel 8) Removed in Babel 8
103-
if (node.optional) {
104-
// TODO: This can never happen
105-
this.token("?.");
100+
// @ts-ignore(Babel 7 vs Babel 8) Removed in Babel 8
101+
if (node.optional) {
102+
this.token("?.");
103+
}
106104
}
107105

108106
if (

packages/babel-helper-module-transforms/src/normalize-and-load-metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ function getModuleMetadata(
278278

279279
// @ts-expect-error lazy is not listed in the type.
280280
// This is needed for compatibility with older version of the commonjs
281-
// plusing.
281+
// plugins.
282282
// TODO(Babel 8): Remove this
283283
get lazy() {
284284
return this.wrap === "lazy";

packages/babel-helper-transform-fixture-test-runner/src/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ function transformWithoutConfigFile(code: string, opts: InputOptions) {
7777
browserslistConfigFile: false,
7878
configFile: false,
7979
babelrc: false,
80+
caller: {
81+
name: "babel-helper-transform-fixture-test-runner/sync",
82+
supportsStaticESM: false,
83+
supportsDynamicImport: false,
84+
supportsExportNamespaceFrom: false,
85+
},
8086
...opts,
8187
});
8288
}
@@ -85,6 +91,12 @@ function transformAsyncWithoutConfigFile(code: string, opts: InputOptions) {
8591
browserslistConfigFile: false,
8692
configFile: false,
8793
babelrc: false,
94+
caller: {
95+
name: "babel-helper-transform-fixture-test-runner/async",
96+
supportsStaticESM: false,
97+
supportsDynamicImport: false,
98+
supportsExportNamespaceFrom: false,
99+
},
88100
...opts,
89101
});
90102
}

packages/babel-parser/src/plugins/estree.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,11 @@ export default (superClass: typeof Parser) =>
503503
.arguments[0] as N.Expression;
504504
(node as N.Node as N.EstreeImportExpression).options =
505505
(node.arguments[1] as N.Expression) ?? null;
506-
// compatibility with previous ESTree AST
507-
// TODO(Babel 8): Remove this
508-
(node as N.Node as N.EstreeImportExpression).attributes =
509-
(node.arguments[1] as N.Expression) ?? null;
506+
if (!process.env.BABEL_8_BREAKING) {
507+
// compatibility with previous ESTree AST
508+
(node as N.Node as N.EstreeImportExpression).attributes =
509+
(node.arguments[1] as N.Expression) ?? null;
510+
}
510511
// arguments isn't optional in the type definition
511512
delete node.arguments;
512513
// callee isn't optional in the type definition

0 commit comments

Comments
 (0)