diff --git a/packages/angular/build/src/tools/esbuild/bundler-context.ts b/packages/angular/build/src/tools/esbuild/bundler-context.ts index a551ae4defba..0d6b3d59ceaf 100644 --- a/packages/angular/build/src/tools/esbuild/bundler-context.ts +++ b/packages/angular/build/src/tools/esbuild/bundler-context.ts @@ -245,7 +245,7 @@ export class BundlerContext { // When incremental always add any files from the load result cache if (this.#loadCache) { for (const file of this.#loadCache.watchFiles) { - if (!isInternalAngularFile(file)) { + if (!isInternalAngularFileOrEsBuildDefine(file)) { // watch files are fully resolved paths this.watchFiles.add(file); } @@ -260,7 +260,7 @@ export class BundlerContext { if (this.incremental) { // Add input files except virtual angular files which do not exist on disk for (const input of Object.keys(result.metafile.inputs)) { - if (!isInternalAngularFile(input)) { + if (!isInternalAngularFileOrEsBuildDefine(input)) { // input file paths are always relative to the workspace root this.watchFiles.add(join(this.workspaceRoot, input)); } @@ -417,12 +417,12 @@ export class BundlerContext { #addErrorsToWatch(result: BuildFailure | BuildResult): void { for (const error of result.errors) { let file = error.location?.file; - if (file && !isInternalAngularFile(file)) { + if (file && !isInternalAngularFileOrEsBuildDefine(file)) { this.watchFiles.add(join(this.workspaceRoot, file)); } for (const note of error.notes) { file = note.location?.file; - if (file && !isInternalAngularFile(file)) { + if (file && !isInternalAngularFileOrEsBuildDefine(file)) { this.watchFiles.add(join(this.workspaceRoot, file)); } } @@ -475,6 +475,6 @@ export class BundlerContext { } } -function isInternalAngularFile(file: string) { - return file.startsWith('angular:'); +function isInternalAngularFileOrEsBuildDefine(file: string) { + return file.startsWith('angular:') || file.startsWith('