feat(nm): Better workspace peer dependencies treatment #3305
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's the problem this PR addresses?
When you use workspace peer dependencies with pnp linker and then switch the project to nm linker, the workspace peer dependencies contract might not be fulfilled, because of the limitations of Node resolution algorithm. It is to be expected. However, we CAN make the developer experience better in this case by detecting the cases when we hit limitations and providing warnings and guidance to the user on how to adjust his project minimally so that all workspace peer dependencies contracts were met.
How did you fix it?
First, I must explain how workspace peer dependencies work. There is one rule of Yarn 1.x and there are at least two rules of Yarn 2+ core for workspace peer dependencies:
Ideally, the nm linker should check all the 3 rules above and report problems with the resulting install if any of the above assumptions cannot be met due to Node resolution algorithm limitations. This task is challenging both in the sense that the nm linker must operate on only ONE graph and that it must meet the same assumptions that are defined on MULTIPLE dependency graphs and in the sense of providing good explanations to the user.
Challenges list:
--preserve-symlinks
Super challenges:
resolutions
Checklist