Skip to content

Commit d9532a9

Browse files
committed
build: update babel monorepo to v8
See associated pull request for more information. Closes #33416 as a pr takeover
1 parent e664314 commit d9532a9

14 files changed

Lines changed: 957 additions & 884 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@angular/platform-server": "22.1.0-next.1",
6060
"@angular/router": "22.1.0-next.1",
6161
"@angular/service-worker": "22.1.0-next.1",
62-
"@babel/core": "7.29.7",
62+
"@babel/core": "8.0.1",
6363
"@bazel/bazelisk": "1.28.1",
6464
"@bazel/buildifier": "8.2.1",
6565
"@bazel/ibazel": "^0.28.0",

packages/angular/build/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"dependencies": {
2121
"@ampproject/remapping": "2.3.0",
2222
"@angular-devkit/architect": "workspace:0.0.0-EXPERIMENTAL-PLACEHOLDER",
23-
"@babel/core": "7.29.7",
24-
"@babel/helper-annotate-as-pure": "7.29.7",
23+
"@babel/core": "8.0.1",
24+
"@babel/helper-annotate-as-pure": "8.0.0",
2525
"@babel/helper-split-export-declaration": "7.24.7",
2626
"@inquirer/confirm": "6.1.1",
2727
"@vitejs/plugin-basic-ssl": "2.3.0",

packages/angular/build/src/tools/babel/plugins/add-code-coverage.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { NodePath, PluginObj, types } from '@babel/core';
9+
import { NodePath, PluginObject, PluginPass, types } from '@babel/core';
1010
import type { Visitor } from 'istanbul-lib-instrument';
1111
import assert from 'node:assert';
1212

@@ -17,13 +17,13 @@ import assert from 'node:assert';
1717
*/
1818
export default function (
1919
programVisitor: typeof import('istanbul-lib-instrument').programVisitor,
20-
): PluginObj {
20+
): PluginObject {
2121
const visitors = new WeakMap<NodePath, Visitor>();
2222

2323
return {
2424
visitor: {
2525
Program: {
26-
enter(path, state) {
26+
enter(path: NodePath<types.Program>, state: PluginPass) {
2727
const visitor = programVisitor(types, state.filename, {
2828
// Babel returns a Converter object from the `convert-source-map` package
2929
inputSourceMap: (state.file.inputMap as undefined | { toObject(): object })?.toObject(),
@@ -32,7 +32,7 @@ export default function (
3232

3333
visitor.enter(path);
3434
},
35-
exit(path) {
35+
exit(path: NodePath<types.Program>) {
3636
const visitor = visitors.get(path);
3737
assert(visitor, 'Instrumentation visitor should always be present for program path.');
3838

packages/angular/build/src/tools/babel/plugins/adjust-static-class-members.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { NodePath, PluginObj, PluginPass, types } from '@babel/core';
9+
import { NodePath, PluginObject, PluginPass, types } from '@babel/core';
1010
import annotateAsPure from '@babel/helper-annotate-as-pure';
1111
import splitExportDeclaration from '@babel/helper-split-export-declaration';
1212

@@ -206,7 +206,7 @@ const exportDefaultAnalysis = new WeakMap<types.Class, ReturnType<typeof analyze
206206
* @returns A babel plugin object instance.
207207
*/
208208
// eslint-disable-next-line max-lines-per-function
209-
export default function (): PluginObj {
209+
export default function (): PluginObject {
210210
return {
211211
visitor: {
212212
// When a class is converted to a variable declaration, the default export must be moved

packages/angular/build/src/tools/babel/plugins/adjust-typescript-enums.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { NodePath, PluginObj, types } from '@babel/core';
9+
import { NodePath, PluginObject, types } from '@babel/core';
1010
import annotateAsPure from '@babel/helper-annotate-as-pure';
1111

1212
/**
@@ -24,7 +24,7 @@ export function getKeywords(): Iterable<string> {
2424
*
2525
* @returns A babel plugin object instance.
2626
*/
27-
export default function (): PluginObj {
27+
export default function (): PluginObject {
2828
return {
2929
visitor: {
3030
VariableDeclaration(path: NodePath<types.VariableDeclaration>) {

packages/angular/build/src/tools/babel/plugins/elide-angular-metadata.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import type { types as BabelTypes, NodePath, PluginObj } from '@babel/core';
9+
import type { types as BabelTypes, NodePath, PluginObject } from '@babel/core';
1010

1111
/**
1212
* The name of the Angular class metadata function created by the Angular compiler.
@@ -48,10 +48,10 @@ const angularMetadataFunctions: Record<string, (args: NodePath[]) => boolean> =
4848
*
4949
* @returns A babel plugin object instance.
5050
*/
51-
export default function ({ types: t }: { types: typeof BabelTypes }): PluginObj {
51+
export default function ({ types: t }: { types: typeof BabelTypes }): PluginObject {
5252
return {
5353
visitor: {
54-
CallExpression(path) {
54+
CallExpression(path: NodePath<BabelTypes.CallExpression>) {
5555
const callee = path.get('callee');
5656

5757
// The function being called must be the metadata function name

packages/angular/build/src/tools/babel/plugins/pure-toplevel-functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import type { NodePath, PluginObj, PluginPass, types } from '@babel/core';
9+
import type { NodePath, PluginObject, PluginPass, types } from '@babel/core';
1010
import annotateAsPure from '@babel/helper-annotate-as-pure';
1111
import * as tslib from 'tslib';
1212

@@ -57,7 +57,7 @@ interface ExtendedPluginPass extends PluginPass {
5757
* A babel plugin factory function for adding the PURE annotation to top-level new and call expressions.
5858
* @returns A babel plugin object instance.
5959
*/
60-
export default function (): PluginObj {
60+
export default function (): PluginObject {
6161
return {
6262
visitor: {
6363
CallExpression(path: NodePath<types.CallExpression>, state: ExtendedPluginPass) {

packages/angular/build/src/tools/esbuild/i18n-inliner-worker.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import remapping, { SourceMapInput } from '@ampproject/remapping';
10-
import { PluginObj, parseSync, transformFromAstAsync, types } from '@babel/core';
10+
import { NodePath, PluginItem, parseSync, transformFromAstAsync, types } from '@babel/core';
1111
import assert from 'node:assert';
1212
import { workerData } from 'node:worker_threads';
1313
import { assertIsError } from '../../utils/error';
@@ -144,26 +144,25 @@ async function loadLocalizeTools(): Promise<LocalizeUtilityModule> {
144144
async function createI18nPlugins(locale: string, translation: Record<string, unknown> | undefined) {
145145
const { Diagnostics, makeEs2015TranslatePlugin } = await loadLocalizeTools();
146146

147-
const plugins: PluginObj[] = [];
147+
const plugins: PluginItem[] = [];
148148
const diagnostics = new Diagnostics();
149149

150150
plugins.push(
151-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
152-
makeEs2015TranslatePlugin(diagnostics, (translation || {}) as any, {
151+
makeEs2015TranslatePlugin(diagnostics, translation || {}, {
153152
missingTranslation: translation === undefined ? 'ignore' : missingTranslation,
154-
}),
153+
}) as unknown as PluginItem,
155154
);
156155

157156
// Create a plugin to replace the locale specifier constant inject by the build system with the actual specifier
158-
plugins.push({
157+
plugins.push(() => ({
159158
visitor: {
160-
StringLiteral(path) {
159+
StringLiteral(path: NodePath<types.StringLiteral>) {
161160
if (path.node.value === '___NG_LOCALE_INSERT___') {
162161
path.replaceWith(types.stringLiteral(locale));
163162
}
164163
},
165164
},
166-
});
165+
}));
167166

168167
return { diagnostics, plugins };
169168
}

packages/angular/build/src/tools/esbuild/javascript-transformer-worker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async function transformWithBabel(
8585

8686
const { default: coveragePluginFactory } =
8787
await import('../babel/plugins/add-code-coverage.js');
88-
plugins.push(coveragePluginFactory(programVisitor));
88+
plugins.push(coveragePluginFactory(programVisitor) as unknown as PluginItem);
8989
} catch (error) {
9090
throw new Error(
9191
`The 'istanbul-lib-instrument' package is required for code coverage but was not found. Please install the package.`,
@@ -97,7 +97,7 @@ async function transformWithBabel(
9797
if (shouldLink) {
9898
// Lazy load the linker plugin only when linking is required
9999
const linkerPlugin = await createLinkerPlugin(options);
100-
plugins.push(linkerPlugin);
100+
plugins.push(linkerPlugin as unknown as PluginItem);
101101
}
102102

103103
if (options.advancedOptimizations) {

packages/angular_devkit/build_angular/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
"@angular-devkit/build-webpack": "workspace:0.0.0-EXPERIMENTAL-PLACEHOLDER",
1212
"@angular-devkit/core": "workspace:0.0.0-PLACEHOLDER",
1313
"@angular/build": "workspace:0.0.0-PLACEHOLDER",
14-
"@babel/core": "7.29.7",
15-
"@babel/generator": "7.29.7",
16-
"@babel/helper-annotate-as-pure": "7.29.7",
14+
"@babel/core": "8.0.1",
15+
"@babel/generator": "8.0.0",
16+
"@babel/helper-annotate-as-pure": "8.0.0",
1717
"@babel/helper-split-export-declaration": "7.24.7",
18-
"@babel/plugin-transform-async-generator-functions": "7.29.7",
19-
"@babel/plugin-transform-async-to-generator": "7.29.7",
20-
"@babel/plugin-transform-runtime": "7.29.7",
21-
"@babel/preset-env": "7.29.7",
22-
"@babel/runtime": "7.29.7",
18+
"@babel/plugin-transform-async-generator-functions": "8.0.1",
19+
"@babel/plugin-transform-async-to-generator": "8.0.1",
20+
"@babel/plugin-transform-runtime": "8.0.1",
21+
"@babel/preset-env": "8.0.1",
22+
"@babel/runtime": "8.0.0",
2323
"@discoveryjs/json-ext": "1.1.0",
2424
"@ngtools/webpack": "workspace:0.0.0-PLACEHOLDER",
2525
"ansi-colors": "4.1.3",

0 commit comments

Comments
 (0)