fix(router): merge SystemJsAppModuleFactoryLoader and SystemJsAllModuleLoader
This commit is contained in:
parent
0b54e3cf0a
commit
0426325ef7
@ -17,7 +17,7 @@ export {DynamicComponentLoader} from './linker/dynamic_component_loader';
|
|||||||
export {ElementRef} from './linker/element_ref';
|
export {ElementRef} from './linker/element_ref';
|
||||||
export {ExpressionChangedAfterItHasBeenCheckedException} from './linker/exceptions';
|
export {ExpressionChangedAfterItHasBeenCheckedException} from './linker/exceptions';
|
||||||
export {QueryList} from './linker/query_list';
|
export {QueryList} from './linker/query_list';
|
||||||
export {SystemJsAppModuleFactoryLoader, SystemJsAppModuleLoader} from './linker/system_js_app_module_factory_loader';
|
export {SystemJsAppModuleLoader} from './linker/system_js_app_module_factory_loader';
|
||||||
export {SystemJsCmpFactoryResolver, SystemJsComponentResolver} from './linker/systemjs_component_resolver';
|
export {SystemJsCmpFactoryResolver, SystemJsComponentResolver} from './linker/systemjs_component_resolver';
|
||||||
export {TemplateRef} from './linker/template_ref';
|
export {TemplateRef} from './linker/template_ref';
|
||||||
export {ViewContainerRef} from './linker/view_container_ref';
|
export {ViewContainerRef} from './linker/view_container_ref';
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import {Injectable} from '../di';
|
import {Injectable, Optional} from '../di';
|
||||||
import {global} from '../facade/lang';
|
import {global} from '../facade/lang';
|
||||||
|
|
||||||
import {AppModuleFactory} from './app_module_factory';
|
import {AppModuleFactory} from './app_module_factory';
|
||||||
@ -16,15 +16,22 @@ import {Compiler} from './compiler';
|
|||||||
|
|
||||||
const _SEPARATOR = '#';
|
const _SEPARATOR = '#';
|
||||||
|
|
||||||
|
const FACTORY_MODULE_SUFFIX = '.ngfactory';
|
||||||
|
const FACTORY_CLASS_SUFFIX = 'NgFactory';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AppModuleFactoryLoader that uses SystemJS to load AppModule type and then compiles them.
|
* AppModuleFactoryLoader that uses SystemJS to load AppModuleFactory
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SystemJsAppModuleLoader implements AppModuleFactoryLoader {
|
export class SystemJsAppModuleLoader implements AppModuleFactoryLoader {
|
||||||
constructor(private _compiler: Compiler) {}
|
constructor(@Optional() private _compiler: Compiler) {}
|
||||||
|
|
||||||
load(path: string): Promise<AppModuleFactory<any>> {
|
load(path: string): Promise<AppModuleFactory<any>> {
|
||||||
|
return this._compiler ? this.loadAndCompile(path) : this.loadFactory(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private loadAndCompile(path: string): Promise<AppModuleFactory<any>> {
|
||||||
let [module, exportName] = path.split(_SEPARATOR);
|
let [module, exportName] = path.split(_SEPARATOR);
|
||||||
if (exportName === undefined) exportName = 'default';
|
if (exportName === undefined) exportName = 'default';
|
||||||
|
|
||||||
@ -34,17 +41,8 @@ export class SystemJsAppModuleLoader implements AppModuleFactoryLoader {
|
|||||||
.then((type: any) => checkNotEmpty(type, module, exportName))
|
.then((type: any) => checkNotEmpty(type, module, exportName))
|
||||||
.then((type: any) => this._compiler.compileAppModuleAsync(type));
|
.then((type: any) => this._compiler.compileAppModuleAsync(type));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const FACTORY_MODULE_SUFFIX = '.ngfactory';
|
private loadFactory(path: string): Promise<AppModuleFactory<any>> {
|
||||||
const FACTORY_CLASS_SUFFIX = 'NgFactory';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* AppModuleFactoryLoader that uses SystemJS to load AppModuleFactories
|
|
||||||
* @experimental
|
|
||||||
*/
|
|
||||||
export class SystemJsAppModuleFactoryLoader implements AppModuleFactoryLoader {
|
|
||||||
load(path: string): Promise<AppModuleFactory<any>> {
|
|
||||||
let [module, exportName] = path.split(_SEPARATOR);
|
let [module, exportName] = path.split(_SEPARATOR);
|
||||||
if (exportName === undefined) exportName = 'default';
|
if (exportName === undefined) exportName = 'default';
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ const FACTORY_CLASS_SUFFIX = 'NgFactory';
|
|||||||
/**
|
/**
|
||||||
* Component resolver that can load component factories lazily
|
* Component resolver that can load component factories lazily
|
||||||
*
|
*
|
||||||
* @deprecated Lazy loading of components is deprecated. Use {@link SystemJsAppModuleFactoryLoader}
|
* @deprecated Lazy loading of components is deprecated. Use {@link SystemJsAppModuleLoader}
|
||||||
* to lazy
|
* to lazy
|
||||||
* load {@link AppModuleFactory}s instead.
|
* load {@link AppModuleFactory}s instead.
|
||||||
*/
|
*/
|
||||||
|
@ -291,11 +291,9 @@ export class Router {
|
|||||||
const tree = this.urlSerializer.parse(change['url']);
|
const tree = this.urlSerializer.parse(change['url']);
|
||||||
// we fire multiple events for a single URL change
|
// we fire multiple events for a single URL change
|
||||||
// we should navigate only once
|
// we should navigate only once
|
||||||
if (this.currentUrlTree.toString() !== tree.toString()) {
|
return this.currentUrlTree.toString() !== tree.toString() ?
|
||||||
return this.scheduleNavigation(tree, change['pop']);
|
this.scheduleNavigation(tree, change['pop']) :
|
||||||
} else {
|
null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ describe('Integration', () => {
|
|||||||
children: [{path: 'user/:name', component: UserCmp}]
|
children: [{path: 'user/:name', component: UserCmp}]
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
const recordedEvents: any = [];
|
const recordedEvents: any[] = [];
|
||||||
router.events.forEach(e => recordedEvents.push(e));
|
router.events.forEach(e => recordedEvents.push(e));
|
||||||
|
|
||||||
router.navigateByUrl('/team/22/user/victor');
|
router.navigateByUrl('/team/22/user/victor');
|
||||||
@ -123,7 +123,7 @@ describe('Integration', () => {
|
|||||||
(<any>location).simulateUrlPop('/team/22/user/fedor');
|
(<any>location).simulateUrlPop('/team/22/user/fedor');
|
||||||
advance(fixture);
|
advance(fixture);
|
||||||
|
|
||||||
expect(fixture.debugElement.nativeElement).toHaveText('team 22 { user fedor, right: }');
|
expect(fixture.debugElement.nativeElement).toHaveText('team 22 [ user fedor, right: ]');
|
||||||
|
|
||||||
expectEvents(recordedEvents, [
|
expectEvents(recordedEvents, [
|
||||||
[NavigationStart, '/team/22/user/victor'], [RoutesRecognized, '/team/22/user/victor'],
|
[NavigationStart, '/team/22/user/victor'], [RoutesRecognized, '/team/22/user/victor'],
|
||||||
@ -298,7 +298,7 @@ describe('Integration', () => {
|
|||||||
|
|
||||||
router.resetConfig([{path: 'user/:name', component: UserCmp}]);
|
router.resetConfig([{path: 'user/:name', component: UserCmp}]);
|
||||||
|
|
||||||
const recordedEvents: any = [];
|
const recordedEvents: any[] = [];
|
||||||
router.events.forEach(e => recordedEvents.push(e));
|
router.events.forEach(e => recordedEvents.push(e));
|
||||||
|
|
||||||
router.navigateByUrl('/user/init');
|
router.navigateByUrl('/user/init');
|
||||||
@ -335,7 +335,7 @@ describe('Integration', () => {
|
|||||||
|
|
||||||
router.resetConfig([{path: 'user/:name', component: UserCmp}]);
|
router.resetConfig([{path: 'user/:name', component: UserCmp}]);
|
||||||
|
|
||||||
const recordedEvents: any = [];
|
const recordedEvents: any[] = [];
|
||||||
router.events.forEach(e => recordedEvents.push(e));
|
router.events.forEach(e => recordedEvents.push(e));
|
||||||
|
|
||||||
let e: any;
|
let e: any;
|
||||||
@ -1217,7 +1217,7 @@ describe('Integration', () => {
|
|||||||
|
|
||||||
router.resetConfig([{path: 'lazy', loadChildren: 'invalid'}]);
|
router.resetConfig([{path: 'lazy', loadChildren: 'invalid'}]);
|
||||||
|
|
||||||
const recordedEvents: any = [];
|
const recordedEvents: any[] = [];
|
||||||
router.events.forEach(e => recordedEvents.push(e));
|
router.events.forEach(e => recordedEvents.push(e));
|
||||||
|
|
||||||
router.navigateByUrl('/lazy/loaded').catch(s => {})
|
router.navigateByUrl('/lazy/loaded').catch(s => {})
|
||||||
|
5
tools/public_api_guard/core/index.d.ts
vendored
5
tools/public_api_guard/core/index.d.ts
vendored
@ -1336,11 +1336,6 @@ export declare function style(tokens: string | {
|
|||||||
[key: string]: string | number;
|
[key: string]: string | number;
|
||||||
}>): AnimationStyleMetadata;
|
}>): AnimationStyleMetadata;
|
||||||
|
|
||||||
/** @experimental */
|
|
||||||
export declare class SystemJsAppModuleFactoryLoader implements AppModuleFactoryLoader {
|
|
||||||
load(path: string): Promise<AppModuleFactory<any>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare class SystemJsAppModuleLoader implements AppModuleFactoryLoader {
|
export declare class SystemJsAppModuleLoader implements AppModuleFactoryLoader {
|
||||||
constructor(_compiler: Compiler);
|
constructor(_compiler: Compiler);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user