问题
I have gone through this article : https://www.reddit.com/r/Angular2/comments/6a678s/primeng_vs_material2/ In the comment they mentioned we can use Prime Ng and Angular material together in app. In PrimeNg components are standalone modules mostly so you can add only the ones you need and same is true for Angular material after couple of updates.
My question is... Can we use multiple number of libraries as many as we want with Angular app Like: PrimeNg, Angular material, Fuse and many more. Without affecting the performance or size of the build, because Tree shaking will take care of it. Basically I want to use Material only for designing layout and some look and feel that.
Also, Does angular(5/6) supports 100% tree shaking or still we need to use Rollup.js ? Gone through multiple article but not sure yet.
回答1:
When you build an Angular app with production flag, every component, service, directive or pipe is referenced at least once (in @NgModule
annotations). At the end of the AOT compilation, the compiler removes these annotations and after that it also removes unreferenced things.
Source
That said, every Angular Material component is a module, which gives you fine grained import of the library.
I don't know PrimeNg, but from what I quickly searched and as you already know it seems to have one module per component too.
Using both libraries should not affect bundle size nor performance, but you should be aware that the "look and feel" differs from UI library to UI library
来源:https://stackoverflow.com/questions/51043663/can-we-use-multiple-libraries-in-angular2-4-5-6-because-it-supports-treeshakin