airbnb / react-with-styles

Use CSS-in-JavaScript with themes for React without being tightly coupled to one implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why put react-with-direction in both dependencies and peerDependencies?

liuwuhaoo opened this issue · comments

I think it's wired and, maybe wrong. Is there something i don't think of?

It’s weird but correct.

The dep means nobody has to manually add it to their own deps in the default case, for npm 3+.

The peer dep means nobody will be able to have a conflicting version anywhere in the tree, which is the critical part.

The “not weird” thing would be to only have it as a peer dep, but that adds extra burden on users.

@ljharb thanks for responding very much.
"The peer dep means nobody will be able to have a conflicting version anywhere in the tree" i didn't get it. how peer dep can stop people installing another version? and why cannot people install another version in the tree?

Peer deps hoist to the top. It doesn’t stop anyone from installing a conflicting version, but it will make npm ls error our, which means they have an invalid dep tree.

got it. so, putting it in peer dep can tell users they maybe install a conflicting version.
i still dont think a package should be both dep and peer dep. thanks anyway.