Take some time and grok: https://angular.io/guide/styleguide
For example: https://angular.io/guide/styleguide#core-feature-module
Keep the entries in your AppModule to a minimum:
@NgModule({
declarations: [ AppComponent ],
imports: [
BrowserModule,
CoreModule,
IonicModule.forRoot(AppComponent, {
backButtonText: ''
})
],
bootstrap: [ IonicApp ],
entryComponents: [ AppComponent ]
})
export class AppModule {}
Do the heavy lifting in your CoreModule (e.g., your singleton services):
@NgModule({
imports: [
CommonModule,
IonicModule,
AngularFireModule.initializeApp(ENV.firebase),
AngularFirestoreModule,
AngularFireAuthModule,
...
ENV.production ? ServiceWorkerModule.register('/ngsw-worker.js') : []
],
exports: [],
declarations: [],
providers: [
AuthService,
{ provide: ErrorHandler, useClass: IonicErrorHandler },
GeolocationService,
...
{ provide: LoggerService, useClass: ConsoleLoggerService },
MapsApiLoaderService
]
})
export class CoreModule {
constructor( private afs: AngularFirestore,
@Optional() @SkipSelf() parentModule: CoreModule) {
throwIfAlreadyLoaded(parentModule, 'CoreModule');
const settings = { timestampsInSnapshots: true };
afs.app.firestore().settings(settings);
}
}