Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(arborist)!: install optional peer dependencies #5301

Draft
wants to merge 1 commit into
base: latest
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 7 additions & 9 deletions workspaces/arborist/lib/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1200,23 +1200,21 @@ This is a one-time fix-up, please be patient...
return false
}

// If the edge has no destination, that's a problem
if (!edge.to) {
return true
}

// If it's already been logged as a load failure, skip it.
if (edge.to && this[_loadFailures].has(edge.to)) {
if (this[_loadFailures].has(edge.to)) {
return false
}

// If it's shrinkwrapped, we use what the shrinkwap wants.
if (edge.to && edge.to.inShrinkwrap) {
if (edge.to.inShrinkwrap) {
return false
}

// If the edge has no destination, that's a problem, unless
// if it's peerOptional and not explicitly requested.
if (!edge.to) {
return edge.type !== 'peerOptional' ||
this[_explicitRequests].has(edge)
}

// If the edge has an error, there's a problem.
if (!edge.valid) {
return true
Expand Down
22 changes: 21 additions & 1 deletion workspaces/arborist/lib/place-dep.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,27 @@ class PlaceDep {
}

get conflictOk () {
return this.force || (!this.isMine && !this.strictPeerDeps)
if (this.force) {
return true
}

if (!this.isMine && !this.strictPeerDeps) {
return true
}

if (this.top.edge.type === 'peerOptional') {
return true
}

let fromIsOptional = !!this.top.edge.from.edgesIn.size
for (const edgeIn of this.top.edge.from.edgesIn.values()) {
if (edgeIn.type !== 'peerOptional') {
fromIsOptional = false
break
}
}

return fromIsOptional
}

get isMine () {
Expand Down
40,747 changes: 38,406 additions & 2,341 deletions workspaces/arborist/tap-snapshots/test/arborist/build-ideal-tree.js.test.cjs

Large diffs are not rendered by default.