Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional peer dependencies are incorrectly listed in package.json #1559

Closed
mprast opened this issue Apr 2, 2020 · 2 comments
Closed

Optional peer dependencies are incorrectly listed in package.json #1559

mprast opened this issue Apr 2, 2020 · 2 comments

Comments

@mprast
Copy link

mprast commented Apr 2, 2020

Currently react-dom and react-native are listed as optional peer dependencies of react-redux, but they are only listed in peerDependenciesMeta and not in peerDependencies. Looking at the RFC for optional peer dependencies in Yarn v2, I'm pretty sure the correct way is to list them in both fields:
yarnpkg/rfcs#105 (comment)

Consistent with this, I'm seeing yarn v2 (with pnp) complaining that A package is trying to access another package without the second one being listed as a dependency of the first one, even when react-dom is a dep of the react-redux's direct ancestor.

Happy to provide a PR and\or a repro if you'd like!

redux: 4.0.5
react-redux: 7.2.0
react-dom: 16.12.0

@timdorr
Copy link
Member

timdorr commented Apr 2, 2020

This is for backwards compatibility with versions of npm/yarn that don't support peerDependenciesMeta. If we add them to peerDependencies, there will be a warning emitted for every installation (since you shouldn't have both packages). By putting them in peerDependenciesMeta, package managers that support the field will assume both are optional.

Even if we implemented the fields fully, it doesn't actually represent what we want: one of the two is required to be installed. That hasn't yet been added to the spec.

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

No branches or pull requests

3 participants