Skip to content

Commit f1d1a88

Browse files
Revert "feat(@angular/build): Support splitting browser and server stats json files for easier consumption"
This reverts commit 9545676.
1 parent 6f7da7f commit f1d1a88

File tree

8 files changed

+14
-67
lines changed

8 files changed

+14
-67
lines changed

packages/angular/build/src/builders/application/execute-build.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { checkCommonJSModules } from '../../tools/esbuild/commonjs-checker';
2020
import { extractLicenses } from '../../tools/esbuild/license-extractor';
2121
import { profileAsync } from '../../tools/esbuild/profiling';
2222
import {
23-
buildMetafileForType,
2423
calculateEstimatedTransferSizes,
2524
logBuildStats,
2625
transformSupportedBrowsersToTargets,
@@ -302,22 +301,13 @@ export async function executeBuild(
302301
BuildOutputFileType.Root,
303302
);
304303

305-
const ssrOutputEnabled: boolean = !!ssrOptions;
306-
307304
// Write metafile if stats option is enabled
308305
if (options.stats) {
309306
executionResult.addOutputFile(
310-
'browser-stats.json',
311-
JSON.stringify(buildMetafileForType(metafile, 'browser', outputFiles), null, 2),
307+
'stats.json',
308+
JSON.stringify(metafile, null, 2),
312309
BuildOutputFileType.Root,
313310
);
314-
if (ssrOutputEnabled) {
315-
executionResult.addOutputFile(
316-
'server-stats.json',
317-
JSON.stringify(buildMetafileForType(metafile, 'server', outputFiles), null, 2),
318-
BuildOutputFileType.Root,
319-
);
320-
}
321311
}
322312

323313
if (!jsonLogs) {
@@ -332,7 +322,7 @@ export async function executeBuild(
332322
colors,
333323
changedFiles,
334324
estimatedTransferSizes,
335-
ssrOutputEnabled,
325+
!!ssrOptions,
336326
verbose,
337327
),
338328
);

packages/angular/build/src/builders/application/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@
535535
},
536536
"statsJson": {
537537
"type": "boolean",
538-
"description": "Generates a 'browser-stats.json' (and 'server-stats.json' when SSR is enabled) file which can be analyzed with https://esbuild.github.io/analyze/.",
538+
"description": "Generates a 'stats.json' file which can be analyzed with https://esbuild.github.io/analyze/.",
539539
"default": false
540540
},
541541
"budgets": {

packages/angular/build/src/tools/esbuild/utils.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -29,50 +29,6 @@ import {
2929
PrerenderedRoutesRecord,
3030
} from './bundler-execution-result';
3131

32-
export function buildMetafileForType(
33-
metafile: Metafile,
34-
type: 'browser' | 'server',
35-
outputFiles: BuildOutputFile[],
36-
): Metafile {
37-
const outputPathsForType = new Set(
38-
outputFiles
39-
.filter(({ type: fileType }) => {
40-
const isServerFile =
41-
fileType === BuildOutputFileType.ServerApplication ||
42-
fileType === BuildOutputFileType.ServerRoot;
43-
44-
return type === 'server' ? isServerFile : !isServerFile;
45-
})
46-
.map(({ path }) => path),
47-
);
48-
49-
const filteredOutputs: Metafile['outputs'] = {};
50-
for (const [outputPath, output] of Object.entries(metafile.outputs)) {
51-
if (outputPathsForType.has(outputPath)) {
52-
filteredOutputs[outputPath] = output;
53-
}
54-
}
55-
56-
const referencedInputs = new Set<string>();
57-
for (const output of Object.values(filteredOutputs)) {
58-
for (const inputPath of Object.keys(output.inputs)) {
59-
referencedInputs.add(inputPath);
60-
}
61-
}
62-
63-
const filteredInputs: Metafile['inputs'] = {};
64-
for (const [inputPath, input] of Object.entries(metafile.inputs)) {
65-
if (referencedInputs.has(inputPath)) {
66-
filteredInputs[inputPath] = input;
67-
}
68-
}
69-
70-
return {
71-
inputs: filteredInputs,
72-
outputs: filteredOutputs,
73-
};
74-
}
75-
7632
export function logBuildStats(
7733
metafile: Metafile,
7834
outputFiles: BuildOutputFile[],

packages/angular_devkit/build_angular/src/builders/browser-esbuild/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@
406406
},
407407
"statsJson": {
408408
"type": "boolean",
409-
"description": "Generates a 'browser-stats.json' file which can be analyzed using tools such as 'webpack-bundle-analyzer'.",
409+
"description": "Generates a 'stats.json' file which can be analyzed using tools such as 'webpack-bundle-analyzer'.",
410410
"default": false
411411
},
412412
"budgets": {

packages/angular_devkit/build_angular/src/builders/browser/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@
394394
},
395395
"statsJson": {
396396
"type": "boolean",
397-
"description": "Generates a 'browser-stats.json' (and 'server-stats.json' when SSR is enabled) file which can be analyzed using tools such as 'webpack-bundle-analyzer'.",
397+
"description": "Generates a 'stats.json' file which can be analyzed using tools such as 'webpack-bundle-analyzer'.",
398398
"default": false
399399
},
400400
"budgets": {

packages/angular_devkit/build_angular/src/builders/browser/specs/stats-json_spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ describe('Browser Builder stats json', () => {
2121

2222
it('works', async () => {
2323
const { files } = await browserBuild(architect, host, target, { statsJson: true });
24-
expect('browser-stats.json' in files).toBe(true);
24+
expect('stats.json' in files).toBe(true);
2525
});
2626

2727
it('works with profile flag', async () => {
2828
const { files } = await browserBuild(architect, host, target, { statsJson: true });
29-
expect('browser-stats.json' in files).toBe(true);
30-
const stats = JSON.parse(await files['browser-stats.json']);
29+
expect('stats.json' in files).toBe(true);
30+
const stats = JSON.parse(await files['stats.json']);
3131
expect(stats.chunks[0].modules[0].profile.building).toBeDefined();
3232
});
3333
});

packages/angular_devkit/build_angular/src/builders/server/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
},
209209
"statsJson": {
210210
"type": "boolean",
211-
"description": "Generates a 'browser-stats.json' and 'server-stats.json' file which can be analyzed using tools such as 'webpack-bundle-analyzer'.",
211+
"description": "Generates a 'stats.json' file which can be analyzed using tools such as 'webpack-bundle-analyzer'.",
212212
"default": false
213213
},
214214
"watch": {

packages/angular_devkit/build_angular/src/tools/webpack/configs/common.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
8383
// Once TypeScript provides support for keeping the dynamic import this workaround can be
8484
// changed to a direct dynamic import.
8585
const { VERSION: NG_VERSION } = await import('@angular/compiler-cli');
86-
const { GLOBAL_DEFS_FOR_TERSER, GLOBAL_DEFS_FOR_TERSER_WITH_AOT } =
87-
await import('@angular/compiler-cli/private/tooling');
86+
const { GLOBAL_DEFS_FOR_TERSER, GLOBAL_DEFS_FOR_TERSER_WITH_AOT } = await import(
87+
'@angular/compiler-cli/private/tooling'
88+
);
8889

8990
// determine hashing format
9091
const hashFormat = getOutputHashFormat(buildOptions.outputHashing);
@@ -244,7 +245,7 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
244245

245246
if (buildOptions.statsJson) {
246247
extraPlugins.push(
247-
new JsonStatsPlugin(path.resolve(root, buildOptions.outputPath, 'browser-stats.json')),
248+
new JsonStatsPlugin(path.resolve(root, buildOptions.outputPath, 'stats.json')),
248249
);
249250
}
250251

0 commit comments

Comments
 (0)