Note: I've searched a dozen other related questions regarding lazy loading on SO, but I wasn't able to solve my issue using them.
Error: Cannot find 'ContactModule' in 'app/contact.module'
I have started with a new project based on Angular CLI and the node console in Windows mentions webpack: Compiling... occasionally so I believe I'm using that, however I do not see any webpack.config.js in my project which other questions mentioned needing changes to.
Here's my app.module.ts:
const appRoutes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'contact', loadChildren: 'app/contact.module#ContactModule' },
];
//...imports...
@NgModule({
declarations: [
AppComponent,
HomeComponent,
// ContactComponent,
// ContactFormComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
JsonpModule,
RouterModule.forRoot(appRoutes)
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
My sub module for lazy loading:
//...imports...
const ROUTES = [
{ path: '', component: ContactComponent },
];
@NgModule({
declarations: [
ContactComponent,
ContactFormComponent
],
imports: [RouterModule.forChild(ROUTES)],
})
class ContactModule {}
And some images of my folder structure and packages.json in case those are helpful.
