Skip to content

Commit 2f1506c

Browse files
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.
1 parent 5b672ea commit 2f1506c

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

src/interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { StateDeclaration, _ViewDeclaration, Transition, HookResult } from '@uirouter/core';
55
import { Type, Component } from '@angular/core';
6-
import { NgModuleToLoad } from './lazyLoad/lazyLoadNgModule';
6+
import { ModuleTypeCallback } from './lazyLoad/lazyLoadNgModule';
77

88
/**
99
* The StateDeclaration object is used to define a state or nested state.
@@ -155,7 +155,7 @@ export interface Ng2StateDeclaration extends StateDeclaration, Ng2ViewDeclaratio
155155
* }
156156
* ```
157157
*/
158-
loadChildren?: NgModuleToLoad;
158+
loadChildren?: ModuleTypeCallback;
159159
}
160160

161161
export interface Ng2ViewDeclaration extends _ViewDeclaration {

src/lazyLoad/lazyLoadNgModule.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@ import { applyModuleConfig } from '../uiRouterConfig';
2828
* ```
2929
*/
3030
export type ModuleTypeCallback = () => Type<any> | Promise<Type<any>>;
31-
/**
32-
* A string or a function which lazy loads a module
33-
*
34-
* If a string, should conform to the Angular Router `loadChildren` string.
35-
* #### Example:
36-
* ```
37-
* var ngModuleToLoad = './foo/foo.module#FooModule'
38-
* ```
39-
*
40-
* For functions, see: [[ModuleTypeCallback]]
41-
*/
42-
export type NgModuleToLoad = string | ModuleTypeCallback;
4331

4432
/**
4533
* Returns a function which lazy loads a nested module
@@ -81,7 +69,7 @@ export type NgModuleToLoad = string | ModuleTypeCallback;
8169
* - Returns the new states array
8270
*/
8371
export function loadNgModule(
84-
moduleToLoad: NgModuleToLoad
72+
moduleToLoad: ModuleTypeCallback
8573
): (transition: Transition, stateObject: StateDeclaration) => Promise<LazyLoadResult> {
8674
return (transition: Transition, stateObject: StateDeclaration) => {
8775
const ng2Injector = transition.injector().get(NATIVE_INJECTOR_TOKEN);
@@ -109,7 +97,10 @@ export function loadNgModule(
10997
*
11098
* @internalapi
11199
*/
112-
export function loadModuleFactory(moduleToLoad: NgModuleToLoad, ng2Injector: Injector): Promise<NgModuleFactory<any>> {
100+
export function loadModuleFactory(
101+
moduleToLoad: ModuleTypeCallback,
102+
ng2Injector: Injector
103+
): Promise<NgModuleFactory<any>> {
113104
if (isString(moduleToLoad)) {
114105
return ng2Injector.get(NgModuleFactoryLoader).load(moduleToLoad);
115106
}

0 commit comments

Comments
 (0)