Skip to content

Commit 4826378

Browse files
filipesilvaKeen Yee Liau
authored andcommitted
fix(@angular-devkit/build-angular): consider local decl in angular core files to be metadata too
Followup to #15239, fixes a 6kb size regression in new apps, potentially more in larger apps. Local declarations inside `@angular/core` files should also be considered metadata and scrubbed.
1 parent 38088d1 commit 4826378

File tree

1 file changed

+8
-1
lines changed
  • packages/angular_devkit/build_optimizer/src/transforms

1 file changed

+8
-1
lines changed

packages/angular_devkit/build_optimizer/src/transforms/scrub-file.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function expect<T extends ts.Node>(node: ts.Node, kind: ts.SyntaxKind): T
9393
}
9494

9595
function findAngularMetadata(node: ts.Node, isAngularCoreFile: boolean): ts.Node[] {
96-
const specs: ts.Node[] = [];
96+
let specs: ts.Node[] = [];
9797
// Find all specifiers from imports of `@angular/core`.
9898
ts.forEachChild(node, (child) => {
9999
if (child.kind === ts.SyntaxKind.ImportDeclaration) {
@@ -104,6 +104,13 @@ function findAngularMetadata(node: ts.Node, isAngularCoreFile: boolean): ts.Node
104104
}
105105
});
106106

107+
// If the current module is a Angular core file, we also consider all declarations in it to
108+
// potentially be Angular metadata.
109+
if (isAngularCoreFile) {
110+
const localDecl = findAllDeclarations(node);
111+
specs = specs.concat(localDecl);
112+
}
113+
107114
return specs;
108115
}
109116

0 commit comments

Comments
 (0)