Fix handling of virtual packages in Yarn2#11208
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #11208 +/- ##
============================================
- Coverage 58.31% 58.29% -0.03%
+ Complexity 1760 1759 -1
============================================
Files 356 356
Lines 13259 13261 +2
Branches 1314 1314
============================================
- Hits 7732 7730 -2
- Misses 5039 5043 +4
Partials 488 488
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| } ?: dependency.locator | ||
|
|
||
| packageInfoForLocator.getValue(locator) | ||
| } |
There was a problem hiding this comment.
IIUC This change only works for "direct" dependencies.
A similar logic needs to be put into Yarn2DependencyHandler.dependenciesFor().
How about taking in my above comment mentioned function, and define it as extension property PackageInfo.realLocator next to the other ones in Yarn2DependencyHandler ?
Ideally, the test should be enhanced to have such virtual package as non-direct dependency too.
There was a problem hiding this comment.
...Maybe there is a chance, that the cycle issue goes away with this..
There was a problem hiding this comment.
Ideally, the test should be enhanced to have such virtual package as non-direct dependency too.
Having such a dependency would be a requirement for me to be able to test if Yarn2DependencyHandler.dependenciesFor() was changed correctly. However, I spent a while looking for such a package and could not find one. All dependents of @csstools/css-color-parser have direct dependencies to the peer dependencies of @csstools/css-color-parser and it seems that in this case Yarn does not create a dependency to a virtual package in the tree.
The only idea I have is to create a workspace to simulate the scenario where a transitive dependency points to a virtual package.
There was a problem hiding this comment.
I have added the same dependency to the workspaces test project to verify that the fix now also works for transitive dependencies.
59ebde2 to
e33568d
Compare
ae77f99 to
8f7493e
Compare
`@react-native-community:netinfo:11.2.1` was used to test the handling of virtual packages which Yarn2+ creates when a package has peer dependencies. Replace it with `@csstools:css-color-parser:3.0.8` which in addition to peer dependencies has also normal dependencies to demonstrate the bug that `Yarn2` currently misses the transitive dependencies of such dependencies. Add the same dependency to the workspaces test project to showcase that the bug also occurs if such a package is not a direct but a transitive dependency. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@doubleopen.io>
When a package has peer dependencies, Yarn2+ creates a virtual package for it that is used also in the output of `yarn info`. This virtual package only contains the peer dependencies, while only the non-virtual package contains the transitive dependencies. Fix the issue that transitive dependencies of such packages are ignored by mapping locators that point to virtual packages to locators that point to the non-virtual packages. Fixes #8058. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@doubleopen.io>
|
Merged despite unrelated test failures. |
Adapt a Yarn2 test project to demonstrate the issue described in #8058 (and #11073) and a fix for the problem.
The PR is currently kept a draft because it triggers the issue demonstrated in #11207 for some projects.