Angular 9: Explain improvements in Tree-Shaking

Technology CommunityCategory: AngularAngular 9: Explain improvements in Tree-Shaking
VietMX Staff asked 3 years ago

Tree Shaking is performed by both Renderer2 and Ivy. But in some cases suppose, we have imported a function and is hidden by some false conditional, but that function will still get included in the bundle, even though it’s never called for renderer 2.

Ivy, on the other hand, breaks things down into smaller, more atomic functions. These atomic functions make the renderer code much more friendly to tree-shaking, because they generate only the code you need from the template you’ve written. As a result you no longer ship the entire framework code, you only bundle pieces of the framework functionality that you use.