maslianok / react-resize-detector

A Cross-Browser, Event-based, Element Resize Detection for React
http://maslianok.github.io/react-resize-detector/
MIT License
1.25k stars 91 forks source link

react-dom is in devDepencencies #76

Closed fhucko closed 5 years ago

fhucko commented 5 years ago

Why is react-dom in devDependencies? It is not needed for runtime? I found it because in my Jest testing project i dont explicitly have react-dom depencency installed.

I expect react-dom to be in dependencies, not in devDependencies. And react as well.

lh0x00 commented 5 years ago

react and react-dom in peerDependencies, it will be install at root node_modules in your project to prevent duplicate version. read more at http://npm.github.io/using-pkgs-docs/package-json/types/peerdependencies.html

fhucko commented 5 years ago

Peer dependencies are not installed automatically. I think this package depends on react and react-dom, so it should be in production dependencies.

From the documentation: NOTE: npm versions 1 and 2 will automatically install peerDependencies if they are not explicitly depended upon higher in the dependency tree. In the next major version of npm (npm@3), this will no longer be the case. You will receive a warning that the peerDependency is not installed instead.

So people have to manually install react and react-dom. If it is desired behavior, then ok, you can close this issue :)

lh0x00 commented 5 years ago

NOTE: npm versions 1 and 2 will automatically install peerDependencies if they are not explicitly depended upon higher in the dependency tree. In the next major version of npm (npm@3), this will no longer be the case. You will receive a warning that the peerDependency is not installed instead. The behavior in npms 1 & 2 was frequently confusing and could easily put you into dependency hell, a situation that npm is designed to avoid as much as possible.

Because your app will crash in some cases if install many version of library. For example: your app will be crashed if install 2 version react, react-dom.

maslianok commented 5 years ago

@hogan thanks for your question.

As @lamhieu-vk mentioned above - we don't want this library to contain sources of react and react-dom. That's why we listed these libraries in the peerDependencies list.

Of course, we can add these libraries to dependencies and, in most cases, this will work. Yarn and NPM are smart enough to resolve such issues. BUT standalone build of RRD library will take about 50kb because of React and ReactDom sources inside.