Let's say we have a big NgModule
the SharedModule
, which exports a lot of components which are needed in multiple components. By importing the SharedModule
into a feature module there is often an overhead because all the shared components get imported and not just those which are necessary. Does splitting the SharedModule
decrease the build-/compilation time? Are there any advantages to split it into smaller modules besides maybe better readable code?
Thanks a lot for your help!
From the official site angular.io:
The root module is all you need in a simple application with a few components. As the app grows, you refactor the root module into feature modules that represent collections of related functionality. You then import these modules into the root module.
and
Delineating areas of your app helps with collaboration between developers and teams, separating directives, and managing the size of the root module. A feature module is an organizational best practice, as opposed to a concept of the core Angular API.
There is nothing about decrease the build-/compilation time, so I think it makes sense
For large apps with lots of routes, consider lazy loading—a design pattern that loads NgModules as needed.