Skip to content

Commit 6f7da7f

Browse files
Revert "fix(@angular/build): Fixing the missing browser initial stats file that was in my main branch off of @angular/angular-cli repository"
This reverts commit 24c509f.
1 parent 8d5d1c3 commit 6f7da7f

File tree

4 files changed

+11
-48
lines changed

4 files changed

+11
-48
lines changed

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

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -308,31 +308,13 @@ export async function executeBuild(
308308
if (options.stats) {
309309
executionResult.addOutputFile(
310310
'browser-stats.json',
311-
JSON.stringify(buildMetafileForType(metafile, 'browser', false, outputFiles), null, 2),
312-
BuildOutputFileType.Root,
313-
);
314-
executionResult.addOutputFile(
315-
'browser-initial-stats.json',
316-
JSON.stringify(
317-
buildMetafileForType(metafile, 'browser', true, outputFiles, initialFiles),
318-
null,
319-
2,
320-
),
311+
JSON.stringify(buildMetafileForType(metafile, 'browser', outputFiles), null, 2),
321312
BuildOutputFileType.Root,
322313
);
323314
if (ssrOutputEnabled) {
324315
executionResult.addOutputFile(
325316
'server-stats.json',
326-
JSON.stringify(buildMetafileForType(metafile, 'server', false, outputFiles), null, 2),
327-
BuildOutputFileType.Root,
328-
);
329-
executionResult.addOutputFile(
330-
'server-initial-stats.json',
331-
JSON.stringify(
332-
buildMetafileForType(metafile, 'server', true, outputFiles, initialFiles),
333-
null,
334-
2,
335-
),
317+
JSON.stringify(buildMetafileForType(metafile, 'server', outputFiles), null, 2),
336318
BuildOutputFileType.Root,
337319
);
338320
}

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,25 @@ import {
3232
export function buildMetafileForType(
3333
metafile: Metafile,
3434
type: 'browser' | 'server',
35-
initial: boolean,
3635
outputFiles: BuildOutputFile[],
37-
initialFiles?: Map<string, InitialFileRecord>,
3836
): Metafile {
39-
const isServer = type === 'server';
40-
4137
const outputPathsForType = new Set(
4238
outputFiles
4339
.filter(({ type: fileType }) => {
4440
const isServerFile =
4541
fileType === BuildOutputFileType.ServerApplication ||
4642
fileType === BuildOutputFileType.ServerRoot;
4743

48-
return isServer ? isServerFile : !isServerFile;
44+
return type === 'server' ? isServerFile : !isServerFile;
4945
})
5046
.map(({ path }) => path),
5147
);
5248

5349
const filteredOutputs: Metafile['outputs'] = {};
5450
for (const [outputPath, output] of Object.entries(metafile.outputs)) {
55-
if (!outputPathsForType.has(outputPath)) {
56-
continue;
57-
}
58-
if (initial && !initialFiles?.has(outputPath)) {
59-
continue;
51+
if (outputPathsForType.has(outputPath)) {
52+
filteredOutputs[outputPath] = output;
6053
}
61-
filteredOutputs[outputPath] = output;
6254
}
6355

6456
const referencedInputs = new Set<string>();

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

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,12 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
2626

2727
expect(result?.success).toBe(true);
2828

29-
if (harness.expectFile('dist/browser-stats.json').toExist()) {
30-
const content = harness.readFile('dist/browser-stats.json');
29+
if (harness.expectFile('dist/stats.json').toExist()) {
30+
const content = harness.readFile('dist/stats.json');
3131
expect(() => JSON.parse(content))
3232
.withContext('Expected Webpack Stats file to be valid JSON.')
3333
.not.toThrow();
3434
}
35-
if (harness.expectFile('dist/browser-initial-stats.json').toExist()) {
36-
const initialContent = harness.readFile('dist/browser-initial-stats.json');
37-
expect(() => JSON.parse(initialContent))
38-
.withContext('Expected Webpack Stats file to be valid JSON.')
39-
.not.toThrow();
40-
}
4135
});
4236

4337
// TODO: Investigate why this profiling object is no longer present in Webpack 5.90.3+ and if this should even be tested
@@ -51,8 +45,8 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
5145

5246
expect(result?.success).toBe(true);
5347

54-
if (harness.expectFile('dist/browser-stats.json').toExist()) {
55-
const stats = JSON.parse(harness.readFile('dist/browser-stats.json'));
48+
if (harness.expectFile('dist/stats.json').toExist()) {
49+
const stats = JSON.parse(harness.readFile('dist/stats.json'));
5650
expect(stats?.chunks?.[0]?.modules?.[0]?.profile?.building).toBeDefined();
5751
}
5852
});
@@ -67,8 +61,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
6761

6862
expect(result?.success).toBe(true);
6963

70-
harness.expectFile('dist/browser-stats.json').toNotExist();
71-
harness.expectFile('dist/browser-initial-stats.json').toNotExist();
64+
harness.expectFile('dist/stats.json').toNotExist();
7265
});
7366

7467
it('does not generate a Webpack Stats file in output when not present', async () => {
@@ -80,8 +73,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
8073

8174
expect(result?.success).toBe(true);
8275

83-
harness.expectFile('dist/browser-stats.json').toNotExist();
84-
harness.expectFile('dist/browser-initial-stats.json').toNotExist();
76+
harness.expectFile('dist/stats.json').toNotExist();
8577
});
8678
});
8779
});

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,6 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
245245
if (buildOptions.statsJson) {
246246
extraPlugins.push(
247247
new JsonStatsPlugin(path.resolve(root, buildOptions.outputPath, 'browser-stats.json')),
248-
new JsonStatsPlugin(
249-
path.resolve(root, buildOptions.outputPath, 'browser-initial-stats.json'),
250-
),
251248
);
252249
}
253250

0 commit comments

Comments
 (0)