feat(compiler-cli): new compiler api and command-line using TypeScript transformers

This commit is contained in:
Chuck Jazdzewski
2017-06-09 14:50:57 -07:00
committed by Matias Niemelä
parent 43c187b624
commit 3097083277
31 changed files with 1990 additions and 115 deletions

View File

@ -15,7 +15,7 @@ import * as path from 'path';
import * as ts from 'typescript';
import * as assert from 'assert';
import {tsc} from '@angular/tsc-wrapped/src/tsc';
import {NodeCompilerHostContext, __NGTOOLS_PRIVATE_API_2} from '@angular/compiler-cli';
import {__NGTOOLS_PRIVATE_API_2} from '@angular/compiler-cli';
const glob = require('glob');
@ -51,7 +51,6 @@ function codeGenTest(forceError = false) {
const wroteFiles: string[] = [];
const config = tsc.readConfiguration(project, basePath);
const hostContext = new NodeCompilerHostContext();
const delegateHost = ts.createCompilerHost(config.parsed.options, true);
const host: ts.CompilerHost = Object.assign(
{}, delegateHost,
@ -79,7 +78,10 @@ function codeGenTest(forceError = false) {
readResource: (fileName: string) => {
readResources.push(fileName);
return hostContext.readResource(fileName);
if (!host.fileExists(fileName)) {
throw new Error(`Compilation failed. Resource file not found: ${fileName}`);
}
return Promise.resolve(host.readFile(fileName));
}
})
.then(() => {
@ -128,7 +130,6 @@ function i18nTest() {
const wroteFiles: string[] = [];
const config = tsc.readConfiguration(project, basePath);
const hostContext = new NodeCompilerHostContext();
const delegateHost = ts.createCompilerHost(config.parsed.options, true);
const host: ts.CompilerHost = Object.assign(
{}, delegateHost,
@ -148,7 +149,10 @@ function i18nTest() {
outFile: undefined,
readResource: (fileName: string) => {
readResources.push(fileName);
return hostContext.readResource(fileName);
if (!host.fileExists(fileName)) {
throw new Error(`Compilation failed. Resource file not found: ${fileName}`);
}
return Promise.resolve(host.readFile(fileName));
},
})
.then(() => {