fix: use a global System.import() instead of using a property of the global facade (#10696)

This commit is contained in:
Hans 2016-08-11 14:17:44 -07:00 committed by vikerman
parent 51b22cf14f
commit 50c795280f
2 changed files with 10 additions and 11 deletions

View File

@ -8,12 +8,13 @@
import {Injectable, Optional} from '../di';
import {global} from '../facade/lang';
import {Compiler} from './compiler';
import {NgModuleFactory} from './ng_module_factory';
import {NgModuleFactoryLoader} from './ng_module_factory_loader';
declare var System: {import: (module: string) => Promise<any>;};
const _SEPARATOR = '#';
const FACTORY_MODULE_SUFFIX = '.ngfactory';
@ -36,8 +37,7 @@ export class SystemJsNgModuleLoader implements NgModuleFactoryLoader {
let [module, exportName] = path.split(_SEPARATOR);
if (exportName === undefined) exportName = 'default';
return (<any>global)
.System.import(module)
return System.import(module)
.then((module: any) => module[exportName])
.then((type: any) => checkNotEmpty(type, module, exportName))
.then((type: any) => this._compiler.compileModuleAsync(type));
@ -47,8 +47,7 @@ export class SystemJsNgModuleLoader implements NgModuleFactoryLoader {
let [module, exportName] = path.split(_SEPARATOR);
if (exportName === undefined) exportName = 'default';
return (<any>global)
.System.import(module + FACTORY_MODULE_SUFFIX)
return System.import(module + FACTORY_MODULE_SUFFIX)
.then((module: any) => module[exportName + FACTORY_CLASS_SUFFIX])
.then((factory: any) => checkNotEmpty(factory, module, exportName));
}

View File

@ -8,11 +8,13 @@
import {Console} from '../console';
import {Injectable} from '../di';
import {global, isString} from '../facade/lang';
import {isString} from '../facade/lang';
import {Type} from '../type';
import {ComponentFactory} from './component_factory';
import {ComponentResolver} from './component_resolver';
declare var System: {import: (module: string) => Promise<any>;};
const _SEPARATOR = '#';
/**
@ -36,9 +38,8 @@ export class SystemJsComponentResolver implements ComponentResolver {
component = 'default';
}
return (<any>global)
.System.import(module)
.then((module: any) => this._resolver.resolveComponent(module[component]));
return System.import(module).then(
(module: any) => this._resolver.resolveComponent(module[component]));
}
return this._resolver.resolveComponent(componentType);
@ -64,8 +65,7 @@ export class SystemJsCmpFactoryResolver implements ComponentResolver {
if (isString(componentType)) {
this._console.warn(ComponentResolver.LazyLoadingDeprecationMsg);
let [module, factory] = componentType.split(_SEPARATOR);
return (<any>global)
.System.import(module + FACTORY_MODULE_SUFFIX)
return System.import(module + FACTORY_MODULE_SUFFIX)
.then((module: any) => module[factory + FACTORY_CLASS_SUFFIX]);
}