From 313683f6f35070f1920ee35291b03767d130e6aa Mon Sep 17 00:00:00 2001 From: Meligy Date: Sat, 31 Dec 2016 20:24:58 +1100 Subject: [PATCH] fix(compiler-cli): avoid handling functions in loadChildren as lazy load routes paths The change avoids the compiler CLI internal API from mismatching the following case as lazy loading ``` import { NonLazyLoadedModule } from './non-lazy-loaded/non-lazy-loaded.module'; export function getNonLazyLoadedModule() { return NonLazyLoadedModule; } export const routes = [ { path: '/some-path', loadChildren: getNonLazyLoadedModule } ]; ``` The output of the check is later passed to `RouteDef.fromString()`, so, it makes sense to be only a string. Fixes angular/angular-cli#3204 --- modules/@angular/compiler-cli/src/ngtools_impl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/@angular/compiler-cli/src/ngtools_impl.ts b/modules/@angular/compiler-cli/src/ngtools_impl.ts index fea594bfe3b22..b956c6cb178c4 100644 --- a/modules/@angular/compiler-cli/src/ngtools_impl.ts +++ b/modules/@angular/compiler-cli/src/ngtools_impl.ts @@ -198,7 +198,7 @@ function _collectRoutes( */ function _collectLoadChildren(routes: Route[]): string[] { return routes.reduce((m, r) => { - if (r.loadChildren) { + if (r.loadChildren && typeof r.loadChildren === 'string') { return m.concat(r.loadChildren); } else if (Array.isArray(r)) { return m.concat(_collectLoadChildren(r));