fix(resolve-dependencies): optimize splitNodeId, fix invalid nodeId (#6755)

This commit is contained in:
Bogdan Savluk
2023-07-03 14:10:12 +02:00
committed by GitHub
parent fee263822c
commit abdb77f48e
3 changed files with 7 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/resolve-dependencies": patch
---
Fix edge case where invalid "nodeId" was created. Small optimization.

View File

@@ -18,5 +18,5 @@ export function createNodeId (parentNodeId: string, pkgId: string) {
}
export function splitNodeId (nodeId: string) {
return nodeId.slice(1, -1).split('>')
return nodeId.split('>').slice(1, -1)
}

View File

@@ -1241,7 +1241,7 @@ async function resolveDependency (
// In case of leaf dependencies (dependencies that have no prod deps or peer deps),
// we only ever need to analyze one leaf dep in a graph, so the nodeId can be short and stateless.
const nodeId = pkgIsLeaf(pkg)
? pkgResponse.body.id
? `>${depPath}>`
: createNodeId(options.parentPkg.nodeId, depPath)
const parentIsInstallable = options.parentPkg.installable === undefined || options.parentPkg.installable