mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-28 02:53:15 -04:00
fix: cli crash with auto-install-peers=true (#5394)
ref #5390 ref #5372
This commit is contained in:
6
.changeset/twenty-wolves-destroy.md
Normal file
6
.changeset/twenty-wolves-destroy.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/resolve-dependencies": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Don't crash when auto-install-peers is true and the project has many complex circular dependencies.
|
||||
@@ -341,3 +341,9 @@ test('auto install peer deps in a workspace. test #2', async () => {
|
||||
},
|
||||
], await testDefaults({ autoInstallPeers: true }))
|
||||
})
|
||||
|
||||
// This test may be removed if autoInstallPeers will become true by default
|
||||
test('installation on a package with many complex circular dependencies does not fail when auto install peers is on', async () => {
|
||||
prepareEmpty()
|
||||
await addDependenciesToPackage({}, ['webpack@4.46.0'], await testDefaults({ autoInstallPeers: true }))
|
||||
})
|
||||
|
||||
@@ -158,7 +158,7 @@ export interface ResolutionContext {
|
||||
virtualStoreDir: string
|
||||
updateMatching?: (pkgName: string) => boolean
|
||||
workspacePackages?: WorkspacePackages
|
||||
missingPeersOfChildrenByPkgId: Record<string, { parentNodeId: string, missingPeersOfChildren: MissingPeersOfChildren }>
|
||||
missingPeersOfChildrenByPkgId: Record<string, { parentImporterId: string, missingPeersOfChildren: MissingPeersOfChildren }>
|
||||
}
|
||||
|
||||
export type MissingPeers = Record<string, string>
|
||||
@@ -1278,7 +1278,7 @@ async function resolveDependency (
|
||||
let missingPeersOfChildren!: MissingPeersOfChildren | undefined
|
||||
if (!nodeIdContains(options.parentPkg.nodeId, depPath)) {
|
||||
if (ctx.missingPeersOfChildrenByPkgId[pkgResponse.body.id]) {
|
||||
if (!options.parentPkg.nodeId.startsWith(ctx.missingPeersOfChildrenByPkgId[pkgResponse.body.id].parentNodeId)) {
|
||||
if (!options.parentPkg.nodeId.startsWith(ctx.missingPeersOfChildrenByPkgId[pkgResponse.body.id].parentImporterId)) {
|
||||
missingPeersOfChildren = ctx.missingPeersOfChildrenByPkgId[pkgResponse.body.id].missingPeersOfChildren
|
||||
}
|
||||
} else {
|
||||
@@ -1289,7 +1289,7 @@ async function resolveDependency (
|
||||
get: pShare(p.promise),
|
||||
}
|
||||
ctx.missingPeersOfChildrenByPkgId[pkgResponse.body.id] = {
|
||||
parentNodeId: options.parentPkg.nodeId,
|
||||
parentImporterId: options.parentPkg.nodeId.substring(0, options.parentPkg.nodeId.indexOf('>', 1) + 1),
|
||||
missingPeersOfChildren,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user