Skip to content

Commit 0ee7625

Browse files
clydindgp1130
authored andcommitted
fix(@angular-devkit/build-angular): ignore cache path when watching with esbuild builder
When using the experimental esbuild-based browser application builder in watch mode, the base cache path defined within the `angular.json` file will now be ignored when detecting file changes. While the builder currently does not persist cache to disk, it may in the future and other builders may currently be run in parallel. (cherry picked from commit e21ee32)
1 parent 316a50d commit 0ee7625

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ export async function* buildEsbuildBrowser(
446446
const watcher = createWatcher({
447447
polling: typeof initialOptions.poll === 'number',
448448
interval: initialOptions.poll,
449-
// Ignore the output path to avoid infinite rebuild cycles
450-
ignored: [normalizedOptions.outputPath],
449+
// Ignore the output and cache paths to avoid infinite rebuild cycles
450+
ignored: [normalizedOptions.outputPath, normalizedOptions.cacheOptions.basePath],
451451
});
452452

453453
// Temporarily watch the entire project

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import { BuilderContext } from '@angular-devkit/architect';
1010
import * as path from 'path';
1111
import { normalizeAssetPatterns, normalizeOptimization, normalizeSourceMaps } from '../../utils';
12+
import { normalizeCacheOptions } from '../../utils/normalize-cache';
1213
import { normalizePolyfills } from '../../utils/normalize-polyfills';
1314
import { generateEntryPoints } from '../../utils/package-chunk-sort';
1415
import { getIndexInputFile, getIndexOutputFile } from '../../utils/webpack-browser-config';
@@ -39,7 +40,9 @@ export async function normalizeOptions(
3940
workspaceRoot,
4041
(projectMetadata.sourceRoot as string | undefined) ?? 'src',
4142
);
42-
// Normalize options
43+
44+
const cacheOptions = normalizeCacheOptions(projectMetadata, workspaceRoot);
45+
4346
const mainEntryPoint = path.join(workspaceRoot, options.main);
4447

4548
// Currently esbuild do not support multiple files per entry-point
@@ -145,6 +148,7 @@ export async function normalizeOptions(
145148
return {
146149
advancedOptimizations: buildOptimizer,
147150
baseHref,
151+
cacheOptions,
148152
crossOrigin,
149153
externalDependencies,
150154
poll,

0 commit comments

Comments
 (0)