fix: use a global System.import() instead of using a property of the global facade (#10696)
This commit is contained in:
parent
51b22cf14f
commit
50c795280f
|
@ -8,12 +8,13 @@
|
||||||
|
|
||||||
|
|
||||||
import {Injectable, Optional} from '../di';
|
import {Injectable, Optional} from '../di';
|
||||||
import {global} from '../facade/lang';
|
|
||||||
|
|
||||||
import {Compiler} from './compiler';
|
import {Compiler} from './compiler';
|
||||||
import {NgModuleFactory} from './ng_module_factory';
|
import {NgModuleFactory} from './ng_module_factory';
|
||||||
import {NgModuleFactoryLoader} from './ng_module_factory_loader';
|
import {NgModuleFactoryLoader} from './ng_module_factory_loader';
|
||||||
|
|
||||||
|
declare var System: {import: (module: string) => Promise<any>;};
|
||||||
|
|
||||||
const _SEPARATOR = '#';
|
const _SEPARATOR = '#';
|
||||||
|
|
||||||
const FACTORY_MODULE_SUFFIX = '.ngfactory';
|
const FACTORY_MODULE_SUFFIX = '.ngfactory';
|
||||||
|
@ -36,8 +37,7 @@ export class SystemJsNgModuleLoader implements NgModuleFactoryLoader {
|
||||||
let [module, exportName] = path.split(_SEPARATOR);
|
let [module, exportName] = path.split(_SEPARATOR);
|
||||||
if (exportName === undefined) exportName = 'default';
|
if (exportName === undefined) exportName = 'default';
|
||||||
|
|
||||||
return (<any>global)
|
return System.import(module)
|
||||||
.System.import(module)
|
|
||||||
.then((module: any) => module[exportName])
|
.then((module: any) => module[exportName])
|
||||||
.then((type: any) => checkNotEmpty(type, module, exportName))
|
.then((type: any) => checkNotEmpty(type, module, exportName))
|
||||||
.then((type: any) => this._compiler.compileModuleAsync(type));
|
.then((type: any) => this._compiler.compileModuleAsync(type));
|
||||||
|
@ -47,8 +47,7 @@ export class SystemJsNgModuleLoader implements NgModuleFactoryLoader {
|
||||||
let [module, exportName] = path.split(_SEPARATOR);
|
let [module, exportName] = path.split(_SEPARATOR);
|
||||||
if (exportName === undefined) exportName = 'default';
|
if (exportName === undefined) exportName = 'default';
|
||||||
|
|
||||||
return (<any>global)
|
return System.import(module + FACTORY_MODULE_SUFFIX)
|
||||||
.System.import(module + FACTORY_MODULE_SUFFIX)
|
|
||||||
.then((module: any) => module[exportName + FACTORY_CLASS_SUFFIX])
|
.then((module: any) => module[exportName + FACTORY_CLASS_SUFFIX])
|
||||||
.then((factory: any) => checkNotEmpty(factory, module, exportName));
|
.then((factory: any) => checkNotEmpty(factory, module, exportName));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,13 @@
|
||||||
|
|
||||||
import {Console} from '../console';
|
import {Console} from '../console';
|
||||||
import {Injectable} from '../di';
|
import {Injectable} from '../di';
|
||||||
import {global, isString} from '../facade/lang';
|
import {isString} from '../facade/lang';
|
||||||
import {Type} from '../type';
|
import {Type} from '../type';
|
||||||
import {ComponentFactory} from './component_factory';
|
import {ComponentFactory} from './component_factory';
|
||||||
import {ComponentResolver} from './component_resolver';
|
import {ComponentResolver} from './component_resolver';
|
||||||
|
|
||||||
|
declare var System: {import: (module: string) => Promise<any>;};
|
||||||
|
|
||||||
const _SEPARATOR = '#';
|
const _SEPARATOR = '#';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,9 +38,8 @@ export class SystemJsComponentResolver implements ComponentResolver {
|
||||||
component = 'default';
|
component = 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
return (<any>global)
|
return System.import(module).then(
|
||||||
.System.import(module)
|
(module: any) => this._resolver.resolveComponent(module[component]));
|
||||||
.then((module: any) => this._resolver.resolveComponent(module[component]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._resolver.resolveComponent(componentType);
|
return this._resolver.resolveComponent(componentType);
|
||||||
|
@ -64,8 +65,7 @@ export class SystemJsCmpFactoryResolver implements ComponentResolver {
|
||||||
if (isString(componentType)) {
|
if (isString(componentType)) {
|
||||||
this._console.warn(ComponentResolver.LazyLoadingDeprecationMsg);
|
this._console.warn(ComponentResolver.LazyLoadingDeprecationMsg);
|
||||||
let [module, factory] = componentType.split(_SEPARATOR);
|
let [module, factory] = componentType.split(_SEPARATOR);
|
||||||
return (<any>global)
|
return System.import(module + FACTORY_MODULE_SUFFIX)
|
||||||
.System.import(module + FACTORY_MODULE_SUFFIX)
|
|
||||||
.then((module: any) => module[factory + FACTORY_CLASS_SUFFIX]);
|
.then((module: any) => module[factory + FACTORY_CLASS_SUFFIX]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue