Skip to content

Commit 92b9a2f

Browse files
committed
fixup! perf(@angular/build): reduce watcher debounce latency for faster incremental rebuilds
1 parent 50b8f2e commit 92b9a2f

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

  • packages/angular/build/src/tools/esbuild

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class WatcherQueue {
145145

146146
constructor(
147147
private readonly debounceMs = 100,
148-
private readonly maxWaitMs = 250,
148+
private readonly maxWaitMs = 500,
149149
) {}
150150

151151
addChange(type: 'added' | 'modified' | 'removed', file: string): void {
@@ -527,7 +527,16 @@ async function createChokidarWatcher(
527527
): Promise<BuildWatcher> {
528528
const chokidar = chokidarModule ?? (await import('chokidar'));
529529
const watchedFiles = new Set<string>();
530-
const queue = new WatcherQueue();
530+
531+
let queue: WatcherQueue;
532+
if (options?.polling) {
533+
const pollingInterval = options.interval ?? 100;
534+
const debounceMs = Math.min(250, Math.max(100, Math.ceil(pollingInterval * 1.5)));
535+
const maxWaitMs = Math.max(500, debounceMs * 3);
536+
queue = new WatcherQueue(debounceMs, maxWaitMs);
537+
} else {
538+
queue = new WatcherQueue();
539+
}
531540

532541
const rootDir = options?.cwd ?? process.cwd();
533542
const isCaseSensitive = isFileSystemCaseSensitive(rootDir);

0 commit comments

Comments
 (0)