Tree shaking create-react-app? Tree shaking create-react-app? reactjs reactjs

Tree shaking create-react-app?


If your project was built with create-react-app, the latest version has the fix, just update react-scripts to version 2.0.4 or higher.

npm install react-scripts@latest --save

This new version has excellent tree shaking thanks to the updated dependencies. I've tested with both material-ui and mdi-material-ui.


We rewrote our imports for material-ui in our create-react-app-typescript project by changing them from this style:

import {FloatingActionButton} from "material-ui";

to this:

import FloatingActionButton from "material-ui/FloatingActionButton";

Edit:This gives a little more context: https://github.com/mui-org/material-ui/issues/11916#issuecomment-401214838