Skip to content

Commit 3c90256

Browse files
committed
perf(@angular-devkit/build-angular): reduce build times for apps with a large number of components when utilizing esbuild-based builders
In this commit, we've optimized the build performance for applications containing a large number of components when using the esbuild-based builder. This optimization entails replacing the spread operator with `Object.assign` when appending to the result metadata in the Angular compiler plugin to avoid creating a multiple copies of the object. **Previous Performance**: - Initial compilation: 37 seconds - First incremental build: 20 seconds - Second incremental build: 16 seconds **Updated Performance**: - Initial compilation: 24 seconds - First incremental build: 6 seconds - Second incremental build: 2 seconds Closes #27280
1 parent 0152ab9 commit 3c90256

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/angular_devkit/build_angular/src/tools/esbuild/angular/compiler-plugin.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,10 @@ export function createCompilerPlugin(
420420

421421
// Combine additional metafiles with main metafile
422422
if (result.metafile && metafile) {
423-
result.metafile.inputs = { ...result.metafile.inputs, ...metafile.inputs };
424-
result.metafile.outputs = { ...result.metafile.outputs, ...metafile.outputs };
423+
// Append the existing object by appending to it to prevent unnecessary new objections creations with spread
424+
// mitigating significant performance overhead for large apps.
425+
Object.assign(result.metafile.inputs, metafile.inputs);
426+
Object.assign(result.metafile.outputs, metafile.outputs);
425427
}
426428
}
427429

0 commit comments

Comments
 (0)