Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): ignore cache path when watching w…
Browse files Browse the repository at this point in the history
…ith 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)
  • Loading branch information
clydin authored and dgp1130 committed Oct 26, 2022
1 parent 316a50d commit 0ee7625
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Expand Up @@ -446,8 +446,8 @@ export async function* buildEsbuildBrowser(
const watcher = createWatcher({
polling: typeof initialOptions.poll === 'number',
interval: initialOptions.poll,
// Ignore the output path to avoid infinite rebuild cycles
ignored: [normalizedOptions.outputPath],
// Ignore the output and cache paths to avoid infinite rebuild cycles
ignored: [normalizedOptions.outputPath, normalizedOptions.cacheOptions.basePath],
});

// Temporarily watch the entire project
Expand Down
Expand Up @@ -9,6 +9,7 @@
import { BuilderContext } from '@angular-devkit/architect';
import * as path from 'path';
import { normalizeAssetPatterns, normalizeOptimization, normalizeSourceMaps } from '../../utils';
import { normalizeCacheOptions } from '../../utils/normalize-cache';
import { normalizePolyfills } from '../../utils/normalize-polyfills';
import { generateEntryPoints } from '../../utils/package-chunk-sort';
import { getIndexInputFile, getIndexOutputFile } from '../../utils/webpack-browser-config';
Expand Down Expand Up @@ -39,7 +40,9 @@ export async function normalizeOptions(
workspaceRoot,
(projectMetadata.sourceRoot as string | undefined) ?? 'src',
);
// Normalize options

const cacheOptions = normalizeCacheOptions(projectMetadata, workspaceRoot);

const mainEntryPoint = path.join(workspaceRoot, options.main);

// Currently esbuild do not support multiple files per entry-point
Expand Down Expand Up @@ -145,6 +148,7 @@ export async function normalizeOptions(
return {
advancedOptimizations: buildOptimizer,
baseHref,
cacheOptions,
crossOrigin,
externalDependencies,
poll,
Expand Down

0 comments on commit 0ee7625

Please sign in to comment.