From 86283dbe044ab0149d29bfc6ab9b29b712f6dc54 Mon Sep 17 00:00:00 2001 From: Jonathan Cammisuli Date: Thu, 5 Jan 2023 15:04:48 -0500 Subject: [PATCH 1/3] fix(core): fix dependent projects for watch --- .../nx/src/daemon/server/file-watching/file-watcher-sockets.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nx/src/daemon/server/file-watching/file-watcher-sockets.ts b/packages/nx/src/daemon/server/file-watching/file-watcher-sockets.ts index 6a794c1ce2c60..02a60eb871915 100644 --- a/packages/nx/src/daemon/server/file-watching/file-watcher-sockets.ts +++ b/packages/nx/src/daemon/server/file-watching/file-watcher-sockets.ts @@ -58,7 +58,7 @@ export function notifyFileWatcherSockets( const watchedProjects = [...config.watchProjects]; if (config.includeDependentProjects) { - for (const project of watchedProjects) { + for (const project of config.watchProjects) { watchedProjects.push( ...findAllProjectNodeDependencies( project, From e32d25bce0565f3e7713caaf3687e44d1e4f7787 Mon Sep 17 00:00:00 2001 From: Jonathan Cammisuli Date: Wed, 11 Jan 2023 09:50:04 -0500 Subject: [PATCH 2/3] feat(core): optimize set --- .../file-watching/file-watcher-sockets.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/nx/src/daemon/server/file-watching/file-watcher-sockets.ts b/packages/nx/src/daemon/server/file-watching/file-watcher-sockets.ts index 02a60eb871915..e4887d6661ffe 100644 --- a/packages/nx/src/daemon/server/file-watching/file-watcher-sockets.ts +++ b/packages/nx/src/daemon/server/file-watching/file-watcher-sockets.ts @@ -55,20 +55,21 @@ export function notifyFileWatcherSockets( changedFiles.push(...projectFiles); } } else { - const watchedProjects = [...config.watchProjects]; + const watchedProjects = new Set(); if (config.includeDependentProjects) { for (const project of config.watchProjects) { - watchedProjects.push( - ...findAllProjectNodeDependencies( - project, - currentProjectGraphCache as ProjectGraph - ) - ); + watchedProjects.add(project); + for (const dep of findAllProjectNodeDependencies( + project, + currentProjectGraphCache as ProjectGraph + )) { + watchedProjects.add(dep); + } } } - for (const watchedProject of new Set(watchedProjects)) { + for (const watchedProject of watchedProjects) { if (!!projectAndGlobalChanges.projects[watchedProject]) { changedProjects.push(watchedProject); From fdb7dba0567bdc790829e610c7207d0f120c9716 Mon Sep 17 00:00:00 2001 From: Jonathan Cammisuli Date: Wed, 11 Jan 2023 10:15:13 -0500 Subject: [PATCH 3/3] feat(core): make sure watchedProjects is initialized with values --- .../nx/src/daemon/server/file-watching/file-watcher-sockets.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/nx/src/daemon/server/file-watching/file-watcher-sockets.ts b/packages/nx/src/daemon/server/file-watching/file-watcher-sockets.ts index e4887d6661ffe..85d38ef560b5a 100644 --- a/packages/nx/src/daemon/server/file-watching/file-watcher-sockets.ts +++ b/packages/nx/src/daemon/server/file-watching/file-watcher-sockets.ts @@ -55,11 +55,10 @@ export function notifyFileWatcherSockets( changedFiles.push(...projectFiles); } } else { - const watchedProjects = new Set(); + const watchedProjects = new Set(config.watchProjects); if (config.includeDependentProjects) { for (const project of config.watchProjects) { - watchedProjects.add(project); for (const dep of findAllProjectNodeDependencies( project, currentProjectGraphCache as ProjectGraph