Hi Santosh, I followed your post and I find it misleading. I might be wrong but I just wanted to confirm with you about my investigation.
Based on my analysis: if you only use required material modules in the shared material module, you might not pay the penalty that you’re talking about. The problem in this blog is you are comparing a scenario where the shared material module is importing unwanted modules VS individual modules imports only required modules.
Based on my analysis, when I used only required material modules in the shared material module file, I got 666.09 KB using the shared material module vs 665.37 KB using material modules directly in the sub modules.
FYI: here’s my repo
Hey Bhavik, thanks for your response, here is one of the stats which I received, you are comparing it in a small app, just do the same practice in a large app, where there are multiple modules using different modules.
Thanks Santosh, If that’s the case then I’m pretty sure Angular team is working on to improve the tree shaking to remove unused imports
So what would you suggest? Importing whatever material components I might need in every feature module? Wouldn’t it be better in that case to import them once in the app.module?
I always suggest import what is needed, you will get better bundle size when doing lazy loading.