Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Isaacs/links to root causing unreportable eresolve #259

Closed
wants to merge 17 commits into from

Conversation

isaacs
Copy link
Contributor

@isaacs isaacs commented Apr 1, 2021

Fix: npm/cli#2896

This provides the currentEdge as a thing that can be reported on in the CLI if somehow the current and peerConflict nodes aren't found.

It also fixes the edge case triggered by having a dependency of file:. in the root node's package.json which then is in conflict with a peerDependency of another root dependency, which is that the Link creates a target with the same path as the root node, but which is not the root node, and results in some truly spectacular splintering.

Based on #258.

This causes major problems when moving links and targets between trees.
When we move the link from one tree to another, it pulls its target,
out, meaning that the target ends up becoming orphaned.

Say there is a matching link and target in two different trees, A and B,
and we want to replace the link and target in one tree with the link and
target in another.

If we move the target A to tree B first, then it replaces the target B,
and link B is updated to point to it.

Then, we move link A to tree B, replacing link B.  To do that, we move
link B out of tree B, which _takes target B with it_, leaving the ported
link A without a target in tree B.
This also corrects an issue where manually updating the package.json
file would sometimes not be reified properly, if a new link target
matches the one that was formerly reified.
Fixes sorting incorrectly when a dependency is set to an empty string
This is in preparation for the use case where explicitRequests includes
edges from nodes other than the project root, so that we can add deps
to workspaces.
This is really important for debugging when "have workspaces been loaded
yet" is a relevant consideration.
This provides another fail-safe for the CLI to report _something_ useful
to the user when an ERESOLVE happens, if by some brokenness in our tree
handling we don't have the node in the tree somehow to provide a current
or peerConflict.
@isaacs isaacs requested a review from nlf April 1, 2021 01:25
fsParent: null,
root: this.root,
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for future reviewers, this is the meat of this fix and it 100% makes sense 🎉

@isaacs isaacs closed this in 3e907ba Apr 1, 2021
@wraithgar wraithgar deleted the isaacs/links-to-root-causing-unreportable-eresolve branch April 22, 2021 17:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Fix ERESOLVE error output
2 participants