I've splitted my app into two modules: one with main basic functionality and other with less-used features like account settings, faq pages and more.
What I'm trying to accomplish is to lazy load the second module for some root route paths, like /account or /settings without having to create many different modules. As far as I know Angular lazy load only works with one root route, and the routes configured in the lazy loaded module are set as children of that route.
{
path: 'account',
loadChildren: './modules/settings/settings.module#SettingsModule',
},
{
path: 'settings',
loadChildren: './modules/settings/settings.module#SettingsModule',
},
The Angular team is working on standalone components, that could potentially make loading some rarely used parts less painful:
https://blog.angular.io/an-update-on-standalone-components-ea53b4d55214
One easy (although not 100% optimal) way that is good enough for a lot of requirements probably is using a single shared module - that way your extra overhead is "just" to create another feature module
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With