Giners / mui-places-autocomplete

Google Material Design (Material-UI) styled React component using Google Maps Places Autocomplete
MIT License
34 stars 26 forks source link

Bug fix: Set 'react' and 'material-ui' as 'peerDependencies' #9

Closed Giners closed 6 years ago

Giners commented 6 years ago

This commit fixes an issue where we were bundling up 'react' and 'material-ui'. This was bad as since we expect our component/module/package to be consumed we can be certain that the consumers already have the 'react' and 'material-ui' modules as dependencies. As a result duplicate modules were loaded which caused problems such as MUI components/elements to lose their styling in SSR use cases.

We fix the issue by setting the 'react' and 'material-ui' modules as 'peerDependencies' to our package. We do add them as 'devDependencies' so that work can be done on our component directly in this repo/package folder. To ensure that we don't bundle 'react' and 'material-ui' when we install them as 'devDependencies' we use 'webpack-node-externals' to cause webpack to exclude everything in 'node_modules' from being bundled and then whitelisting our few actual 'dependencies'.

This commit fixes bug: #7 modified: package.json modified: test/test.jsx.snap modified: webpack.config.js modified: yarn.lock