To my understanding the reason for a CoreModule
was to have all the things necessary to initialize your application and also to hold services that were to be shared across all modules in the application (HttpInterceptors, AuthenticationService, etc). Now that we have provideIn: 'root'
, is there a reason to have a CoreModule anymore? Is this pattern now deprecated? Is there a use case where we still might want to have a CoreModule
that holds all or some of the shared services?
You can checkout angular style guide: https://angular.io/guide/styleguide#core-feature-module.
A reason is the separation of concepts, coreModule must have only modules, providers, components, others that should only be at appModule and not at any other module of your app. This also helps you to make your app module cleaner.
Here you can set HttpClientModule, HTTP_INTERCEPTORS, BrowserAnimationsModule, others.
You can also check out my project where I implemented angular style guide recommendations, such as the core module: here