Add sideEffects: false to react-router-dom package.json #6082
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Webpack 4.0 introduced support for a
sideEffects
flag in a project'spackage.json
: https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free. This is awesome because we can now get Webpack's tree shaking to work as intended for most, if not all projects. 🎉I've noticed that in my projects where I've used
react-router-dom
, the recommended import syntax (eg.import { Route } from 'react-router-dom'
) still pulls in the entire library. While react-router-dom and it's associated packages aren't that large, I'm a bit of a performance junkie 😃. All this PR does is add thesideEffects: false
flag to thereact-router-dom
package. I created a simple test repo to demo the effects of this flag: https://github.com/taylorc93/react-router-test. I'm noticing ~20KB of minified JS removed from my bundle as a result of this change.The only thing I'm slightly unsure of is whether there are, in fact, side effects. From what I can see, there aren't any, but I could definitely be missing something. Let me know what you think / if there's anything else you need from me to get this merged!
Side note: Love this project, I've been using it for years and it's worked fabulously. Keep up the great work!