I was intent to access some lazy-loaded routes defined in a custom extended library. Everything was alright until I'm wanted to build a production package (AOT active). The build passed, but when I'm trying to reach a route I get this error in the browser's console :
Uncaught Error: Uncaught (in promise): Error: Runtime compiler is not loaded
Error: Runtime compiler is not loaded
at e.Jr (main.41ff3398f5c3f189c836.js:1)
at t.project (main.41ff3398f5c3f189c836.js:1)
at t._tryNext (main.41ff3398f5c3f189c836.js:1)
...
I assume that it's related with loadChildren
attribute, when I build the lib, ng-packgr
failed with new Angular 8 lazy-loading synthaxe, arrow function (it's a known issue https://github.com/ng-packagr/ng-packagr/issues/1285).
Lazy Routes are defined in the custom library like this :
export function getRouteModule() {
return RouteModule;
}
export const MAIN_APP_ROUTES: Routes = [
{
path: 'route',
loadChildren: getRouteModule
},
...
];
Then in my consumer project :
@NgModule({
imports: [
BrowserModule,
LibraryModule,
RouterModule.forRoot(MAIN_APP_ROUTES, {useHash: true})
],
declarations: [
AppComponent
],
bootstrap: [AppComponent]
})
export class AppModule {
}
so I tried several synthaxes, the older one combined with Angular library should be great :
{
path: 'route',
loadChildren: '@MyLib/route/route.module#RouteModule'
},
...
but it doesn't worked.
Any idea ?