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 theapp.component
tapp-two
is only used in thelazy.component
- both
tapp-one
andtapp-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
.