Tree shaking while bundling
See original GitHub issueIs 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:
- Created 5 years ago
- Reactions:45
- Comments:16 (6 by maintainers)
Top 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 >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
Its february 2020, brexit happened but not this.
@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 😃