refactor: always load all projects into allProjectsGraph (#9259)

This commit is contained in:
Brandon Cheng
2025-03-10 21:59:23 -04:00
committed by GitHub
parent 57f989ef45
commit b4efd0eca8
2 changed files with 11 additions and 24 deletions

View File

@@ -0,0 +1,8 @@
---
"@pnpm/plugin-commands-installation": minor
pnpm: minor
---
Removed a branching code path that only executed when `dedupe-peer-dependents=false`. We believe this internal refactor will not result in behavior changes, but we expect it to make future pnpm versions behave more consistently for projects that override `dedupe-peer-dependents` to false. There should be less unique bugs from turning off `dedupe-peer-dependents`.
See details in [#9259](https://github.com/pnpm/pnpm/pull/9259).

View File

@@ -220,31 +220,10 @@ when running add/update with the --workspace option')
})
}
const didUserConfigureCatalogs = Object.values(opts.catalogs ?? {})
.some(catalog => Object.keys(catalog ?? {}).length > 0)
const allProjectsGraph: ProjectsGraph = opts.allProjectsGraph ?? createPkgGraph(allProjects, {
linkWorkspacePackages: Boolean(opts.linkWorkspacePackages),
}).graph
// pnpm catalogs and dedupe-peer-dependents are features that require the
// allProjectsGraph to contain all projects to correctly update the wanted
// lockfile. Otherwise the wanted lockfile would be partially updated for
// only the selected projects specified for the filtered install.
//
// This should still be performance since only dependencies for the
// selectedProjectsGraph are installed. The allProjectsGraph is only used
// to compute the wanted lockfile.
let allProjectsGraph!: ProjectsGraph
if (didUserConfigureCatalogs || opts.dedupePeerDependents) {
allProjectsGraph = opts.allProjectsGraph ?? createPkgGraph(allProjects, {
linkWorkspacePackages: Boolean(opts.linkWorkspacePackages),
}).graph
} else {
allProjectsGraph = selectedProjectsGraph
if (!allProjectsGraph[opts.workspaceDir as ProjectRootDir]) {
allProjectsGraph = {
...allProjectsGraph,
...selectProjectByDir(allProjects, opts.workspaceDir),
}
}
}
await recursiveInstallThenUpdateWorkspaceState(allProjects,
params,
{