feat(compiler-cli): new compiler api and command-line using TypeScript transformers
This commit is contained in:

committed by
Matias Niemelä

parent
43c187b624
commit
3097083277
@ -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(() => {
|
||||
|
Reference in New Issue
Block a user