berry icon indicating copy to clipboard operation
berry copied to clipboard

[Feature] The in-built facts database for yarn constraints does not include transitive dependencies

Open anuragkalia opened this issue 4 years ago • 4 comments

  • [x] I'd be willing to implement this feature (contributing guide)
  • [ ] This feature is important to have in this repository; a contrib plugin wouldn't do

Describe the user story

In my organization, we have a lot of packages used over time. And they have built a lot of transitive dependencies.

hence, when I am using Av3 and Bv3, it is possible Bv3 internally depends on Av2. I want to proactively detect that both Av1 and Av2 exist in my dependency tree.

But when I printed the knowledge database using yarn constraints source -v, it does not have this information. This is frustrating because I really like the idea of declaratively adding constraints using prolog. Moreover, the information already exists in yarn when I query yarn info -R -A.

So, it means, yarn constraints is not useful to me because of incomplete data and i will write imperative code for such checks anyway.

Describe the solution you'd like

Add the transitive dependency information in yarn info -R -A available in the constraints facts database.

Describe the drawbacks of your solution

It may be a little slower to process for the increase the database but I don't think it will materially affect the execution.

Describe alternatives you've considered

Building a script around yarn info -R -A.

anuragkalia avatar Feb 07 '22 18:02 anuragkalia

It may be a little slower to process for the increase the database but I don't think it will materially affect the execution.

It takes ~4 minutes in one of my monorepos to run constraints. There's a lot of transitive dependencies. Unless there's a way to speed up performance, I imagine increasing the number of facts drastically would make it impossible to run constraints. I do like the idea of operating with transitive dependencies though.

noahnu avatar Feb 08 '22 21:02 noahnu

I'd love to have this feature. If performance is a concern, it can be behind an optional flag, e.g. yarn constraints --include-transitive

Mithras avatar Mar 17 '22 04:03 Mithras

I'm also interested in this feature. Specifically, I'd like to enforce that the lockfile doesn't contain more than one entry for certain packages.

@arcanis With the changes in https://github.com/yarnpkg/berry/pull/5026, is this an enhancement that's been considered before?

jtbandes avatar Apr 26 '23 16:04 jtbandes

Now that the new constraint engine has shipped, could this feature be considered for inclusion?

jtbandes avatar Apr 29 '24 22:04 jtbandes