build: remove references to tsc-wrapped
(#19298)
With this commit `ngc` is used instead of `tsc-wrapped` for collecting metadata and tsickle rewriting and `tsc-wrapped` is removed from the repository. `@angular/tsc-wrapped@5` is now deprecated and is no longer used, updated, or maintained as part as of Angular 5.x.x. `@angular/tsc-wrapped@4` is still maintained and required by Angular 4.x.x and will be maintained as long as 4.x.x is in LTS. PR Close #19298
This commit is contained in:

committed by
Igor Minar

parent
4c73b52d5c
commit
f96142cd7c
@ -14,8 +14,7 @@ import 'reflect-metadata';
|
||||
import * as path from 'path';
|
||||
import * as ts from 'typescript';
|
||||
import * as assert from 'assert';
|
||||
import {tsc} from '@angular/tsc-wrapped/src/tsc';
|
||||
import {__NGTOOLS_PRIVATE_API_2} from '@angular/compiler-cli';
|
||||
import {__NGTOOLS_PRIVATE_API_2, readConfiguration} from '@angular/compiler-cli';
|
||||
|
||||
const glob = require('glob');
|
||||
|
||||
@ -50,14 +49,14 @@ function codeGenTest(forceError = false) {
|
||||
const readResources: string[] = [];
|
||||
const wroteFiles: string[] = [];
|
||||
|
||||
const config = tsc.readConfiguration(project, basePath);
|
||||
const delegateHost = ts.createCompilerHost(config.parsed.options, true);
|
||||
const config = readConfiguration(project);
|
||||
const delegateHost = ts.createCompilerHost(config.options, true);
|
||||
const host: ts.CompilerHost = Object.assign(
|
||||
{}, delegateHost,
|
||||
{writeFile: (fileName: string, ...rest: any[]) => { wroteFiles.push(fileName); }});
|
||||
const program = ts.createProgram(config.parsed.fileNames, config.parsed.options, host);
|
||||
const program = ts.createProgram(config.rootNames, config.options, host);
|
||||
|
||||
config.ngOptions.basePath = basePath;
|
||||
config.options.basePath = basePath;
|
||||
|
||||
console.log(`>>> running codegen for ${project}`);
|
||||
if (forceError) {
|
||||
@ -66,9 +65,9 @@ function codeGenTest(forceError = false) {
|
||||
return __NGTOOLS_PRIVATE_API_2
|
||||
.codeGen({
|
||||
basePath,
|
||||
compilerOptions: config.parsed.options, program, host,
|
||||
compilerOptions: config.options, program, host,
|
||||
|
||||
angularCompilerOptions: config.ngOptions,
|
||||
angularCompilerOptions: config.options,
|
||||
|
||||
// i18n options.
|
||||
i18nFormat: 'xlf',
|
||||
@ -129,21 +128,21 @@ function i18nTest() {
|
||||
const readResources: string[] = [];
|
||||
const wroteFiles: string[] = [];
|
||||
|
||||
const config = tsc.readConfiguration(project, basePath);
|
||||
const delegateHost = ts.createCompilerHost(config.parsed.options, true);
|
||||
const config = readConfiguration(project);
|
||||
const delegateHost = ts.createCompilerHost(config.options, true);
|
||||
const host: ts.CompilerHost = Object.assign(
|
||||
{}, delegateHost,
|
||||
{writeFile: (fileName: string, ...rest: any[]) => { wroteFiles.push(fileName); }});
|
||||
const program = ts.createProgram(config.parsed.fileNames, config.parsed.options, host);
|
||||
const program = ts.createProgram(config.rootNames, config.options, host);
|
||||
|
||||
config.ngOptions.basePath = basePath;
|
||||
config.options.basePath = basePath;
|
||||
|
||||
console.log(`>>> running i18n extraction for ${project}`);
|
||||
return __NGTOOLS_PRIVATE_API_2
|
||||
.extractI18n({
|
||||
basePath,
|
||||
compilerOptions: config.parsed.options, program, host,
|
||||
angularCompilerOptions: config.ngOptions,
|
||||
compilerOptions: config.options, program, host,
|
||||
angularCompilerOptions: config.options,
|
||||
i18nFormat: 'xlf',
|
||||
locale: undefined,
|
||||
outFile: undefined,
|
||||
@ -193,18 +192,14 @@ function lazyRoutesTest() {
|
||||
const basePath = path.join(__dirname, '../ngtools_src');
|
||||
const project = path.join(basePath, 'tsconfig-build.json');
|
||||
|
||||
const config = tsc.readConfiguration(project, basePath);
|
||||
const host = ts.createCompilerHost(config.parsed.options, true);
|
||||
const program = ts.createProgram(config.parsed.fileNames, config.parsed.options, host);
|
||||
const config = readConfiguration(project);
|
||||
const host = ts.createCompilerHost(config.options, true);
|
||||
const program = ts.createProgram(config.rootNames, config.options, host);
|
||||
|
||||
config.ngOptions.basePath = basePath;
|
||||
config.options.basePath = basePath;
|
||||
|
||||
const lazyRoutes = __NGTOOLS_PRIVATE_API_2.listLazyRoutes({
|
||||
program,
|
||||
host,
|
||||
angularCompilerOptions: config.ngOptions,
|
||||
entryModule: 'app.module#AppModule'
|
||||
});
|
||||
const lazyRoutes = __NGTOOLS_PRIVATE_API_2.listLazyRoutes(
|
||||
{program, host, angularCompilerOptions: config.options, entryModule: 'app.module#AppModule'});
|
||||
|
||||
const expectations: {[route: string]: string} = {
|
||||
'./lazy.module#LazyModule': 'lazy.module.ts',
|
||||
|
@ -14,8 +14,7 @@ import 'reflect-metadata';
|
||||
import * as path from 'path';
|
||||
import * as ts from 'typescript';
|
||||
import * as assert from 'assert';
|
||||
import {tsc} from '@angular/tsc-wrapped/src/tsc';
|
||||
import {CompilerOptions, CodeGenerator, CompilerHostContext, NodeCompilerHostContext} from '@angular/compiler-cli';
|
||||
import {CompilerOptions, CodeGenerator, CompilerHostContext, NodeCompilerHostContext, readConfiguration} from '@angular/compiler-cli';
|
||||
|
||||
/**
|
||||
* Main method.
|
||||
@ -46,10 +45,10 @@ function main() {
|
||||
}
|
||||
}
|
||||
|
||||
const config = tsc.readConfiguration(project, basePath);
|
||||
config.ngOptions.basePath = basePath;
|
||||
const config = readConfiguration(project);
|
||||
config.options.basePath = basePath;
|
||||
// This flag tells ngc do not recompile libraries.
|
||||
config.ngOptions.generateCodeForLibraries = false;
|
||||
config.options.generateCodeForLibraries = false;
|
||||
|
||||
console.log(`>>> running codegen for ${project}`);
|
||||
codegen(
|
||||
@ -86,21 +85,21 @@ function main() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple adaption of tsc-wrapped main to just run codegen with a CompilerHostContext
|
||||
* Simple adaption of main to just run codegen with a CompilerHostContext
|
||||
*/
|
||||
function codegen(
|
||||
config: {parsed: ts.ParsedCommandLine, ngOptions: CompilerOptions},
|
||||
config: {options: CompilerOptions, rootNames: string[]},
|
||||
hostContextFactory: (host: ts.CompilerHost) => CompilerHostContext) {
|
||||
const host = ts.createCompilerHost(config.parsed.options, true);
|
||||
const host = ts.createCompilerHost(config.options, true);
|
||||
|
||||
// HACK: patch the realpath to solve symlink issue here:
|
||||
// https://github.com/Microsoft/TypeScript/issues/9552
|
||||
// todo(misko): remove once facade symlinks are removed
|
||||
host.realpath = (path) => path;
|
||||
|
||||
const program = ts.createProgram(config.parsed.fileNames, config.parsed.options, host);
|
||||
const program = ts.createProgram(config.rootNames, config.options, host);
|
||||
|
||||
return CodeGenerator.create(config.ngOptions, {
|
||||
return CodeGenerator.create(config.options, {
|
||||
} as any, program, host, hostContextFactory(host)).codegen();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user