Skip to content

Commit 023d093

Browse files
committed
perf(@angular-devkit/build-webpack): include only required stats in webpackStats
Until we depend on `webpackStats` in the browser builder we should only included the required stats. The below are the needed stats; ``` all: false, colors: true, hash: true, timings: true, chunks: true, builtAt: true, warnings: true, errors: true, assets: true, ids: true, entrypoints: true, ```
1 parent 2e007b7 commit 023d093

File tree

2 files changed

+12
-23
lines changed
  • packages/angular_devkit

2 files changed

+12
-23
lines changed

packages/angular_devkit/build_angular/src/webpack/configs/stats.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@ const webpackOutputOptions = {
1515
timings: true, // required by custom stat output
1616
chunks: true, // required by custom stat output
1717
builtAt: true, // required by custom stat output
18-
chunkModules: false,
19-
children: false, // listing all children is very noisy in AOT and hides warnings/errors
20-
modules: false,
21-
reasons: false,
2218
warnings: true,
2319
errors: true,
2420
assets: true, // required by custom stat output
25-
version: false,
26-
errorDetails: false,
27-
moduleTrace: false,
21+
22+
// Needed for markAsyncChunksNonInitial.
23+
ids: true,
24+
entrypoints: true,
2825
};
2926

3027
const verboseWebpackOutputOptions: Record<string, boolean | string | number> = {
@@ -40,10 +37,9 @@ const verboseWebpackOutputOptions: Record<string, boolean | string | number> = {
4037
errorDetails: true,
4138
moduleTrace: true,
4239
logging: 'verbose',
40+
modulesSpace: Infinity,
4341
};
4442

45-
verboseWebpackOutputOptions['modulesSpace'] = Infinity;
46-
4743
export function getWebpackStatsConfig(verbose = false) {
4844
return verbose
4945
? { ...webpackOutputOptions, ...verboseWebpackOutputOptions }

packages/angular_devkit/build_webpack/src/webpack/index.ts

+7-14
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ export function runWebpack(
5959
switchMap(
6060
(webpackCompiler) =>
6161
new Observable<BuildResult>((obs) => {
62-
// Webpack 5 has a compiler level close function
63-
const compilerClose = (webpackCompiler as {
64-
close?(callback: () => void): void;
65-
}).close?.bind(webpackCompiler);
66-
6762
const callback = (err?: Error, stats?: webpack.Stats) => {
6863
if (err) {
6964
return obs.error(err);
@@ -76,19 +71,17 @@ export function runWebpack(
7671
// Log stats.
7772
log(stats, config);
7873

79-
obs.next(({
74+
const statsOptions = typeof config.stats === 'boolean' ? undefined : config.stats;
75+
76+
obs.next({
8077
success: !stats.hasErrors(),
81-
webpackStats: shouldProvideStats ? stats.toJson() : undefined,
78+
webpackStats: shouldProvideStats ? stats.toJson(statsOptions) : undefined,
8279
emittedFiles: getEmittedFiles(stats.compilation),
8380
outputPath: stats.compilation.outputOptions.path,
84-
} as unknown) as BuildResult);
81+
} as unknown as BuildResult);
8582

8683
if (!config.watch) {
87-
if (compilerClose) {
88-
compilerClose(() => obs.complete());
89-
} else {
90-
obs.complete();
91-
}
84+
webpackCompiler.close(() => obs.complete());
9285
}
9386
};
9487

@@ -100,7 +93,7 @@ export function runWebpack(
10093
// Teardown logic. Close the watcher when unsubscribed from.
10194
return () => {
10295
watching.close(() => {});
103-
compilerClose?.(() => {});
96+
webpackCompiler.close(() => {});
10497
};
10598
} else {
10699
webpackCompiler.run(callback);

0 commit comments

Comments
 (0)