-
Notifications
You must be signed in to change notification settings - Fork 128
package.json misconfigured #75
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
Comments
dependencies are required to run, devDependencies only to develop, e.g.: unit tests, CoffeeScript to Javascript transpilation, minification, ... React is a dependency because it is included in the final build. More Details: |
Sorry for the late reply This is incorrect. For reusable components: Put a react dependency in both peerDependencies and devDependencies. Putting react in dependencies will cause multiple versions of React to be installed if somebody uses your component but has a different version of React in their own package.json - having multiple versions of React not only bloats the build, but also causes errors when different versions try to interact. Also imperical proof from libraries already doing this styled-components: https://github.com/styled-components/styled-components/blob/master/packages/styled-components/package.json material-ui: https://github.com/mui-org/material-ui/blob/master/packages/material-ui/package.json formik: https://github.com/jaredpalmer/formik/blob/master/package.json |
For this reason alone we had to ditch this library and use our own. |
I am facing the same issue. Is there an update on this? |
me too facing same issue. Having multiple versions of React not only bloats the build, but also causes errors when different versions try to interact. We are using latest react version (16.12.0) with hooks support, but this library causes some error due to different versions of react installed. Kindly move the react and react-dom from dependencies to devDependencies. To add to @andrewl913 list, another popular library which doing this. react-dates (by airbnb) - https://github.com/airbnb/react-dates/blob/master/package.json react-accessible-accordion - https://github.com/springload/react-accessible-accordion/blob/master/package.json react-google-maps - https://github.com/tomchentw/react-google-maps/blob/master/package.json react-id-swiper - https://github.com/kidjp85/react-id-swiper/blob/master/package.json |
This logic applies to react applications(projects). Not for reusable components. This library is a reusable component used on other react projects. So it make sense to move the react to devDependency and inform the consumer of the library through peerDependency and avoid bloating the final build having multiple versions of react. In the same SO thread look at another answer - https://stackoverflow.com/questions/48861868/why-react-should-usually-be-a-prod-dependency-and-not-dev-dependency/48861985#48861985
|
…ed other version with 'npm audit fix'
i removed the direct react + react-dom dependency and kept them in peerDependencies in #152. it isn’t necessary to have them in devDependencies because
|
Looks like react and reace-dom is not only a dependency but also a peer dependency. This can cause issues for those using mono repo workflows such as lerna or yarn workspaces..
Should remove the dependencies and place them in devDependencies
The text was updated successfully, but these errors were encountered: