diff --git a/modules/@angular/compiler-cli/src/codegen.ts b/modules/@angular/compiler-cli/src/codegen.ts index 03255bd92a..ba7d2da1c7 100644 --- a/modules/@angular/compiler-cli/src/codegen.ts +++ b/modules/@angular/compiler-cli/src/codegen.ts @@ -78,17 +78,7 @@ export class CodeGenerator { static create( options: AngularCompilerOptions, cliOptions: NgcCliOptions, program: ts.Program, - compilerHost: ts.CompilerHost, ngHostContext?: NgHostContext, - resourceLoader?: compiler.ResourceLoader, ngHost?: NgHost): CodeGenerator { - resourceLoader = resourceLoader || { - get: (s: string) => { - if (!compilerHost.fileExists(s)) { - // TODO: We should really have a test for error cases like this! - throw new Error(`Compilation failed. Resource file not found: ${s}`); - } - return Promise.resolve(compilerHost.readFile(s)); - } - }; + compilerHost: ts.CompilerHost, ngHost?: NgHost): CodeGenerator { const transFile = cliOptions.i18nFile; const locale = cliOptions.locale; let transContent: string = ''; @@ -99,45 +89,13 @@ export class CodeGenerator { } transContent = readFileSync(transFile, 'utf8'); } - - const urlResolver: compiler.UrlResolver = compiler.createOfflineCompileUrlResolver(); - if (!ngHost) { - const usePathMapping = !!options.rootDirs && options.rootDirs.length > 0; - ngHost = usePathMapping ? - new PathMappedNgHost(program, compilerHost, options, ngHostContext) : - new NgHost(program, compilerHost, options, ngHostContext); - } - const staticReflector = new compiler.StaticReflector(ngHost); - compiler.StaticAndDynamicReflectionCapabilities.install(staticReflector); - const htmlParser = - new compiler.I18NHtmlParser(new compiler.HtmlParser(), transContent, cliOptions.i18nFormat); - const config = new compiler.CompilerConfig({ - genDebugInfo: options.debug === true, - defaultEncapsulation: ViewEncapsulation.Emulated, - logBindingUpdate: false, - useJit: false + const {compiler: aotCompiler, reflector} = compiler.createAotCompiler(ngHost, { + debug: options.debug === true, + translations: transContent, + i18nFormat: cliOptions.i18nFormat, + locale: cliOptions.locale }); - const normalizer = - new compiler.DirectiveNormalizer(resourceLoader, urlResolver, htmlParser, config); - const expressionParser = new compiler.Parser(new compiler.Lexer()); - const elementSchemaRegistry = new compiler.DomElementSchemaRegistry(); - const console = new Console(); - const tmplParser = new compiler.TemplateParser( - expressionParser, elementSchemaRegistry, htmlParser, console, []); - const resolver = new compiler.CompileMetadataResolver( - new compiler.NgModuleResolver(staticReflector), - new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector), - elementSchemaRegistry, normalizer, staticReflector); - // TODO(vicb): do not pass cliOptions.i18nFormat here - const aotCompiler = new compiler.AotCompiler( - resolver, tmplParser, new compiler.StyleCompiler(urlResolver), - new compiler.ViewCompiler(config, elementSchemaRegistry), - new compiler.DirectiveWrapperCompiler( - config, expressionParser, elementSchemaRegistry, console), - new compiler.NgModuleCompiler(), new compiler.TypeScriptEmitter(ngHost), cliOptions.locale, - cliOptions.i18nFormat, new compiler.AnimationParser(elementSchemaRegistry)); - - return new CodeGenerator(options, program, compilerHost, staticReflector, aotCompiler, ngHost); + return new CodeGenerator(options, program, compilerHost, reflector, aotCompiler, ngHost); } } diff --git a/modules/@angular/compiler-cli/src/ng_host.ts b/modules/@angular/compiler-cli/src/ng_host.ts index e1d975033e..9ff1823c36 100644 --- a/modules/@angular/compiler-cli/src/ng_host.ts +++ b/modules/@angular/compiler-cli/src/ng_host.ts @@ -21,6 +21,7 @@ export interface NgHostContext { fileExists(fileName: string): boolean; directoryExists(directoryName: string): boolean; readFile(fileName: string): string; + readResource(fileName: string): Promise; assumeFileExists(fileName: string): void; } @@ -75,7 +76,7 @@ export class NgHost implements AotCompilerHost { * * NOTE: (*) the relative path is computed depending on `isGenDirChildOfRootDir`. */ - getImportPath(containingFile: string, importedFile: string): string { + resolveFileToImport(importedFile: string, containingFile: string): string { // If a file does not yet exist (because we compile it later), we still need to // assume it exists it so that the `resolve` method works! if (!this.compilerHost.fileExists(importedFile)) { @@ -176,6 +177,8 @@ export class NgHost implements AotCompilerHost { } } + loadResource(filePath: string): Promise { return this.context.readResource(filePath); } + private getResolverMetadata(filePath: string): ModuleMetadata { let metadata = this.resolverCache.get(filePath); if (!metadata) { @@ -205,5 +208,13 @@ export class NodeNgHostContext implements NgHostContext { readFile(fileName: string): string { return fs.readFileSync(fileName, 'utf8'); } + readResource(s: string) { + if (!this.host.fileExists(s)) { + // TODO: We should really have a test for error cases like this! + throw new Error(`Compilation failed. Resource file not found: ${s}`); + } + return Promise.resolve(this.host.readFile(s)); + } + assumeFileExists(fileName: string): void { this.assumedExists[fileName] = true; } } diff --git a/modules/@angular/compiler-cli/src/path_mapped_ng_host.ts b/modules/@angular/compiler-cli/src/path_mapped_ng_host.ts index d37ec855ea..e100ea3293 100644 --- a/modules/@angular/compiler-cli/src/path_mapped_ng_host.ts +++ b/modules/@angular/compiler-cli/src/path_mapped_ng_host.ts @@ -69,7 +69,7 @@ export class PathMappedNgHost extends NgHost { * Relativize the paths by checking candidate prefixes of the absolute path, to see if * they are resolvable by the moduleResolution strategy from the CompilerHost. */ - getImportPath(containingFile: string, importedFile: string): string { + resolveFileToImport(importedFile: string, containingFile: string): string { if (this.options.traceResolution) { console.log( 'getImportPath from containingFile', containingFile, 'to importedFile', importedFile); diff --git a/modules/@angular/compiler-cli/test/mocks.ts b/modules/@angular/compiler-cli/test/mocks.ts index fddc69c866..d7f4c6ade6 100644 --- a/modules/@angular/compiler-cli/test/mocks.ts +++ b/modules/@angular/compiler-cli/test/mocks.ts @@ -28,6 +28,14 @@ export class MockContext implements NgHostContext { return undefined; } + readResource(fileName: string): Promise { + const result = this.readFile(fileName); + if (result == null) { + return Promise.reject(new Error(`Resource not found: ${fileName}`)); + } + return Promise.resolve(result); + } + writeFile(fileName: string, data: string): void { const parts = fileName.split('/'); const name = parts.pop(); diff --git a/modules/@angular/compiler-cli/test/ng_host_spec.ts b/modules/@angular/compiler-cli/test/ng_host_spec.ts index e2776b5cf8..d780648e39 100644 --- a/modules/@angular/compiler-cli/test/ng_host_spec.ts +++ b/modules/@angular/compiler-cli/test/ng_host_spec.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {beforeEach, describe, expect, it} from '@angular/core/testing/testing_internal'; import * as ts from 'typescript'; import {NgHost} from '../src/ng_host'; @@ -57,87 +56,87 @@ describe('NgHost', () => { describe('nestedGenDir', () => { it('should import node_module from factory', () => { - expect(hostNestedGenDir.getImportPath( - '/tmp/project/src/gen/my.ngfactory.ts', - '/tmp/project/node_modules/@angular/core.d.ts')) + expect(hostNestedGenDir.resolveFileToImport( + '/tmp/project/node_modules/@angular/core.d.ts', + '/tmp/project/src/gen/my.ngfactory.ts', )) .toEqual('@angular/core'); }); it('should import factory from factory', () => { - expect(hostNestedGenDir.getImportPath( - '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/my.other.ngfactory.ts')) + expect(hostNestedGenDir.resolveFileToImport( + '/tmp/project/src/my.other.ngfactory.ts', '/tmp/project/src/my.ngfactory.ts')) .toEqual('./my.other.ngfactory'); - expect(hostNestedGenDir.getImportPath( - '/tmp/project/src/a/my.ngfactory.ts', '/tmp/project/src/my.other.css.ts')) + expect(hostNestedGenDir.resolveFileToImport( + '/tmp/project/src/my.other.css.ts', '/tmp/project/src/a/my.ngfactory.ts')) .toEqual('../my.other.css'); - expect(hostNestedGenDir.getImportPath( - '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/a/my.other.css.shim.ts')) + expect(hostNestedGenDir.resolveFileToImport( + '/tmp/project/src/a/my.other.css.shim.ts', '/tmp/project/src/my.ngfactory.ts')) .toEqual('./a/my.other.css.shim'); }); it('should import application from factory', () => { - expect(hostNestedGenDir.getImportPath( - '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/my.other.ts')) + expect(hostNestedGenDir.resolveFileToImport( + '/tmp/project/src/my.other.ts', '/tmp/project/src/my.ngfactory.ts')) .toEqual('../my.other'); - expect(hostNestedGenDir.getImportPath( - '/tmp/project/src/a/my.ngfactory.ts', '/tmp/project/src/my.other.ts')) + expect(hostNestedGenDir.resolveFileToImport( + '/tmp/project/src/my.other.ts', '/tmp/project/src/a/my.ngfactory.ts')) .toEqual('../../my.other'); - expect(hostNestedGenDir.getImportPath( - '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/a/my.other.ts')) + expect(hostNestedGenDir.resolveFileToImport( + '/tmp/project/src/a/my.other.ts', '/tmp/project/src/my.ngfactory.ts')) .toEqual('../a/my.other'); }); }); - describe('nestedGenDir', () => { + describe('siblingGenDir', () => { it('should import node_module from factory', () => { - expect(hostSiblingGenDir.getImportPath( - '/tmp/project/src/gen/my.ngfactory.ts', - '/tmp/project/node_modules/@angular/core.d.ts')) + expect(hostSiblingGenDir.resolveFileToImport( + '/tmp/project/node_modules/@angular/core.d.ts', + '/tmp/project/src/gen/my.ngfactory.ts')) .toEqual('@angular/core'); }); it('should import factory from factory', () => { - expect(hostSiblingGenDir.getImportPath( - '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/my.other.ngfactory.ts')) + expect(hostSiblingGenDir.resolveFileToImport( + '/tmp/project/src/my.other.ngfactory.ts', '/tmp/project/src/my.ngfactory.ts')) .toEqual('./my.other.ngfactory'); - expect(hostSiblingGenDir.getImportPath( - '/tmp/project/src/a/my.ngfactory.ts', '/tmp/project/src/my.other.css.ts')) + expect(hostSiblingGenDir.resolveFileToImport( + '/tmp/project/src/my.other.css.ts', '/tmp/project/src/a/my.ngfactory.ts')) .toEqual('../my.other.css'); - expect(hostSiblingGenDir.getImportPath( - '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/a/my.other.css.shim.ts')) + expect(hostSiblingGenDir.resolveFileToImport( + '/tmp/project/src/a/my.other.css.shim.ts', '/tmp/project/src/my.ngfactory.ts')) .toEqual('./a/my.other.css.shim'); }); it('should import application from factory', () => { - expect(hostSiblingGenDir.getImportPath( - '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/my.other.ts')) + expect(hostSiblingGenDir.resolveFileToImport( + '/tmp/project/src/my.other.ts', '/tmp/project/src/my.ngfactory.ts')) .toEqual('./my.other'); - expect(hostSiblingGenDir.getImportPath( - '/tmp/project/src/a/my.ngfactory.ts', '/tmp/project/src/my.other.ts')) + expect(hostSiblingGenDir.resolveFileToImport( + '/tmp/project/src/my.other.ts', '/tmp/project/src/a/my.ngfactory.ts')) .toEqual('../my.other'); - expect(hostSiblingGenDir.getImportPath( - '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/a/my.other.ts')) + expect(hostSiblingGenDir.resolveFileToImport( + '/tmp/project/src/a/my.other.ts', '/tmp/project/src/my.ngfactory.ts')) .toEqual('./a/my.other'); }); }); it('should be able to produce an import from main @angular/core', () => { - expect(hostNestedGenDir.getImportPath( - '/tmp/project/src/main.ts', '/tmp/project/node_modules/@angular/core.d.ts')) + expect(hostNestedGenDir.resolveFileToImport( + '/tmp/project/node_modules/@angular/core.d.ts', '/tmp/project/src/main.ts')) .toEqual('@angular/core'); }); it('should be able to produce an import from main to a sub-directory', () => { - expect(hostNestedGenDir.getImportPath('main.ts', 'lib/utils.ts')).toEqual('./lib/utils'); + expect(hostNestedGenDir.resolveFileToImport('lib/utils.ts', 'main.ts')).toEqual('./lib/utils'); }); it('should be able to produce an import from to a peer file', () => { - expect(hostNestedGenDir.getImportPath('lib/utils.ts', 'lib/collections.ts')) + expect(hostNestedGenDir.resolveFileToImport('lib/collections.ts', 'lib/utils.ts')) .toEqual('./collections'); }); it('should be able to produce an import from to a sibling directory', () => { - expect(hostNestedGenDir.getImportPath('lib2/utils2.ts', 'lib/utils.ts')) + expect(hostNestedGenDir.resolveFileToImport('lib/utils.ts', 'lib2/utils2.ts')) .toEqual('../lib/utils'); }); diff --git a/modules/@angular/compiler/index.ts b/modules/@angular/compiler/index.ts index 8b37b1e698..215911dedb 100644 --- a/modules/@angular/compiler/index.ts +++ b/modules/@angular/compiler/index.ts @@ -25,6 +25,7 @@ export * from './src/template_parser/template_ast'; export {TEMPLATE_TRANSFORMS} from './src/template_parser/template_parser'; export {CompilerConfig, RenderTypes} from './src/config'; export * from './src/compile_metadata'; +export * from './src/aot/compiler_factory'; export * from './src/aot/compiler'; export * from './src/aot/compiler_host'; export * from './src/aot/static_reflector'; diff --git a/modules/@angular/compiler/src/aot/compiler_factory.ts b/modules/@angular/compiler/src/aot/compiler_factory.ts new file mode 100644 index 0000000000..71d3e9e91b --- /dev/null +++ b/modules/@angular/compiler/src/aot/compiler_factory.ts @@ -0,0 +1,79 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {ViewEncapsulation} from '@angular/core'; + +import {AnimationParser} from '../animation/animation_parser'; +import {CompilerConfig} from '../config'; +import {DirectiveNormalizer} from '../directive_normalizer'; +import {DirectiveResolver} from '../directive_resolver'; +import {DirectiveWrapperCompiler} from '../directive_wrapper_compiler'; +import {Lexer} from '../expression_parser/lexer'; +import {Parser} from '../expression_parser/parser'; +import {I18NHtmlParser} from '../i18n/i18n_html_parser'; +import {CompileMetadataResolver} from '../metadata_resolver'; +import {HtmlParser} from '../ml_parser/html_parser'; +import {NgModuleCompiler} from '../ng_module_compiler'; +import {NgModuleResolver} from '../ng_module_resolver'; +import {TypeScriptEmitter} from '../output/ts_emitter'; +import {PipeResolver} from '../pipe_resolver'; +import {Console} from '../private_import_core'; +import {DomElementSchemaRegistry} from '../schema/dom_element_schema_registry'; +import {StyleCompiler} from '../style_compiler'; +import {TemplateParser} from '../template_parser/template_parser'; +import {createOfflineCompileUrlResolver} from '../url_resolver'; +import {ViewCompiler} from '../view_compiler/view_compiler'; + +import {AotCompiler} from './compiler'; +import {AotCompilerHost} from './compiler_host'; +import {StaticAndDynamicReflectionCapabilities} from './static_reflection_capabilities'; +import {StaticReflector} from './static_reflector'; + +export interface AotCompilerOptions { + debug?: boolean; + locale?: string; + i18nFormat?: string; + translations?: string; +} + +/** + * Creates a new AotCompiler based on options and a host. + */ +export function createAotCompiler(ngHost: AotCompilerHost, options: AotCompilerOptions): + {compiler: AotCompiler, reflector: StaticReflector} { + let translations: string = options.translations || ''; + + const urlResolver = createOfflineCompileUrlResolver(); + const staticReflector = new StaticReflector(ngHost); + StaticAndDynamicReflectionCapabilities.install(staticReflector); + const htmlParser = new I18NHtmlParser(new HtmlParser(), translations, options.i18nFormat); + const config = new CompilerConfig({ + genDebugInfo: options.debug === true, + defaultEncapsulation: ViewEncapsulation.Emulated, + logBindingUpdate: false, + useJit: false + }); + const normalizer = new DirectiveNormalizer( + {get: (url: string) => ngHost.loadResource(url)}, urlResolver, htmlParser, config); + const expressionParser = new Parser(new Lexer()); + const elementSchemaRegistry = new DomElementSchemaRegistry(); + const console = new Console(); + const tmplParser = + new TemplateParser(expressionParser, elementSchemaRegistry, htmlParser, console, []); + const resolver = new CompileMetadataResolver( + new NgModuleResolver(staticReflector), new DirectiveResolver(staticReflector), + new PipeResolver(staticReflector), elementSchemaRegistry, normalizer, staticReflector); + // TODO(vicb): do not pass options.i18nFormat here + const compiler = new AotCompiler( + resolver, tmplParser, new StyleCompiler(urlResolver), + new ViewCompiler(config, elementSchemaRegistry), + new DirectiveWrapperCompiler(config, expressionParser, elementSchemaRegistry, console), + new NgModuleCompiler(), new TypeScriptEmitter(ngHost), options.locale, options.i18nFormat, + new AnimationParser(elementSchemaRegistry)); + return {compiler, reflector: staticReflector}; +} diff --git a/modules/@angular/compiler/src/aot/compiler_host.ts b/modules/@angular/compiler/src/aot/compiler_host.ts index 6c3fdf8001..f6862e056c 100644 --- a/modules/@angular/compiler/src/aot/compiler_host.ts +++ b/modules/@angular/compiler/src/aot/compiler_host.ts @@ -25,7 +25,17 @@ export interface AotCompilerHost { getMetadataFor(modulePath: string): {[key: string]: any}|{[key: string]: any}[]; /** - * Converts a module name into a file path. + * Converts an import into a file path. */ resolveImportToFile(moduleName: string, containingFile: string): string; + + /** + * Converts a file path to an import + */ + resolveFileToImport(importedFilePath: string, containingFilePath: string): string; + + /** + * Loads a resource (e.g. html / css) + */ + loadResource(path: string): Promise; } \ No newline at end of file diff --git a/modules/@angular/compiler/src/output/js_emitter.ts b/modules/@angular/compiler/src/output/js_emitter.ts index 75dcfa582a..59bf56efed 100644 --- a/modules/@angular/compiler/src/output/js_emitter.ts +++ b/modules/@angular/compiler/src/output/js_emitter.ts @@ -12,10 +12,10 @@ import {isBlank, isPresent} from '../facade/lang'; import {EmitterVisitorContext, OutputEmitter} from './abstract_emitter'; import {AbstractJsEmitterVisitor} from './abstract_js_emitter'; import * as o from './output_ast'; -import {ImportGenerator} from './path_util'; +import {ImportResolver} from './path_util'; export class JavaScriptEmitter implements OutputEmitter { - constructor(private _importGenerator: ImportGenerator) {} + constructor(private _importGenerator: ImportResolver) {} emitStatements(moduleUrl: string, stmts: o.Statement[], exportedVars: string[]): string { const converter = new JsEmitterVisitor(moduleUrl); const ctx = EmitterVisitorContext.createRoot(exportedVars); @@ -25,7 +25,7 @@ export class JavaScriptEmitter implements OutputEmitter { // Note: can't write the real word for import as it screws up system.js auto detection... srcParts.push( `var ${prefix} = req` + - `uire('${this._importGenerator.getImportPath(moduleUrl, importedModuleUrl)}');`); + `uire('${this._importGenerator.resolveFileToImport(importedModuleUrl, moduleUrl)}');`); }); srcParts.push(ctx.toSource()); return srcParts.join('\n'); diff --git a/modules/@angular/compiler/src/output/path_util.ts b/modules/@angular/compiler/src/output/path_util.ts index e8dfb24391..07615af2d9 100644 --- a/modules/@angular/compiler/src/output/path_util.ts +++ b/modules/@angular/compiler/src/output/path_util.ts @@ -9,6 +9,6 @@ /** * Interface that defines how import statements should be generated. */ -export abstract class ImportGenerator { - abstract getImportPath(moduleUrlStr: string, importedUrlStr: string): string; +export abstract class ImportResolver { + abstract resolveFileToImport(importedFilePath: string, containingFilePath: string): string; } diff --git a/modules/@angular/compiler/src/output/ts_emitter.ts b/modules/@angular/compiler/src/output/ts_emitter.ts index e0628cd3f3..c7dc722faa 100644 --- a/modules/@angular/compiler/src/output/ts_emitter.ts +++ b/modules/@angular/compiler/src/output/ts_emitter.ts @@ -12,7 +12,7 @@ import {isBlank, isPresent} from '../facade/lang'; import {AbstractEmitterVisitor, CATCH_ERROR_VAR, CATCH_STACK_VAR, EmitterVisitorContext, OutputEmitter} from './abstract_emitter'; import * as o from './output_ast'; -import {ImportGenerator} from './path_util'; +import {ImportResolver} from './path_util'; const _debugModuleUrl = '/debug/lib'; @@ -37,7 +37,7 @@ export function debugOutputAstAsTypeScript(ast: o.Statement | o.Expression | o.T } export class TypeScriptEmitter implements OutputEmitter { - constructor(private _importGenerator: ImportGenerator) {} + constructor(private _importGenerator: ImportResolver) {} emitStatements(moduleUrl: string, stmts: o.Statement[], exportedVars: string[]): string { const converter = new _TsEmitterVisitor(moduleUrl); const ctx = EmitterVisitorContext.createRoot(exportedVars); @@ -47,7 +47,7 @@ export class TypeScriptEmitter implements OutputEmitter { // Note: can't write the real word for import as it screws up system.js auto detection... srcParts.push( `imp` + - `ort * as ${prefix} from '${this._importGenerator.getImportPath(moduleUrl, importedModuleUrl)}';`); + `ort * as ${prefix} from '${this._importGenerator.resolveFileToImport(importedModuleUrl, moduleUrl)}';`); }); srcParts.push(ctx.toSource()); return srcParts.join('\n'); diff --git a/modules/@angular/compiler/test/aot/static_reflector_spec.ts b/modules/@angular/compiler/test/aot/static_reflector_spec.ts index 219519caac..d2fa19ed31 100644 --- a/modules/@angular/compiler/test/aot/static_reflector_spec.ts +++ b/modules/@angular/compiler/test/aot/static_reflector_spec.ts @@ -511,6 +511,12 @@ class MockAotCompilerHost implements AotCompilerHost { constructor() {} + loadResource(filePath: string): Promise { throw new Error('Should not be called!'); } + + resolveFileToImport(importedFilePath: string, containingFilePath: string): string { + throw new Error('Should not be called!'); + } + // In tests, assume that symbols are not re-exported resolveImportToFile(modulePath: string, containingFile?: string): string { function splitPath(path: string): string[] { return path.split(/\/|\\/g); } diff --git a/modules/@angular/compiler/test/output/output_emitter_util.ts b/modules/@angular/compiler/test/output/output_emitter_util.ts index c510b794cf..4b4222b105 100644 --- a/modules/@angular/compiler/test/output/output_emitter_util.ts +++ b/modules/@angular/compiler/test/output/output_emitter_util.ts @@ -9,7 +9,7 @@ import {CompileIdentifierMetadata} from '@angular/compiler/src/compile_metadata'; import {assetUrl} from '@angular/compiler/src/identifiers'; import * as o from '@angular/compiler/src/output/output_ast'; -import {ImportGenerator} from '@angular/compiler/src/output/path_util'; +import {ImportResolver} from '@angular/compiler/src/output/path_util'; import {EventEmitter} from '@angular/core'; import {BaseError} from '@angular/core/src/facade/errors'; import {ViewType} from '@angular/core/src/linker/view_type'; @@ -252,6 +252,8 @@ function createOperatorFn(op: o.BinaryOperator) { o.DYNAMIC_TYPE); } -export class SimpleJsImportGenerator implements ImportGenerator { - getImportPath(moduleUrlStr: string, importedUrlStr: string): string { return importedUrlStr; } +export class SimpleJsImportGenerator implements ImportResolver { + resolveFileToImport(importedUrlStr: string, moduleUrlStr: string): string { + return importedUrlStr; + } }