Skip to content

Commit

Permalink
fix(compiler-cli): avoid handling functions in loadChildren as lazy l…
Browse files Browse the repository at this point in the history
…oad 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
  • Loading branch information
Meligy authored and matsko committed Jan 11, 2017
1 parent 338be6d commit 313683f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/@angular/compiler-cli/src/ngtools_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 313683f

Please sign in to comment.