Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Why peerDependencies over just dependencies? #279

Closed
chrisdhanaraj opened this issue May 23, 2017 · 1 comment
Closed

Why peerDependencies over just dependencies? #279

chrisdhanaraj opened this issue May 23, 2017 · 1 comment

Comments

@chrisdhanaraj
Copy link

So when I look through the package.json of your OSS projects and others (in this case, glamorous), I notice that many will add certain packages they depend on as peerDependencies instead of just dependencies. I'm curious to what the benefit is of this - at first glance, it just makes the user go through one more install step. Thanks!

@kentcdodds
Copy link
Owner

Hi @chrisdhanaraj,
You're correct! The user does have to go through one more install step. But you could also think of it as: "The user gets to go through one more install step." Specifically, that the user gets to choose which version of the peerDependency they want to use. Especially for React-based projects, it's better for them to list React as a peerDependency because you don't want each of your component libraries to bring all of React with them. It's like making a batch of cookies. You already have the flour, and you don't want the sugar to bring flour with it too. The flour is a peer-dependency of the sugar.

For glamorous specifically, I didn't want to bundle glamor with it because I see them as complimentary. I want people to use glamor directly in their app when it makes sense, and glamorous in other places. They interop so well together, and serve different use cases.

I hope that's helpful!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants