parent
3fec27961e
commit
e81dea695c
|
@ -131,7 +131,15 @@ export class CodeGenerator {
|
||||||
static create(
|
static create(
|
||||||
options: AngularCompilerOptions, program: ts.Program, compilerHost: ts.CompilerHost,
|
options: AngularCompilerOptions, program: ts.Program, compilerHost: ts.CompilerHost,
|
||||||
reflectorHostContext?: ReflectorHostContext): CodeGenerator {
|
reflectorHostContext?: ReflectorHostContext): CodeGenerator {
|
||||||
const xhr: compiler.XHR = {get: (s: string) => Promise.resolve(compilerHost.readFile(s))};
|
const xhr: compiler.XHR = {
|
||||||
|
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 urlResolver: compiler.UrlResolver = compiler.createOfflineCompileUrlResolver();
|
const urlResolver: compiler.UrlResolver = compiler.createOfflineCompileUrlResolver();
|
||||||
const reflectorHost = new ReflectorHost(program, compilerHost, options, reflectorHostContext);
|
const reflectorHost = new ReflectorHost(program, compilerHost, options, reflectorHostContext);
|
||||||
const staticReflector = new StaticReflector(reflectorHost);
|
const staticReflector = new StaticReflector(reflectorHost);
|
||||||
|
|
|
@ -141,7 +141,15 @@ class Extractor {
|
||||||
static create(
|
static create(
|
||||||
options: tsc.AngularCompilerOptions, program: ts.Program,
|
options: tsc.AngularCompilerOptions, program: ts.Program,
|
||||||
compilerHost: ts.CompilerHost): Extractor {
|
compilerHost: ts.CompilerHost): Extractor {
|
||||||
const xhr: compiler.XHR = {get: (s: string) => Promise.resolve(compilerHost.readFile(s))};
|
const xhr: compiler.XHR = {
|
||||||
|
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 urlResolver: compiler.UrlResolver = compiler.createOfflineCompileUrlResolver();
|
const urlResolver: compiler.UrlResolver = compiler.createOfflineCompileUrlResolver();
|
||||||
const reflectorHost = new ReflectorHost(program, compilerHost, options);
|
const reflectorHost = new ReflectorHost(program, compilerHost, options);
|
||||||
const staticReflector = new StaticReflector(reflectorHost);
|
const staticReflector = new StaticReflector(reflectorHost);
|
||||||
|
|
Loading…
Reference in New Issue