refactor(compiler): add createAotCompiler factory

Also adds 2 more methods to the `AotCompilerHost`:
- `loadResource`
- `resolveFileToImport`
This commit is contained in:
Tobias Bosch
2016-11-15 11:13:20 -08:00
committed by Chuck Jazdzewski
parent 484119e59f
commit 2235048432
13 changed files with 174 additions and 100 deletions

View File

@ -511,6 +511,12 @@ class MockAotCompilerHost implements AotCompilerHost {
constructor() {}
loadResource(filePath: string): Promise<string> { 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); }

View File

@ -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;
}
}