Big Bundle size - Tree shaking not working for operators
See original GitHub issueBug Report
Current Behavior When creating a minimal project using rxjs the bundle size for that project is very heavy even when using just one or two operators (+600Kb uncompressed)
Reproduction
- Here I show you a minimal repo where I am just using ONE operator (map operator) and the bundle size is big: https://github.com/sandinosaso/rxjs-big-bundle-bug
import { Observable } from 'rxjs/internal/Observable';
import { map } from 'rxjs/operators';
let x = Observable.create();
x.pipe(
map((v) => v++)
)
Expected behavior I expect the bundle size to be only related to the number of operators I import in this case should be 7.5 Kb and not 577 Kb
Environment
- Runtime: [e.g. Node v${x}, Chrome v${x}]
- RxJS version: 6.5.2
- Webpack 4.32.2
Possible Solution Not sure I thought by the docs that tree shaking should work out of the box for this project. Not sure how to help with this.
Additional context/Screenshots
Before importing operators the bundle size is ( ** 36.8 Kb ** ):

After import just map operator the bundle size is ( ** 577 Kb ** ):

Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Webpack Tree Shaking not working when importing from a file ...
If I remove the moment import from module.js tree shaking works fine and i only see square in my bundle. Is this how...
Read more >Optimize your bundle size by eliminating dead code / tree ...
Today, I want to talk about a very effective method to optimize your bundle size called Tree Shaking. Traditionally, we install a module...
Read more >Tree Shaking: DevExtreme - JavaScript UI Components for ...
The tree shaking mechanism works only when you create the production bundle. Bundle Size. DevExtreme code consists of three main code groups: -...
Read more >PCF Controls - Tree-Shaking For Better Bundle Size
In this post I will show how to optimize the tree-shaking process and reduce the bundle size of PCF controls with simple adjustments...
Read more >Minimize size in webpack | Vue Forums - Syncfusion
Besides this problem, we don't really understand how to use the tree shaking in our project. Is there any other information we could...
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 Free
Top 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

https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md#import-paths
You should NOT be importing from internal locations. Your screen shots indicate you are importing from
rxjs/internal/Observable, etc. Your doing so is not supported.