question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tree shaking does not work on dependencies of dependencies

See original GitHub issue

Converting 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:closed
  • Created 4 years ago
  • Reactions:15
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
simonssspiritcommented, Nov 7, 2019

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.

2reactions
carpbencommented, May 29, 2019

@iansu, @ianschmitz, Do you mind sharing your opinion?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found