Solvedangular cli ng serve --watch --aot and lazy loaded modules - doesn't work anymore

CLI 6.0.1
angular 6.0.1
Windows 10 x64

I use the following when I work on the project:

ng serve --ssl --host %NetworkIP% --port 4200 --proxy-config proxy.config.json --watch --aot

and the first time I run the project everything works. But for all subsequent changes in any file of the lazy loaded modules, the module does not load and throws the error:

Uncaught (in promise): TypeError: Cannot read property 'call' of undefined
TypeError: Cannot read property 'call' of undefined
at webpack_require (bootstrap:81)
at Object../src/app/collaboration/components/availableView.component.ngfactory.js (availableCollView.component.ts:20)
at webpack_require (bootstrap:81)
at Object../src/app/collaboration/containers/availableColls.component.ngfactory.js (workCard.component.ts:30)
at webpack_require (bootstrap:81)
at Object../src/app/collaboration/collaboration.module.ngfactory.js (collaboration-routing.module.ts:85)
at webpack_require (bootstrap:81)
at $_lazy_route_resource lazy namespace object:61

etc. So I have to restart ng serve every time.

Here's the routing config:

const routes: Routes = [
    ...
   {
      path: "collaboration",
      canActivate: [RoleAuthorizationGuard],
      loadChildren: "./collaboration/collaboration.module#IlgCollaborationModule"
   },
   ...
];

@NgModule({
   imports: [RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })],
   exports: [RouterModule],
   providers: [CanDeactivateGuard]
})
export class AppRoutingModule {}
33 Answers

✔️Accepted Answer

Long story short, use
"@angular-devkit/build-angular": "0.7.0-rc.0",
and problem solved!

Other Answers:

Any news on this ? It would be good to have at least an official statement about the resolution of this issue.

More Issues: