From 2f1506c774d27a3963c170b9ef6ccefc7050f443 Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Sun, 10 Nov 2019 15:22:43 -0800 Subject: [PATCH] feat(lazyLoad): Remove NgModuleToLoad type (string based lazy module loading) BREAKING CHANGE: Removed string based lazy module loading via loadChildren Previously, we supported `loadChildren: './lazymodule/lazy.module.ts#LazyModule'` This lazy load mechanism is deprecated in Angular 8 in favor of: `loadChildren: import('./lazymodule/lazy.module).then(x => x.LazyModule)` Migrate your `loadChildren`(s) to the `import()` style. --- src/interface.ts | 4 ++-- src/lazyLoad/lazyLoadNgModule.ts | 19 +++++-------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/interface.ts b/src/interface.ts index 734f94108..0b0291094 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -3,7 +3,7 @@ import { StateDeclaration, _ViewDeclaration, Transition, HookResult } from '@uirouter/core'; import { Type, Component } from '@angular/core'; -import { NgModuleToLoad } from './lazyLoad/lazyLoadNgModule'; +import { ModuleTypeCallback } from './lazyLoad/lazyLoadNgModule'; /** * The StateDeclaration object is used to define a state or nested state. @@ -155,7 +155,7 @@ export interface Ng2StateDeclaration extends StateDeclaration, Ng2ViewDeclaratio * } * ``` */ - loadChildren?: NgModuleToLoad; + loadChildren?: ModuleTypeCallback; } export interface Ng2ViewDeclaration extends _ViewDeclaration { diff --git a/src/lazyLoad/lazyLoadNgModule.ts b/src/lazyLoad/lazyLoadNgModule.ts index bd9fc7e69..de2ed2fc7 100644 --- a/src/lazyLoad/lazyLoadNgModule.ts +++ b/src/lazyLoad/lazyLoadNgModule.ts @@ -28,18 +28,6 @@ import { applyModuleConfig } from '../uiRouterConfig'; * ``` */ export type ModuleTypeCallback = () => Type | Promise>; -/** - * A string or a function which lazy loads a module - * - * If a string, should conform to the Angular Router `loadChildren` string. - * #### Example: - * ``` - * var ngModuleToLoad = './foo/foo.module#FooModule' - * ``` - * - * For functions, see: [[ModuleTypeCallback]] - */ -export type NgModuleToLoad = string | ModuleTypeCallback; /** * Returns a function which lazy loads a nested module @@ -81,7 +69,7 @@ export type NgModuleToLoad = string | ModuleTypeCallback; * - Returns the new states array */ export function loadNgModule( - moduleToLoad: NgModuleToLoad + moduleToLoad: ModuleTypeCallback ): (transition: Transition, stateObject: StateDeclaration) => Promise { return (transition: Transition, stateObject: StateDeclaration) => { const ng2Injector = transition.injector().get(NATIVE_INJECTOR_TOKEN); @@ -109,7 +97,10 @@ export function loadNgModule( * * @internalapi */ -export function loadModuleFactory(moduleToLoad: NgModuleToLoad, ng2Injector: Injector): Promise> { +export function loadModuleFactory( + moduleToLoad: ModuleTypeCallback, + ng2Injector: Injector +): Promise> { if (isString(moduleToLoad)) { return ng2Injector.get(NgModuleFactoryLoader).load(moduleToLoad); }