-
Notifications
You must be signed in to change notification settings - Fork 64
Do not ERESOLVE on peerOptionals not added to tree #227
Conversation
"optional": false, | ||
"path": "{CWD}/test/fixtures/peer-optional-eresolve/a/node_modules/@isaacs/testing-peer-optional-conflict-a-x", | ||
"peer": false, | ||
"realpath": "{CWD}/test/fixtures/peer-optional-eresolve/a/node_modules/@isaacs/testing-peer-optional-conflict-a-x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heads up, looks like cleanSnapshot
is failing to clean {CWD}
in all windows ci targets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I missed something there. Gotta get that fixed before landing, might be a real issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM
test/arborist/build-ideal-tree.js
Outdated
for (const c of cases) { | ||
t.test(`case ${c}`, async t => { | ||
const path = resolve(base, c) | ||
t.matchSnapshot(await buildIdeal(path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.matchSnapshot(await buildIdeal(path)) | |
t.matchSnapshot(await printIdeal(path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhhh, right, because the print does the cleanup. Thanks!
6e4824e
to
2f8dc90
Compare
For these dependency graphs: # case a root -> (x, y@1) x -> PEEROPTIONAL(z) z -> PEER(y@2) # case b root -> (x) PEEROPTIONAL(y@1) x -> PEEROPTIONAL(y@2) # case c root -> (x) PEEROPTIONAL(y@1) x -> PEER(z) z -> PEEROPTIONAL(y@2) The peerOptional dependency is included in the peerSet, which would raise an ERESOLVE conflict at the peerSet generation stage, even though the peerOptional dependencies will not actually be added to the tree. To address this, this commit tracks the nodes which are actually required in the peerSet generation phase, by virtue of being non-optionally depended upon by a required node in the peerSet. If a conflict occurs on a node which is not in the required set during the peerSet generation phase, we ignore it in much the same way that we would ignore peerSet errors in metadependencies or when --force is used. Of course, if the peerOptional dependency is _actually_ required, to avoid a conflict with an invalid resolution present in the tree already, and there is no suitable placement for it, then ERESOLVE will still be raised. Fix: #223 Fix: npm/cli#2667 PR-URL: #227 Credit: @isaacs Close: #227 Reviewed-by: @ruyadorno
2f8dc90
to
f375873
Compare
Based on #225, land that first.
For these dependency graphs:
The peerOptional dependency is included in the peerSet, which would
raise an ERESOLVE conflict at the peerSet generation stage, even though
the peerOptional dependencies will not actually be added to the tree.
To address this, this commit tracks the nodes which are actually
required in the peerSet generation phase, by virtue of being
non-optionally depended upon by a required node in the peerSet.
If a conflict occurs on a node which is not in the required set during
the peerSet generation phase, we ignore it in much the same way that we
would ignore peerSet errors in metadependencies or when --force is used.
Of course, if the peerOptional dependency is actually required, to
avoid a conflict with an invalid resolution present in the tree already,
and there is no suitable placement for it, then ERESOLVE will still be
raised.
Fix: #223
Fix: npm/cli#2667