Skip to content

Commit 342a4ea

Browse files
clydindgp1130
authored andcommitted
fix(@angular-devkit/build-angular): correctly show initial files in stat table with esbuild builder
When using the esbuild-based browser application builder, only actual initial files will be displayed in the initial files section. Previously, certain dynamically imported files could unintentionally be displayed in the stats output table as initial files. This was a display only error and had no effect on the files added to the index HTML file. (cherry picked from commit 571f894)
1 parent a0687dc commit 342a4ea

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

packages/angular_devkit/build_angular/src/builders/browser-esbuild/esbuild.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,19 @@ export class BundlerContext {
103103
outputFile.path = relativeFilePath;
104104

105105
if (entryPoint) {
106-
// An entryPoint value indicates an initial file
107-
initialFiles.push({
108-
file: outputFile.path,
109-
// The first part of the filename is the name of file (e.g., "polyfills" for "polyfills.7S5G3MDY.js")
110-
name: basename(outputFile.path).split('.')[0],
111-
extension: extname(outputFile.path),
112-
});
106+
// The first part of the filename is the name of file (e.g., "polyfills" for "polyfills.7S5G3MDY.js")
107+
const name = basename(outputFile.path).split('.', 1)[0];
108+
109+
// Only entrypoints with an entry in the options are initial files.
110+
// Dynamic imports also have an entryPoint value in the meta file.
111+
if ((this.#esbuildOptions.entryPoints as Record<string, string>)?.[name]) {
112+
// An entryPoint value indicates an initial file
113+
initialFiles.push({
114+
file: outputFile.path,
115+
name,
116+
extension: extname(outputFile.path),
117+
});
118+
}
113119
}
114120
}
115121

packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ function logBuildStats(context: BuilderContext, metafile: Metafile, initialFiles
765765

766766
stats.push({
767767
initial: initial.has(file),
768-
stats: [file, initial.get(file) ?? '', output.bytes, ''],
768+
stats: [file, initial.get(file) ?? '-', output.bytes, ''],
769769
});
770770
}
771771

0 commit comments

Comments
 (0)