Skip to content

Add support for catalog references in peer dependencies#6926

Open
WooWan wants to merge 6 commits intoyarnpkg:masterfrom
WooWan:catalog-peerDeps
Open

Add support for catalog references in peer dependencies#6926
WooWan wants to merge 6 commits intoyarnpkg:masterfrom
WooWan:catalog-peerDeps

Conversation

@WooWan
Copy link
Copy Markdown
Contributor

@WooWan WooWan commented Sep 27, 2025

What's the problem this PR addresses?

Fixes: #6925

What?

Added catalog: protocol support in peerDependencies. Previously, catalog: references worked in dependencies and devDependencies but were incorrectly flagged as errors in peerDependencies.

How?

  • Created resolvePeerDescriptorFromCatalog to resolve catalog: references from project configuration

  • Registered a reducePeerDependency hook in the resolution pipeline to intercept and resolve catalog: references in peer deps

Fixes #6925

How did you fix it?

Updated the dependency range validation logic in Manifest.ts to treat catalog: protocol as a valid range format. This prevents catalog references from being
flagged as errors when used in peer dependencies.

...

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@MKruschke
Copy link
Copy Markdown

Hi,
any update on this one would be nice to use also catalog references inside the peerDeps. 🙏🏻

@arcanis
Copy link
Copy Markdown
Member

arcanis commented Nov 7, 2025

I'm not certain that's correct - afaik the reduceDependency hook we use to apply catalog updates doesn't iterate over peerDependencies, so we'd always keep the catalog: range in the peerDependencies field rather than replacing it.

@WooWan
Copy link
Copy Markdown
Contributor Author

WooWan commented Nov 7, 2025

I'm not certain that's correct - afaik the reduceDependency hook we use to apply catalog updates doesn't iterate over peerDependencies, so we'd always keep the catalog: range in the peerDependencies field rather than replacing it.

I'm not very familiar with reduceDependency, do you think the fundamental solution would be to fix reduceDependency so that it iterates over peerDependencies as well?

@arcanis
Copy link
Copy Markdown
Member

arcanis commented Nov 7, 2025

That would be a breaking change, as 3rd-party plugins would have their behavior changed in hard-to-predict ways.

Probably the safest is to introduce a reducePeerDependency hook here and here. I'm a little worried about the potential perf impact but it's worth a shot.

@MKruschke
Copy link
Copy Markdown

Hey,
still looking forward to get catalog ranges enabled for peerDependencies. @WooWan please let me know if you can finished it otherwise I would offer some help.

@WooWan
Copy link
Copy Markdown
Contributor Author

WooWan commented Dec 9, 2025

I've been busy and haven't been able to get to the PR. I'll work on it by next weekend!
@MKruschke

@WooWan
Copy link
Copy Markdown
Contributor Author

WooWan commented Dec 21, 2025

@arcanis @MKruschke Hello! I've added a reducePeerDependency hook and test code. Verified that it works. Happy to get a review!

@thomaswoeckinger
Copy link
Copy Markdown

Is there any progress?

@MKruschke
Copy link
Copy Markdown

@arcanis could you please have a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug?]: Yarn Catalog does not support peerDependencies

4 participants