So my issue is that i would like to preload all of my child route modules. I have the below in my root routing module
RouterModule.forRoot(appRoutes, { preloadingStrategy: AppCustomPreloader })
AppCustomPreloader looks like the following
export class AppCustomPreloader implements PreloadingStrategy {
preload(route: Route, load: Function): Observable<any> {
try {
return route.data && route.data.preload ? load() : Observable.of(null);
}
catch (ex) {
console.log('error');
}
}
}
For each of the routes in my nested routing module, i have given each one an attribute of data: "true" like below
{
path: 'somepage',
loadChildren: './somedirectory/somemodule.module#SomeModule',
data: { preload: true }
}
Everything preloads correctly but i am getting "Maximum Call Stack Size Exceeded" error in chrome and "Too much recursion" in Firefox.
I have about 10 modules that get preloaded and they are all relatively small. Is the issue that the stack size is actually too big or is the issue that i am missing some sort of infinite routing module load. What is a good way to debug the 2 possibilities?
Without posting your routes it's hard to say. Here's some steps that helped me build a very complex router:
RouterModule.forRoot(appRoutes, { preloadingStrategy: AppCustomPreloader, enableTracing: true })
for more insight on what is happening.