Tree shaking does not work on dependencies of dependencies
See original GitHub issueConverting from ES6 named imports, such as
import {faTimes} from "@fortawesome/pro-light-svg-icons"
import {Range} from "rc-slider"
to specific (“cheery picking”) imports, such as
import {faTimes} from "@fortawesome/pro-light-svg-icons/faTimes"
import Range from "rc-slider/es/Range"
reduced bundle size from 1.01MB to 870kb. I know that this is what we should expect from Lodash, but that tree shaking is possible with named imports . Could it be that CRA, due to its Babel-Webpack configuration, blocks “tree shaking” for named imports?
Project details: “react-scripts”: “2.1.5”, Typescript
Resources: optimizing-js-tree-shaking-1, optimizing-js-tree-shaking-2
Issue Analytics
- State:
- Created 4 years ago
- Reactions:15
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Tree shaking doesn't work on second-level-deep modules ...
one thing that probably could give hints about the internal issue is that seems that dependencies are not entry-point independent.. I mean: if ......
Read more >Tree-Shaking: A Reference Guide - Smashing Magazine
You will not want your dependencies to be fully optimized in a development environment because it will make issues much more difficult to...
Read more >Tree Shaking - webpack
Tree shaking is a term commonly used in the JavaScript context for ... It also can't skip subtree/dependencies since the spec says that...
Read more >Unable to tree shake React and dependencies if they are not ...
As per my understanding - Tree Shaking only works for ES2015 module and Not for CommonJS module. https://webpack.js.org/guides/tree-shaking/.
Read more >Tree-Shaking Problems with Component Libraries - Medium
If you're publishing a component library, offer an ES Module build — and avoid rolling all your modules into a single file. PropTypes...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We are also interested in this improvement.
You can change your own imports, but in cases with third party packages which use name imports internally, you have no option to change it.
@iansu, @ianschmitz, Do you mind sharing your opinion?