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 while bundling

See original GitHub issue

Is it possible anyhow to implement tree shaking during bundling.

Suppose I have a file say greetings.js:

export const sayHi = (name) => {return `Jarvis says hi to ${name}`};
export const sayBye = (name) => {return `Jarvis says bye to ${name}`};

Now if in my project I am only using sayHi then I want sayBye to be removed from the final bundle which is currently not the case. Is it possible anyhow to implement this (even if I had to do changes in the config file for the metro bundler).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:45
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

62reactions
neikercommented, Feb 6, 2020

Its february 2020, brexit happened but not this.

60reactions
cpojercommented, Feb 7, 2020

@rafeca and @mjesun have since left Facebook. We are not actively working on tree shaking at Facebook and are exploring other more promising ways to keep our app size small.

If you are using Metro for React Native, it is unlikely that tree shaking will have a major impact on your applications size or behavior. If you are looking for size improvements, consider compressing the JS bundle that you ship with your app. If you are looking for performance improvements, there are likely many other things (like shipping Hermes and bytecode) that will have a large impact.

I’ll close this as wontfix now but we will accept contributions towards tree shaking – and I’m accepting your job applications if you wanna work on this kinda stuff at Facebook London 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tree-Shaking: A Reference Guide - Smashing Magazine
“Tree-shaking” is a must-have performance optimization when bundling JavaScript. In this article, we dive deeper on how exactly it works and ...
Read more >
Tree Shaking - webpack
Tree shaking is a term commonly used in the JavaScript context for dead-code elimination. It relies on the static structure of ES2015 module...
Read more >
Tree shaking and code splitting in webpack - LogRocket Blog
Tree shaking, also known as dead code elimination, is the practice of removing unused code in your production build. It's important to ship...
Read more >
How Tree-shaking in JavaScript Bundlers work
Tree shaking is a technique used in dead code elimination which aims to reduce bundle size by removing unused functions, imports and statements....
Read more >
Tree Shaking - Patterns.dev
Tree shaking is aimed at removing code that will never be used from a final JavaScript bundle. When done right, it can reduce...
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