-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
chore: add all missing peer dependency statements #4243
Merged
+68
−4
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change will do what you think it will do they way it stands:
peerDependency
means styled-components expect the consuming application to have downloaded those dependencies beforehand, which I believe is not the case here (I might be wrong though 😄)To achieve what you want (better dedupe on the consuming apps side) you can simply change the dependencies listed in the
dependencies
array to use the range syntax like you used here. NPM/Yarn will be smart and reuse the dependencies versions already present on the consuming side if there's a match for that range..There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why they're defined in both peer and regular dependencies, with peerDependenciesMeta declaring all but "react" are optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But since the
dependencies
array still defines fixed versions, it'll overwrite the peerDependenciesMeta, won't it? 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it linked against the
styled-components-website
repo and it seems to work as expected (at least using yarn.) A test version is published asstyled-components@6.1.5-rc.0
if you want to give it a shot.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the explicit dependency + permissive peer dep with a bunch of different pms:
Worked (installed only the higher version): yarn, pnpm
Didn't work (installed both versions): npm, bun
The tricky thing is with
react
the range is really wide (16.8 and up basically.) I could move things out of peerDependencies into devDependencies, but basically no pm automatically installs peerDependencies out of the box so users would get hit with an error to add the dependency explicitly. The goal of this was to ensure the relevant libraries are available at least at the version we specify, with peerDependencies meant to deduplicate to a greater applicable version if defined in the client repository.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened an issue against npm, I think yarn and pnpm behavior is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, interesting one.. I expected PMs to make
dependencies
take precedence overpeerDependencies
as, to me,peerDependencies
was purely informational to let consuming apps know that you expect something to be there.. However, that doesn't seem to be the behavior the accepted RFC you linked describes..Even if they fix npm, it'll take time for people to adopt the version with the fix..
IMHO, if I consume a library that has a dependency:
"A": "^1.1.0"
, I would think that library was integration-tested with that package with that version, although anything in the range might work..You just precisely described (in my understanding) the
dependencies
array when used with ranges :DThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imported
styled-components@6.1.5-rc.0
into the styled-components-website and ranyarn
.. it did not take into account the peerDependencies array (that specifiespostcss: ^8.4.31
- should've resolved postcss to 8.4.32)..When I removed the
peerDependencies
and set thedependencies
to be a range (postcss: ^8.4.0
for testing purposes), it resolved postcss to 8.4.32There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more obvious in the repo I linked in the bug ticket since that repo has postcss saved already at a higher version