fix: hoisting of dependencies after resolution stage (#9686)

close #9685
This commit is contained in:
Zoltan Kochan
2025-06-24 11:51:18 +02:00
committed by GitHub
parent 5d2308c9aa
commit cc6db888d6
2 changed files with 17 additions and 1 deletions

View File

@@ -0,0 +1,11 @@
---
"@pnpm/core": patch
"pnpm": patch
---
Restore hoisting of optional peer dependencies when installing with an outdated lockfile.
Regression introduced in [v10.12.2] by [#9648]; resolves [#9685].
[v10.12.2]: https://github.com/pnpm/pnpm/releases/tag/v10.12.2
[#9648]: https://github.com/pnpm/pnpm/pull/9648
[#9685]: https://github.com/pnpm/pnpm/issues/9685

View File

@@ -218,7 +218,12 @@ export async function linkPackages (projects: ImporterToUpdate[], depGraph: Depe
...await hoist({
extraNodePath: opts.extraNodePaths,
graph: depGraph,
directDepsByImporterId: opts.dependenciesByProjectId,
directDepsByImporterId: {
...opts.dependenciesByProjectId,
'.': new Map(Array.from(opts.dependenciesByProjectId['.']?.entries() ?? []).filter(([alias]) => {
return newCurrentLockfile.importers['.' as ProjectId].specifiers[alias]
})),
},
importerIds: projectIds,
privateHoistedModulesDir: opts.hoistedModulesDir,
privateHoistPattern: opts.hoistPattern ?? [],