refactor(compiler): simplify the CompilerHost used for transformers

- remove unneeded methods (`getNgCanonicalFileName`, `assumeFileExists`)
- simplify moduleName <-> fileName conversion logic as we don’t need to
  account for `genDir` anymore.
- rename `createNgCompilerHost` -> `createCompilerHost`
This commit is contained in:
Tobias Bosch
2017-08-14 11:04:55 -07:00
committed by Hans
parent 27d5058e01
commit 6a1ab61cce
9 changed files with 310 additions and 333 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AotCompilerHost, StaticSymbol} from '@angular/compiler';
import {AotCompilerHost, StaticSymbol, syntaxError} from '@angular/compiler';
import {AngularCompilerOptions, CollectorOptions, MetadataCollector, ModuleMetadata} from '@angular/tsc-wrapped';
import * as fs from 'fs';
import * as path from 'path';
@ -131,6 +131,9 @@ export abstract class BaseAotCompilerHost<C extends BaseAotCompilerHostContext>
loadResource(filePath: string): Promise<string>|string {
if (this.context.readResource) return this.context.readResource(filePath);
if (!this.context.fileExists(filePath)) {
throw syntaxError(`Error: Resource file not found: ${filePath}`);
}
return this.context.readFile(filePath);
}