Skip to content

Commit b1ca585

Browse files
gbleuclaude
authored andcommitted
feat(workspace): merge package-manager workspace members into Nx discovery
Nx-mode discovery returned exclusively the projects that have a project.json. Real Nx workspaces infer most projects from package.json scripts via the package manager's workspace globs — on a 250-package monorepo only 25 had a project.json, so edits in the other 225 packages were invisible: a changed file attributed to no project silently yields an empty affected set. When the workspace is also an npm/yarn/pnpm/bun workspace, merge the members that Nx-mode discovery didn't already cover (deduplicated by project root and name; project.json wins). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 8b64617 commit b1ca585

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/workspace/mod.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,24 @@ pub(crate) fn build_walker(
4646
pub fn discover_projects(cwd: &Path) -> Result<Vec<Project>> {
4747
// Try Nx first
4848
if nx::is_nx_workspace(cwd) {
49-
return nx::get_projects(cwd);
49+
let mut projects = nx::get_projects(cwd)?;
50+
// Merge package-manager workspace members that have no project.json —
51+
// Nx itself infers these from package.json scripts, so an Nx workspace's
52+
// project set is a superset of its project.json files.
53+
if workspaces::is_workspace(cwd) {
54+
if let Ok(ws_projects) = workspaces::get_projects(cwd) {
55+
let known_roots: std::collections::HashSet<std::path::PathBuf> =
56+
projects.iter().map(|p| p.root.clone()).collect();
57+
let known_names: std::collections::HashSet<String> =
58+
projects.iter().map(|p| p.name.clone()).collect();
59+
projects.extend(
60+
ws_projects
61+
.into_iter()
62+
.filter(|p| !known_roots.contains(&p.root) && !known_names.contains(&p.name)),
63+
);
64+
}
65+
}
66+
return Ok(projects);
5067
}
5168

5269
// Try Turbo (turbo.json)

0 commit comments

Comments
 (0)