Open pauldraper opened 2 years ago
Side note: My goal here is to get a comprehensive list of the resolved package dependency graph for analysis.
If there's a better way to do this, I'd love to know.
It shows dependencies as part of a non-virtual base record. Since those dependencies will never change regardless of the virtual, duplicating them on each virtual record would take a very large amount of vertical space for nothing.
a very large amount of vertical space for nothing.
They are only printed if --virtuals
is explicitly chosen.
Since those dependencies will never change regardless of the virtual
Isn't the entire point of virtual packages is that the (peer) dependencies can change?
Virtual package A1 depends on a virtual package B1, yet yarn info only shows that virtual package A1 depends on concrete package B. That loses information, because B and B1 are not the same package.
That's a bit abstract. Consider the above example, to show why virtuals deps are necessary.
In reality,
webpack@npm:5.66.0 [4c3f2]
depends on acorn-import-assertions@npm:1.8.0 [6d128]
acorn-import-assertions@npm:1.8.0 [6d128]
depends on acorn@npm:8.7.0
.But yarn info
won't reveal that. It only says
webpack@npm:5.66.0 [4c3f2]
existswebpack@npm:5.66.0
depends on acorn-import-assertions@npm:^1.7.6
acorn-import-assertions@npm:1.8.0
has no dependencies (!!)Only virtual packages of acorn-import-assertions
depend on acorn
. But yarn info
fails to tell us which virtual package of acorn-import-assertions
is used by webpack
, because it hides the deps of the webpack
virtual package.
(Again, the idea is to obtain a dependency graph, so that I can consume it with analysis tools.)
Isn't the entire point of virtual packages is that the (peer) dependencies can change?
The peerDependencies
resolutions can change (and those are the ones you see in the Peer dependencies
section from your paste). The dependencies
resolutions are static and cannot change from one virtual to the other, hence why they are factored in their own section.
Virtual package A1 depends on a virtual package B1, yet yarn info only shows that virtual package A1 depends on concrete package B. That loses information, because B and B1 are not the same package.
Right, that's the bug. Yarn does show the dependencies, it's just that it shows the base package rather than the virtual ones 🙂
This is because the base package data structure, used to print the regular dependencies, is never mutated during the virtual tree post-processing (only its virtual instances are) and thus if one of its dependencies get virtualized it'll never know. We'll need to:
Thanks for the thoughts. You're certainly familiar, though from my poking yarn why
it seems that there are virtual -> virtual dependencies that aren't in the base. But I might be wrong about that.
Self-service
Describe the bug
yarn info --virtuals
doesn't show the dependencies of virtual packages.To reproduce
package.json
Run
The output shows
Notice that the virtual package (
webpack@npm:5.66.0 [4c3f2]
) shows no dependencies.I expected it to have a dependency on several packages, including
acorn@npm:8.7.0
andacorn-import-assertions@npm:1.8.0 [6d128]
.Environment
Additional context
In other contexts, the virtual package has the expected dependencies.
For example, going the reverse direction,
acorn@npm:8.7.0
is a dependent ofwebpack@npm:5.66.0 [4c3f2]
.Using why shows the same: