Skip to content

Initial - tree shake works

Latest
Compare
Choose a tag to compare
@gparlakov gparlakov released this 07 Jun 06:32
· 3 commits to master since this release

There are two modules, one of them is lazy loaded. Plus a shared module. In the shared there are two components tapp-one and tapp-two (tapp from test app and also string that is easy to search for)
When build using ng build --prod we get 0.chunk.js and main.js (plus hashes) which are the main app and the lazy loaded module/components chunk.

  • tapp-one is only used in the app.component
  • tapp-two is only used in the lazy.component
  • both tapp-one and tapp-two are declared and exported from the shated module

The result is that tapp-one can only be seen in main.js and tapp-two can only be seen in 0.chunck.js. Which means that Angular compiler has compiled the factory functions. Then as part of the prod build tree shaking has removed the unused tapp-two function from main.js and the unused tapp-one for the 0.chunk.js.