diff --git a/.changeset/angry-eggs-rhyme.md b/.changeset/angry-eggs-rhyme.md new file mode 100644 index 0000000000..3c69d47d7f --- /dev/null +++ b/.changeset/angry-eggs-rhyme.md @@ -0,0 +1,6 @@ +--- +"@pnpm/resolve-dependencies": patch +"pnpm": patch +--- + +Fix an error with peer resolutions, which was happening when there was a circular dependency and another dependency that had the name of the circular dependency as a substring. diff --git a/packages/resolve-dependencies/src/resolvePeers.ts b/packages/resolve-dependencies/src/resolvePeers.ts index 8533ca5cff..24550176b8 100644 --- a/packages/resolve-dependencies/src/resolvePeers.ts +++ b/packages/resolve-dependencies/src/resolvePeers.ts @@ -334,17 +334,17 @@ function getPreviouslyResolvedChildren (nodeId if (!ownId || !parentIds.includes(ownId)) return allChildren - const nodeIdChunks = parentIds.join('>').split(ownId) + const nodeIdChunks = parentIds.join('>').split(`>${ownId}>`) nodeIdChunks.pop() nodeIdChunks.reduce((accNodeId, part) => { - accNodeId += `${part}${ownId}` + accNodeId += `>${part}>${ownId}` const parentNode = dependenciesTree[`${accNodeId}>`] Object.assign( allChildren, typeof parentNode.children === 'function' ? parentNode.children() : parentNode.children ) return accNodeId - }, '>') + }, '') return allChildren }