yarnpkg / yarnpkg/berry

[Feature] Peer dependency resolutions

Open
#4,099 6 comments 29 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
8.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

  • 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

As a developer, I want to overwrite the version number of a peer dependency in a nested package, so that Yarn will stop warning that the installed version of the dependency doesn't satisfy the requested version, but will still check the peer dependency using the new version number I've specified.

Describe the solution you'd like

I can think of a few options, each having its own set of potential drawbacks:

  1. Create a new peerResolutions field.
  2. Allow resolutions to replace peerDependencies as well as dependencies.
  3. Allow packageExtensions to overwrite existing peer dependencies, maybe with a new syntax where I provide version: XXX and overwrite: true.

Describe the drawbacks of your solution

  1. More fields to support.
  2. I'm not sure, actually. It feels like this would be safe, but I have to imagine there's some reason it doesn't already work this way.
  3. More syntax to support, potentially dangerous, fundamentally changes the purpose of packageExtensions.

Describe alternatives you've considered

I haven't had any success ignoring the mismatched peer dependencies using peerDependenciesMeta, nor trying to adjust them with resolutions; neither seems to work.

I could use logFilters to discard matching messages, but that's not much of a solution, and doesn't suppress the warning "Some peer dependencies are incorrectly met".

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how Yarn handles peerDependencies, resolutions, packageExtensions, peerDependenciesMeta, and logFilters, then compare the three proposed approaches. The work is done when one supported mechanism lets users override a nested peer dependency version, validates against that version, and removes the reported mismatch warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.