diff --git a/modules/@angular/compiler/compiler.ts b/modules/@angular/compiler/compiler.ts index 1528294b05..4f92e492df 100644 --- a/modules/@angular/compiler/compiler.ts +++ b/modules/@angular/compiler/compiler.ts @@ -19,6 +19,7 @@ export { SourceModule, NormalizedComponentWithViewDirectives, OfflineCompiler, + RuntimeCompiler, CompileMetadataWithIdentifier, CompileMetadataWithType, CompileIdentifierMetadata, diff --git a/modules/@angular/core/src/linker.ts b/modules/@angular/core/src/linker.ts index 3fc0d36fc9..f4375ce30b 100644 --- a/modules/@angular/core/src/linker.ts +++ b/modules/@angular/core/src/linker.ts @@ -1,5 +1,6 @@ // Public API for compiler export {ComponentResolver} from './linker/component_resolver'; +export {SystemJsComponentResolver} from './linker/systemjs_component_resolver'; export {QueryList} from './linker/query_list'; export {DynamicComponentLoader} from './linker/dynamic_component_loader'; export {ElementRef} from './linker/element_ref'; diff --git a/modules/@angular/core/src/linker/systemjs_component_resolver.ts b/modules/@angular/core/src/linker/systemjs_component_resolver.ts new file mode 100644 index 0000000000..955d4f3b87 --- /dev/null +++ b/modules/@angular/core/src/linker/systemjs_component_resolver.ts @@ -0,0 +1,21 @@ +import { ComponentResolver } from './component_resolver'; +import { Type, isString, global } from '../../src/facade/lang'; +import { ComponentFactory } from './component_factory'; + +/** + * Component resolver that can load components lazily + */ +export class SystemJsComponentResolver implements ComponentResolver { + constructor(private _resolver: ComponentResolver) {} + + resolveComponent(componentType:string|Type):Promise> { + if (isString(componentType)) { + return (global).System.import(componentType).then(module => + this._resolver.resolveComponent(module.default)); + } else { + return this._resolver.resolveComponent(componentType); + } + } + + clearCache() {} +} diff --git a/modules/@angular/integration_test/public_api_spec.ts b/modules/@angular/integration_test/public_api_spec.ts index 2804b5d10a..8ddd143f85 100644 --- a/modules/@angular/integration_test/public_api_spec.ts +++ b/modules/@angular/integration_test/public_api_spec.ts @@ -140,6 +140,7 @@ var COMPILER: string[] = [ "DirectiveResolver", "NormalizedComponentWithViewDirectives", "OfflineCompiler", + "RuntimeCompiler", "PipeResolver", "ProviderAst", "ProviderAstType", @@ -185,6 +186,7 @@ var CORE: string[] = [ 'ChangeDetectorRef', 'Class:js', 'ComponentResolver', + 'SystemJsComponentResolver', 'Component', 'ComponentMetadata', 'ComponentRef', diff --git a/modules/@angular/router/src/recognize.ts b/modules/@angular/router/src/recognize.ts index a3ecf73252..028e20a0a7 100644 --- a/modules/@angular/router/src/recognize.ts +++ b/modules/@angular/router/src/recognize.ts @@ -11,7 +11,7 @@ import {reflector} from '@angular/core'; // TODO: vsavkin: recognize should take the old tree and merge it export function recognize(componentResolver: ComponentResolver, rootComponent: Type, url: UrlTree): Promise { - let matched = new _MatchResult(rootComponent, [url.root], null, rootNode(url).children, []); + let matched = new _MatchResult(rootComponent, [url.root], {}, rootNode(url).children, []); return _constructSegment(componentResolver, matched).then(roots => new RouteTree(roots[0])); }