Skip to content

Commit

Permalink
feat(core): add includeProjectDependents as a option for file watching (
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammisuli committed Nov 28, 2022
1 parent f0f60fb commit db3499d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/nx/src/daemon/client/client.ts
Expand Up @@ -106,7 +106,8 @@ export class DaemonClient {
async registerFileWatcher(
config: {
watchProjects: string[] | 'all';
includeGlobalWorkspaceFiles: boolean;
includeGlobalWorkspaceFiles?: boolean;
includeDependentProjects?: boolean;
},
callback: (
error: Error | null | 'closed',
Expand Down
@@ -1,6 +1,8 @@
import { Socket } from 'net';
import { ProjectGraphCache } from '../../../project-graph/nx-deps-cache';
import { ProjectGraph } from '../../../config/project-graph';
import { findAllProjectNodeDependencies } from '../../../utils/project-graph-utils';
import { PromisedBasedQueue } from '../../../utils/promised-based-queue';
import { currentProjectGraphCache } from '../project-graph-incremental-recomputation';
import { handleResult } from '../server';
import { getProjectsAndGlobalChanges } from './changed-projects';

Expand All @@ -11,6 +13,7 @@ export let registeredFileWatcherSockets: {
config: {
watchProjects: string[] | 'all';
includeGlobalWorkspaceFiles: boolean;
includeDependentProjects: boolean;
};
}[] = [];

Expand Down Expand Up @@ -52,7 +55,20 @@ export function notifyFileWatcherSockets(
changedFiles.push(...projectFiles);
}
} else {
for (const watchedProject of config.watchProjects) {
const watchedProjects = [...config.watchProjects];

if (config.includeDependentProjects) {
for (const project of watchedProjects) {
watchedProjects.push(
...findAllProjectNodeDependencies(
project,
currentProjectGraphCache as ProjectGraph
)
);
}
}

for (const watchedProject of new Set(watchedProjects)) {
if (!!projectAndGlobalChanges.projects[watchedProject]) {
changedProjects.push(watchedProject);

Expand Down
Expand Up @@ -24,7 +24,7 @@ let cachedSerializedProjectGraphPromise: Promise<{
export let projectFileMapWithFiles:
| { projectFileMap: ProjectFileMap; allWorkspaceFiles: FileData[] }
| undefined;
let currentProjectGraphCache: ProjectGraphCache | undefined;
export let currentProjectGraphCache: ProjectGraphCache | undefined;

const collectedUpdatedFiles = new Set<string>();
const collectedDeletedFiles = new Set<string>();
Expand Down

1 comment on commit db3499d

@vercel
Copy link

@vercel vercel bot commented on db3499d Nov 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx.dev

Please sign in to comment.