Skip to content

Commit

Permalink
Optimize webpack by setting sideEffects to false (#1064)
Browse files Browse the repository at this point in the history
Optimize webpack by setting sideEffects to false

This allows webpack 4 to optimize the bundle by only importing the used modules instead of everything.
  • Loading branch information
0xR authored and TrySound committed Mar 26, 2018
1 parent a91572a commit dc14f16
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer'
import List from 'react-virtualized/dist/commonjs/List'
```

Note webpack 4 makes this optimization itself, see the [documentation](https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free).

If the above syntax looks too cumbersome, or you import react-virtualized components from a lot of places, you can also configure a Webpack alias. For example:

```js
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"jsnext:main": "dist/es/index.js",
"sideEffects": false,
"license": "MIT",
"scripts": {
"build:types": "flow-copy-source --ignore \"**/*.{jest,e2e,ssr,example}.js\" source/WindowScroller dist/es/WindowScroller && flow-copy-source --ignore \"**/*.{jest,e2e,ssr,example}.js\" source/AutoSizer dist/es/AutoSizer ",
Expand Down

0 comments on commit dc14f16

Please sign in to comment.