diff --git a/modules/@angular/compiler-cli/src/codegen.ts b/modules/@angular/compiler-cli/src/codegen.ts index ba7d2da1c7..03255bd92a 100644 --- a/modules/@angular/compiler-cli/src/codegen.ts +++ b/modules/@angular/compiler-cli/src/codegen.ts @@ -78,7 +78,17 @@ export class CodeGenerator { static create( options: AngularCompilerOptions, cliOptions: NgcCliOptions, program: ts.Program, - compilerHost: ts.CompilerHost, ngHost?: NgHost): CodeGenerator { + 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)); + } + }; const transFile = cliOptions.i18nFile; const locale = cliOptions.locale; let transContent: string = ''; @@ -89,13 +99,45 @@ export class CodeGenerator { } transContent = readFileSync(transFile, 'utf8'); } - const {compiler: aotCompiler, reflector} = compiler.createAotCompiler(ngHost, { - debug: options.debug === true, - translations: transContent, - i18nFormat: cliOptions.i18nFormat, - locale: cliOptions.locale + + 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 }); - return new CodeGenerator(options, program, compilerHost, reflector, aotCompiler, ngHost); + 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); } } diff --git a/modules/@angular/compiler-cli/src/ng_host.ts b/modules/@angular/compiler-cli/src/ng_host.ts index 9ff1823c36..e1d975033e 100644 --- a/modules/@angular/compiler-cli/src/ng_host.ts +++ b/modules/@angular/compiler-cli/src/ng_host.ts @@ -21,7 +21,6 @@ export interface NgHostContext { fileExists(fileName: string): boolean; directoryExists(directoryName: string): boolean; readFile(fileName: string): string; - readResource(fileName: string): Promise; assumeFileExists(fileName: string): void; } @@ -76,7 +75,7 @@ export class NgHost implements AotCompilerHost { * * NOTE: (*) the relative path is computed depending on `isGenDirChildOfRootDir`. */ - resolveFileToImport(importedFile: string, containingFile: string): string { + getImportPath(containingFile: string, importedFile: 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)) { @@ -177,8 +176,6 @@ 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) { @@ -208,13 +205,5 @@ 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 e100ea3293..d37ec855ea 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. */ - resolveFileToImport(importedFile: string, containingFile: string): string { + getImportPath(containingFile: string, importedFile: 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 d7f4c6ade6..fddc69c866 100644 --- a/modules/@angular/compiler-cli/test/mocks.ts +++ b/modules/@angular/compiler-cli/test/mocks.ts @@ -28,14 +28,6 @@ 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 d780648e39..e2776b5cf8 100644 --- a/modules/@angular/compiler-cli/test/ng_host_spec.ts +++ b/modules/@angular/compiler-cli/test/ng_host_spec.ts @@ -6,6 +6,7 @@ * 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'; @@ -56,87 +57,87 @@ describe('NgHost', () => { describe('nestedGenDir', () => { it('should import node_module from factory', () => { - expect(hostNestedGenDir.resolveFileToImport( - '/tmp/project/node_modules/@angular/core.d.ts', - '/tmp/project/src/gen/my.ngfactory.ts', )) + expect(hostNestedGenDir.getImportPath( + '/tmp/project/src/gen/my.ngfactory.ts', + '/tmp/project/node_modules/@angular/core.d.ts')) .toEqual('@angular/core'); }); it('should import factory from factory', () => { - expect(hostNestedGenDir.resolveFileToImport( - '/tmp/project/src/my.other.ngfactory.ts', '/tmp/project/src/my.ngfactory.ts')) + expect(hostNestedGenDir.getImportPath( + '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/my.other.ngfactory.ts')) .toEqual('./my.other.ngfactory'); - expect(hostNestedGenDir.resolveFileToImport( - '/tmp/project/src/my.other.css.ts', '/tmp/project/src/a/my.ngfactory.ts')) + expect(hostNestedGenDir.getImportPath( + '/tmp/project/src/a/my.ngfactory.ts', '/tmp/project/src/my.other.css.ts')) .toEqual('../my.other.css'); - expect(hostNestedGenDir.resolveFileToImport( - '/tmp/project/src/a/my.other.css.shim.ts', '/tmp/project/src/my.ngfactory.ts')) + expect(hostNestedGenDir.getImportPath( + '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/a/my.other.css.shim.ts')) .toEqual('./a/my.other.css.shim'); }); it('should import application from factory', () => { - expect(hostNestedGenDir.resolveFileToImport( - '/tmp/project/src/my.other.ts', '/tmp/project/src/my.ngfactory.ts')) + expect(hostNestedGenDir.getImportPath( + '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/my.other.ts')) .toEqual('../my.other'); - expect(hostNestedGenDir.resolveFileToImport( - '/tmp/project/src/my.other.ts', '/tmp/project/src/a/my.ngfactory.ts')) + expect(hostNestedGenDir.getImportPath( + '/tmp/project/src/a/my.ngfactory.ts', '/tmp/project/src/my.other.ts')) .toEqual('../../my.other'); - expect(hostNestedGenDir.resolveFileToImport( - '/tmp/project/src/a/my.other.ts', '/tmp/project/src/my.ngfactory.ts')) + expect(hostNestedGenDir.getImportPath( + '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/a/my.other.ts')) .toEqual('../a/my.other'); }); }); - describe('siblingGenDir', () => { + describe('nestedGenDir', () => { it('should import node_module from factory', () => { - expect(hostSiblingGenDir.resolveFileToImport( - '/tmp/project/node_modules/@angular/core.d.ts', - '/tmp/project/src/gen/my.ngfactory.ts')) + expect(hostSiblingGenDir.getImportPath( + '/tmp/project/src/gen/my.ngfactory.ts', + '/tmp/project/node_modules/@angular/core.d.ts')) .toEqual('@angular/core'); }); it('should import factory from factory', () => { - expect(hostSiblingGenDir.resolveFileToImport( - '/tmp/project/src/my.other.ngfactory.ts', '/tmp/project/src/my.ngfactory.ts')) + expect(hostSiblingGenDir.getImportPath( + '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/my.other.ngfactory.ts')) .toEqual('./my.other.ngfactory'); - expect(hostSiblingGenDir.resolveFileToImport( - '/tmp/project/src/my.other.css.ts', '/tmp/project/src/a/my.ngfactory.ts')) + expect(hostSiblingGenDir.getImportPath( + '/tmp/project/src/a/my.ngfactory.ts', '/tmp/project/src/my.other.css.ts')) .toEqual('../my.other.css'); - expect(hostSiblingGenDir.resolveFileToImport( - '/tmp/project/src/a/my.other.css.shim.ts', '/tmp/project/src/my.ngfactory.ts')) + expect(hostSiblingGenDir.getImportPath( + '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/a/my.other.css.shim.ts')) .toEqual('./a/my.other.css.shim'); }); it('should import application from factory', () => { - expect(hostSiblingGenDir.resolveFileToImport( - '/tmp/project/src/my.other.ts', '/tmp/project/src/my.ngfactory.ts')) + expect(hostSiblingGenDir.getImportPath( + '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/my.other.ts')) .toEqual('./my.other'); - expect(hostSiblingGenDir.resolveFileToImport( - '/tmp/project/src/my.other.ts', '/tmp/project/src/a/my.ngfactory.ts')) + expect(hostSiblingGenDir.getImportPath( + '/tmp/project/src/a/my.ngfactory.ts', '/tmp/project/src/my.other.ts')) .toEqual('../my.other'); - expect(hostSiblingGenDir.resolveFileToImport( - '/tmp/project/src/a/my.other.ts', '/tmp/project/src/my.ngfactory.ts')) + expect(hostSiblingGenDir.getImportPath( + '/tmp/project/src/my.ngfactory.ts', '/tmp/project/src/a/my.other.ts')) .toEqual('./a/my.other'); }); }); it('should be able to produce an import from main @angular/core', () => { - expect(hostNestedGenDir.resolveFileToImport( - '/tmp/project/node_modules/@angular/core.d.ts', '/tmp/project/src/main.ts')) + expect(hostNestedGenDir.getImportPath( + '/tmp/project/src/main.ts', '/tmp/project/node_modules/@angular/core.d.ts')) .toEqual('@angular/core'); }); it('should be able to produce an import from main to a sub-directory', () => { - expect(hostNestedGenDir.resolveFileToImport('lib/utils.ts', 'main.ts')).toEqual('./lib/utils'); + expect(hostNestedGenDir.getImportPath('main.ts', 'lib/utils.ts')).toEqual('./lib/utils'); }); it('should be able to produce an import from to a peer file', () => { - expect(hostNestedGenDir.resolveFileToImport('lib/collections.ts', 'lib/utils.ts')) + expect(hostNestedGenDir.getImportPath('lib/utils.ts', 'lib/collections.ts')) .toEqual('./collections'); }); it('should be able to produce an import from to a sibling directory', () => { - expect(hostNestedGenDir.resolveFileToImport('lib/utils.ts', 'lib2/utils2.ts')) + expect(hostNestedGenDir.getImportPath('lib2/utils2.ts', 'lib/utils.ts')) .toEqual('../lib/utils'); }); diff --git a/modules/@angular/compiler/index.ts b/modules/@angular/compiler/index.ts index 215911dedb..8b37b1e698 100644 --- a/modules/@angular/compiler/index.ts +++ b/modules/@angular/compiler/index.ts @@ -25,7 +25,6 @@ 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 deleted file mode 100644 index 71d3e9e91b..0000000000 --- a/modules/@angular/compiler/src/aot/compiler_factory.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @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 f6862e056c..6c3fdf8001 100644 --- a/modules/@angular/compiler/src/aot/compiler_host.ts +++ b/modules/@angular/compiler/src/aot/compiler_host.ts @@ -25,17 +25,7 @@ export interface AotCompilerHost { getMetadataFor(modulePath: string): {[key: string]: any}|{[key: string]: any}[]; /** - * Converts an import into a file path. + * Converts a module name 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 59bf56efed..75dcfa582a 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 {ImportResolver} from './path_util'; +import {ImportGenerator} from './path_util'; export class JavaScriptEmitter implements OutputEmitter { - constructor(private _importGenerator: ImportResolver) {} + constructor(private _importGenerator: ImportGenerator) {} 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.resolveFileToImport(importedModuleUrl, moduleUrl)}');`); + `uire('${this._importGenerator.getImportPath(moduleUrl, importedModuleUrl)}');`); }); 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 07615af2d9..e8dfb24391 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 ImportResolver { - abstract resolveFileToImport(importedFilePath: string, containingFilePath: string): string; +export abstract class ImportGenerator { + abstract getImportPath(moduleUrlStr: string, importedUrlStr: string): string; } diff --git a/modules/@angular/compiler/src/output/ts_emitter.ts b/modules/@angular/compiler/src/output/ts_emitter.ts index c7dc722faa..e0628cd3f3 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 {ImportResolver} from './path_util'; +import {ImportGenerator} 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: ImportResolver) {} + constructor(private _importGenerator: ImportGenerator) {} 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.resolveFileToImport(importedModuleUrl, moduleUrl)}';`); + `ort * as ${prefix} from '${this._importGenerator.getImportPath(moduleUrl, importedModuleUrl)}';`); }); 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 d2fa19ed31..219519caac 100644 --- a/modules/@angular/compiler/test/aot/static_reflector_spec.ts +++ b/modules/@angular/compiler/test/aot/static_reflector_spec.ts @@ -511,12 +511,6 @@ 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 4b4222b105..c510b794cf 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 {ImportResolver} from '@angular/compiler/src/output/path_util'; +import {ImportGenerator} 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,8 +252,6 @@ function createOperatorFn(op: o.BinaryOperator) { o.DYNAMIC_TYPE); } -export class SimpleJsImportGenerator implements ImportResolver { - resolveFileToImport(importedUrlStr: string, moduleUrlStr: string): string { - return importedUrlStr; - } +export class SimpleJsImportGenerator implements ImportGenerator { + getImportPath(moduleUrlStr: string, importedUrlStr: string): string { return importedUrlStr; } }