From 46d88a034343dc93dd0c467afc08c824da427fef Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 30 Nov 2023 08:38:43 +0000 Subject: [PATCH] fix(@angular-devkit/build-angular): handle watch updates on Mac OSX when using native FSEvents API By default, on Mac OSX chokidar will use the native darwin FSEvents API unless polling is enabled. In which case instead of listening on `raw` events we need to listen to `all` events. (cherry picked from commit 7ccc210071a43eeea4430c8183c9b4d907987043) --- .../angular_devkit/build_angular/src/tools/esbuild/watcher.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/tools/esbuild/watcher.ts b/packages/angular_devkit/build_angular/src/tools/esbuild/watcher.ts index a4c45feaf551..adb9acf42cf6 100644 --- a/packages/angular_devkit/build_angular/src/tools/esbuild/watcher.ts +++ b/packages/angular_devkit/build_angular/src/tools/esbuild/watcher.ts @@ -98,7 +98,7 @@ export function createWatcher(options?: { * ... (Nothing) * ``` */ - watcher.on('raw', (event, path, { watchedPath }) => { + watcher.on(watcher.options.useFsEvents ? 'all' : 'raw', (event, path, metadata) => { switch (event) { case 'add': case 'change': @@ -108,7 +108,7 @@ export function createWatcher(options?: { case 'rename': // When polling is enabled `watchedPath` can be undefined. // `path` is always normalized unlike `watchedPath`. - const changedPath = watchedPath ? normalize(watchedPath) : path; + const changedPath = metadata?.watchedPath ? normalize(metadata.watchedPath) : path; currentEvents ??= new Map(); currentEvents.set(changedPath, event); break;