Skip to content

Commit

Permalink
refactor: resolvePeers.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Apr 19, 2022
1 parent 2e0174f commit 2550e63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/resolve-dependencies/src/resolveDependencyTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function buildTree (
childrenNodeIds[child.alias] = child.depPath
continue
}
if (nodeIdContainsSequence(parentNodeId, parentId, child.depPath)) {
if (nodeIdContainsSequence(parentNodeId, parentId, child.depPath) || parentId === child.depPath) {
continue
}
const childNodeId = createNodeId(parentNodeId, child.depPath)
Expand Down
11 changes: 7 additions & 4 deletions packages/resolve-dependencies/src/resolvePeers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ function resolvePeersOfNode<T extends PartialResolvedPackage> (
: {
...parentParentPkgs,
...toPkgByName(
Object.keys(children).map((alias) => ({
Object.entries(children).map(([alias, nodeId]) => ({
alias,
node: ctx.dependenciesTree[children[alias]],
nodeId: children[alias],
node: ctx.dependenciesTree[nodeId],
nodeId,
}))
),
}
Expand Down Expand Up @@ -345,9 +345,12 @@ function getPreviouslyResolvedChildren<T extends PartialResolvedPackage> (nodeId
nodeIdChunks.reduce((accNodeId, part) => {
accNodeId += `>${part}>${ownId}`
const parentNode = dependenciesTree[`${accNodeId}>`]
if (typeof parentNode.children === 'function') {
parentNode.children = parentNode.children()
}
Object.assign(
allChildren,
typeof parentNode.children === 'function' ? parentNode.children() : parentNode.children
parentNode.children
)
return accNodeId
}, '')
Expand Down

0 comments on commit 2550e63

Please sign in to comment.