Skip to content

Commit 2dff858

Browse files
authored
refactor: remove unsupported Angular imports (#950)
* refactor: Remove unsupported imports from Angular Angular v13 removes the deprecated `loadChildren: string` syntax as well as the supporting `NgModuleFactoryLoader` and `SystemJsNgModuleLoader`. This commit simply removes those imports and providers. None of the examples or tests appear to be using the `loadChildren: string` syntax. In fact, the `Ng2StateDeclaration.loadChildren` does not even have `string` as a valid type in `ModuleTypeCallback`. See angular/angular@361273f fixes #949 * fixup! refactor: Remove unsupported imports from Angular
1 parent a34d95a commit 2dff858

File tree

5 files changed

+3
-18
lines changed

5 files changed

+3
-18
lines changed

src/lazyLoad/lazyLoadNgModule.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NgModuleRef, Injector, NgModuleFactory, Type, Compiler, NgModuleFactoryLoader } from '@angular/core';
1+
import { NgModuleRef, Injector, NgModuleFactory, Type, Compiler } from '@angular/core';
22
import {
33
Transition,
44
LazyLoadResult,
@@ -84,10 +84,6 @@ export function loadNgModule(
8484
/**
8585
* Returns the module factory that can be used to instantiate a module
8686
*
87-
* For strings this:
88-
* - Finds the correct NgModuleFactoryLoader
89-
* - Loads the new NgModuleFactory from the path string (async)
90-
*
9187
* For a Type<any> or Promise<Type<any>> this:
9288
* - Compiles the component type (if not running with AOT)
9389
* - Returns the NgModuleFactory resulting from compilation (or direct loading if using AOT) as a Promise
@@ -98,10 +94,6 @@ export function loadModuleFactory(
9894
moduleToLoad: ModuleTypeCallback,
9995
ng2Injector: Injector
10096
): Promise<NgModuleFactory<any>> {
101-
if (isString(moduleToLoad)) {
102-
return ng2Injector.get(NgModuleFactoryLoader).load(moduleToLoad);
103-
}
104-
10597
const compiler: Compiler = ng2Injector.get(Compiler);
10698

10799
const unwrapEsModuleDefault = (x) => (x && x.__esModule && x['default'] ? x['default'] : x);

test-angular-versions/v10/src/app/app.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BrowserModule } from '@angular/platform-browser';
2-
import { NgModule, NgModuleFactoryLoader, SystemJsNgModuleLoader } from '@angular/core';
2+
import { NgModule } from '@angular/core';
33
import { UIRouterModule } from '@uirouter/angular';
44
import { UIRouter } from '@uirouter/core';
55

@@ -19,7 +19,6 @@ export function config(router: UIRouter) {
1919

2020
@NgModule({
2121
imports: [BrowserModule, UIRouterModule.forRoot({ states, config })],
22-
providers: [{ provide: NgModuleFactoryLoader, useClass: SystemJsNgModuleLoader }],
2322
declarations: [AppComponent, HomeComponent, AboutComponent],
2423
bootstrap: [AppComponent],
2524
})

test-angular-versions/v11/src/app/app.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BrowserModule } from '@angular/platform-browser';
2-
import { NgModule, NgModuleFactoryLoader, SystemJsNgModuleLoader } from '@angular/core';
2+
import { NgModule } from '@angular/core';
33
import { UIRouterModule } from '@uirouter/angular';
44
import { UIRouter } from '@uirouter/core';
55

@@ -19,7 +19,6 @@ export function config(router: UIRouter) {
1919

2020
@NgModule({
2121
imports: [BrowserModule, UIRouterModule.forRoot({ states, config })],
22-
providers: [{ provide: NgModuleFactoryLoader, useClass: SystemJsNgModuleLoader }],
2322
declarations: [AppComponent, HomeComponent, AboutComponent],
2423
bootstrap: [AppComponent],
2524
})

test/ngModule/deferInitialRender.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import {
66
APP_INITIALIZER,
77
ApplicationInitStatus,
88
Component,
9-
NgModuleFactoryLoader,
10-
SystemJsNgModuleLoader,
119
} from '@angular/core';
1210
import { Ng2StateDeclaration } from '../../src/interface';
1311

@@ -43,7 +41,6 @@ const setupTests = (deferInitialRender: boolean) => {
4341
declarations: [HomeComponent, AppComponent],
4442
imports: [routerModule],
4543
providers: [
46-
{ provide: NgModuleFactoryLoader, useClass: SystemJsNgModuleLoader },
4744
{ provide: APP_INITIALIZER, useValue: () => appInitializer, multi: true },
4845
],
4946
});

test/ngModule/lazyModule.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { async, inject, TestBed } from '@angular/core/testing';
22
import { UIRouterModule } from '../../src/uiRouterNgModule';
33
import { UIView } from '../../src/directives/uiView';
44
import { memoryLocationPlugin, UIRouter } from '@uirouter/core';
5-
import { NgModuleFactoryLoader, SystemJsNgModuleLoader } from '@angular/core';
65

76
declare let System;
87

@@ -40,7 +39,6 @@ describe('lazy loading', () => {
4039
TestBed.configureTestingModule({
4140
declarations: [],
4241
imports: [routerModule],
43-
providers: [{ provide: NgModuleFactoryLoader, useClass: SystemJsNgModuleLoader }],
4442
});
4543
});
4644

0 commit comments

Comments
 (0)