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:
Chuck Jazdzewski
2017-09-21 13:55:52 -07:00
committed by Igor Minar
parent 4c73b52d5c
commit f96142cd7c
104 changed files with 336 additions and 6594 deletions
-1
View File
@@ -135,7 +135,6 @@ groups:
compiler-cli:
conditions:
files:
- "packages/tsc-wrapped/*"
- "packages/compiler-cli/*"
- "packages/bazel/*"
users:
-1
View File
@@ -221,7 +221,6 @@ The following is the list of supported scopes:
* **platform-webworker-dynamic**
* **router**
* **upgrade**
* **tsc-wrapped**
There are currently a few exceptions to the "use package name" rule:
+1 -1
View File
@@ -66,7 +66,7 @@ You can think of `.metadata.json` as a diagram of the overall structure of a dec
<div class="l-sub-section">
Angular's [schema.ts](https://github.com/angular/angular/blob/master/packages/tsc-wrapped/src/schema.ts)
Angular's [schema.ts](https://github.com/angular/angular/blob/master/packages/compiler-cli/src/metadata/schema.ts)
describes the JSON format as a collection of TypeScript interfaces.
</div>
@@ -14,7 +14,6 @@
"@angular/platform-browser-dynamic",
"@angular/platform-server",
"@angular/router",
"@angular/tsc-wrapped",
"@angular/upgrade",
"angular-in-memory-web-api",
"core-js",
@@ -41,7 +41,6 @@ const ANGULAR_PACKAGES = [
'platform-browser-dynamic',
'platform-server',
'router',
'tsc-wrapped',
'upgrade',
];
@@ -26,13 +26,11 @@ describe('example-boilerplate tool', () => {
it('should override the Angular node_modules with the locally built Angular packages if `useLocal` is true', () => {
const numberOfAngularPackages = 12;
const numberOfAngularToolsPackages = 1;
exampleBoilerPlate.add(true);
expect(exampleBoilerPlate.overridePackage).toHaveBeenCalledTimes(numberOfAngularPackages + numberOfAngularToolsPackages);
expect(exampleBoilerPlate.overridePackage).toHaveBeenCalledTimes(numberOfAngularPackages);
// for example
expect(exampleBoilerPlate.overridePackage).toHaveBeenCalledWith(path.resolve(__dirname, '../../../dist/packages-dist'), 'common');
expect(exampleBoilerPlate.overridePackage).toHaveBeenCalledWith(path.resolve(__dirname, '../../../dist/packages-dist'), 'core');
expect(exampleBoilerPlate.overridePackage).toHaveBeenCalledWith(path.resolve(__dirname, '../../../dist/packages-dist'), 'tsc-wrapped');
});
it('should process all the example folders', () => {
-1
View File
@@ -23,7 +23,6 @@
"@angular/platform-browser-dynamic": "~4.3.1",
"@angular/platform-server": "~4.3.1",
"@angular/router": "~4.3.1",
"@angular/tsc-wrapped": "~4.3.1",
"@angular/upgrade": "~4.3.1",
"angular-in-memory-web-api": "~0.4.0",
"core-js": "^2.4.1",
+26 -17
View File
@@ -25,9 +25,12 @@ PACKAGES=(core
language-service
benchpress)
TSC_PACKAGES=(compiler-cli
language-service
benchpress)
NODE_PACKAGES=(compiler-cli
benchpress
tsc-wrapped)
benchpress)
BUILD_ALL=true
BUNDLE=true
@@ -38,6 +41,7 @@ BUILD_EXAMPLES=true
COMPILE_SOURCE=true
TYPECHECK_ALL=true
BUILD_TOOLS=true
export NODE_PATH=${NODE_PATH:-}:${currentDir}/dist/tools
for ARG in "$@"; do
case "$ARG" in
@@ -156,7 +160,7 @@ runRollup() {
if [[ -f "${1}/rollup.config.js" ]]; then
cd ${1}
echo "====== $ROLLUP -c ${1}/rollup.config.js"
echo "====== $ROLLUP -c ${1}/rollup.config.js --sourcemap"
$ROLLUP -c rollup.config.js --sourcemap >/dev/null 2>&1
# Recurse for sub directories
@@ -216,11 +220,12 @@ minify() {
# None
#######################################
compilePackage() {
echo "====== [${3}]: COMPILING: ${NGC} -p ${1}/tsconfig-build.json"
# For NODE_PACKAGES items (not getting rolled up)
if containsElement "${3}" "${NODE_PACKAGES[@]}"; then
# For TSC_PACKAGES items
if containsElement "${3}" "${TSC_PACKAGES[@]}"; then
echo "====== [${3}]: COMPILING: ${TSC} -p ${1}/tsconfig-build.json"
$TSC -p ${1}/tsconfig-build.json
else
echo "====== [${3}]: COMPILING: ${NGC} -p ${1}/tsconfig-build.json"
local package_name=$(basename "${2}")
$NGC -p ${1}/tsconfig-build.json
echo "====== Create ${1}/../${package_name}.d.ts re-export file for tsickle"
@@ -247,9 +252,15 @@ compilePackage() {
# None
#######################################
compilePackageES5() {
echo "====== [${3}]: COMPILING: ${NGC} -p ${1}/tsconfig-build.json --target es5 -d false --outDir ${2} --importHelpers true --sourceMap"
local package_name=$(basename "${2}")
$NGC -p ${1}/tsconfig-build.json --target es5 -d false --outDir ${2} --importHelpers true --sourceMap
if containsElement "${3}" "${TSC_PACKAGES[@]}"; then
echo "====== [${3}]: COMPILING: ${TSC} -p ${1}/tsconfig-build.json --target es5 -d false --outDir ${2} --importHelpers true --sourceMap"
local package_name=$(basename "${2}")
$TSC -p ${1}/tsconfig-build.json --target es5 -d false --outDir ${2} --importHelpers true --sourceMap
else
echo "====== [${3}]: COMPILING: ${NGC} -p ${1}/tsconfig-build.json --target es5 -d false --outDir ${2} --importHelpers true --sourceMap"
local package_name=$(basename "${2}")
$NGC -p ${1}/tsconfig-build.json --target es5 -d false --outDir ${2} --importHelpers true --sourceMap
fi
for DIR in ${1}/* ; do
[ -d "${DIR}" ] || continue
@@ -315,7 +326,7 @@ echo "====== BUILDING: Version ${VERSION}"
N="
"
TSC=`pwd`/node_modules/.bin/tsc
NGC="node --max-old-space-size=3000 `pwd`/dist/packages-dist/tsc-wrapped/src/main"
NGC="node --max-old-space-size=3000 `pwd`/dist/tools/@angular/compiler-cli/src/main"
UGLIFYJS=`pwd`/node_modules/.bin/uglifyjs
TSCONFIG=./tools/tsconfig.json
ROLLUP=`pwd`/node_modules/.bin/rollup
@@ -394,14 +405,12 @@ if [[ ${BUILD_ALL} == true ]]; then
fi
if [[ ${BUILD_TOOLS} == true || ${BUILD_ALL} == true ]]; then
echo "====== (tsc-wrapped)COMPILING: \$(npm bin)/tsc -p packages/tsc-wrapped/tsconfig.json ====="
$(npm bin)/tsc -p packages/tsc-wrapped/tsconfig.json
echo "====== (tsc-wrapped)COMPILING: \$(npm bin)/tsc -p packages/tsc-wrapped/tsconfig-build.json ====="
$(npm bin)/tsc -p packages/tsc-wrapped/tsconfig-build.json
cp ./packages/tsc-wrapped/package.json ./dist/packages-dist/tsc-wrapped
cp ./packages/tsc-wrapped/README.md ./dist/packages-dist/tsc-wrapped
updateVersionReferences dist/packages-dist/tsc-wrapped
echo "====== (compiler)COMPILING: \$(npm bin)/tsc -p packages/compiler/tsconfig-tools.json"
$(npm bin)/tsc -p packages/compiler/tsconfig-tools.json
echo "====== (compiler)COMPILING: \$(npm bin)/tsc -p packages/compiler-cli/tsconfig-tools.json"
$(npm bin)/tsc -p packages/compiler-cli/tsconfig-tools.json
mkdir -p ./dist/packages-dist
rsync -a packages/bazel/ ./dist/packages-dist/bazel
# Remove BEGIN-INTERNAL...END-INTERAL blocks
# https://stackoverflow.com/questions/24175271/how-can-i-match-multi-line-patterns-in-the-command-line-with-perl-style-regex
@@ -10,7 +10,6 @@
"@angular/core": "file:../../dist/packages-dist/core",
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser",
"@angular/platform-server": "file:../../dist/packages-dist/platform-server",
"@angular/tsc-wrapped": "file:../../dist/packages-dist/tsc-wrapped",
"google-closure-compiler": "git+https://github.com/alexeagle/closure-compiler.git#packagejson.dist",
"rxjs": "file:../../node_modules/rxjs",
"typescript": "file:../../node_modules/typescript",
-1
View File
@@ -10,7 +10,6 @@
"@angular/core": "file:../../dist/packages-dist/core",
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser",
"@angular/platform-server": "file:../../dist/packages-dist/platform-server",
"@angular/tsc-wrapped": "file:../../dist/packages-dist/tsc-wrapped",
"google-closure-compiler": "git+https://github.com/alexeagle/closure-compiler.git#packagejson.dist",
"rxjs": "file:../../node_modules/rxjs",
"typescript": "file:../../node_modules/typescript",
@@ -12,7 +12,6 @@
"@angular/language-service": "file:../../dist/packages-dist/language-service",
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser",
"@angular/platform-server": "file:../../dist/packages-dist/platform-server",
"@angular/tsc-wrapped": "file:../../dist/packages-dist/tsc-wrapped",
"@types/minimist": "^1.2.0",
"@types/node": "^7.0.5",
"minimist": "^1.2.0",
@@ -15,7 +15,6 @@
"@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic",
"@angular/platform-server": "file:../../dist/packages-dist/platform-server",
"@angular/router": "file:../../dist/packages-dist/router",
"@angular/tsc-wrapped": "file:../../dist/packages-dist/tsc-wrapped",
"@angular/upgrade": "file:../../dist/packages-dist/upgrade",
"@types/jasmine": "2.5.41",
"rxjs": "file:../../node_modules/rxjs",
-1
View File
@@ -61,7 +61,6 @@ module.exports = function(config) {
'dist/all/@angular/examples/**/e2e_test/*',
'dist/all/@angular/language-service/**',
'dist/all/@angular/router/test/**',
'dist/all/@angular/tsc-wrapped/**',
'dist/all/@angular/platform-browser/testing/e2e_util.js',
'dist/all/angular1_router.js',
'dist/examples/**/e2e_test/**',
+5 -4
View File
@@ -12,9 +12,7 @@
"paths": {
"selenium-webdriver": ["../node_modules/@types/selenium-webdriver/index.d.ts"],
"rxjs/*": ["../node_modules/rxjs/*"],
"@angular/*": ["../dist/all/@angular/*"],
"@angular/tsc-wrapped": ["../dist/packages-dist/tsc-wrapped"],
"@angular/tsc-wrapped/*": ["../dist/packages-dist/tsc-wrapped/*"]
"@angular/*": ["../dist/all/@angular/*"]
},
"rootDir": ".",
"inlineSourceMap": true,
@@ -32,5 +30,8 @@
"benchmarks_external",
"payload_tests",
"rollup-test"
]
],
"angularCompilerOptions": {
"skipTemplateCodegen": true
}
}
@@ -5,7 +5,8 @@
"baseUrl": ".",
"rootDir": "../../",
"paths": {
"@angular/animations": ["../../../../dist/packages/animations"]
"@angular/animations": ["../../../../dist/packages/animations"],
"@angular/core": ["../../../../dist/packages/core"]
},
"outDir": "../../../../dist/packages/animations"
},
@@ -19,7 +20,8 @@
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"strictMetadataEmit": false,
"skipTemplateCodegen": true,
"flatModuleOutFile": "testing.js",
"flatModuleId": "@angular/animations/browser/testing"
}
@@ -5,7 +5,8 @@
"baseUrl": ".",
"rootDir": "../",
"paths": {
"@angular/animations": ["../../../dist/packages/animations"]
"@angular/animations": ["../../../dist/packages/animations"],
"@angular/core": ["../../../dist/packages/core"]
},
"outDir": "../../../dist/packages/animations"
},
@@ -18,7 +19,8 @@
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"strictMetadataEmit": false,
"skipTemplateCodegen": true,
"flatModuleOutFile": "browser.js",
"flatModuleId": "@angular/animations/browser"
}
+5 -2
View File
@@ -4,7 +4,9 @@
"compilerOptions": {
"baseUrl": ".",
"rootDir": ".",
"paths": {},
"paths": {
"@angular/core": ["../../dist/packages/core"]
},
"outDir": "../../dist/packages/animations"
},
@@ -16,7 +18,8 @@
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"strictMetadataEmit": false,
"skipTemplateCodegen": true,
"flatModuleOutFile": "animations.js",
"flatModuleId": "@angular/animations"
}
@@ -19,7 +19,8 @@
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"strictMetadataEmit": false,
"skipTemplateCodegen": true,
"flatModuleOutFile": "testing.js",
"flatModuleId": "@angular/common/http/testing"
}
+2 -1
View File
@@ -17,7 +17,8 @@
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"strictMetadataEmit": false,
"skipTemplateCodegen": true,
"flatModuleOutFile": "http.js",
"flatModuleId": "@angular/common/http"
}
+4 -1
View File
@@ -19,5 +19,8 @@
},
"exclude": [
"./closure-locale.ts"
]
],
"angularCompilerOptions": {
"skipTemplateCodegen": true
}
}
+2 -1
View File
@@ -18,7 +18,8 @@
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"strictMetadataEmit": false,
"skipTemplateCodegen": true,
"flatModuleOutFile": "testing.js",
"flatModuleId": "@angular/common/testing"
}
+2 -1
View File
@@ -17,7 +17,8 @@
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"strictMetadataEmit": false,
"skipTemplateCodegen": true,
"flatModuleOutFile": "common.js",
"flatModuleId": "@angular/common"
}
+1 -2
View File
@@ -9,8 +9,7 @@ ts_library(
]),
module_name = "@angular/compiler-cli",
deps = [
"//packages/compiler",
"//packages/tsc-wrapped",
"//packages/compiler"
],
tsconfig = ":tsconfig-build.json",
)
+2 -2
View File
@@ -112,7 +112,7 @@ with the one already used in the plugin for TypeScript typechecking and emit.
## Design
At a high level, this program
- collects static metadata about the sources using the `tsc-wrapped` package
- collects static metadata about the sources
- uses the `OfflineCompiler` from `@angular/compiler` to codegen additional `.ts` files
- these `.ts` files are written to the `genDir` path, then compiled together with the application.
@@ -130,7 +130,7 @@ $ ./scripts/ci/offline_compiler_test.sh
# Recompile @angular/core module (needs to use tsc-ext to keep the metadata)
$ export NODE_PATH=${NODE_PATH}:$(pwd)/dist/all:$(pwd)/dist/tools
$ node dist/tools/@angular/tsc-wrapped/src/main -p packages/core/tsconfig-build.json
$ node dist/tools/@angular/compiler-cli/src/main -p packages/core/tsconfig-build.json
# Iterate on the test
$ cd /tmp/wherever/e2e_test.1464388257/
@@ -17,10 +17,7 @@ var rxjsLocation = normalize('../../node_modules/rxjs');
var tslibLocation = normalize('../../node_modules/tslib');
var esm = 'esm/';
var locations = {
'tsc-wrapped': normalize('../../dist/tools/@angular') + '/',
'compiler-cli': normalize('../../dist/packages') + '/'
};
var locations = {'compiler-cli': normalize('../../dist/packages') + '/'};
var esm_suffixes = {};
@@ -30,11 +27,6 @@ function normalize(fileName) {
function resolve(id, from) {
// console.log('Resolve id:', id, 'from', from)
if (id == '@angular/tsc-wrapped') {
// Hack to restrict the import to not include the index of @angular/tsc-wrapped so we don't
// rollup tsickle.
return locations['tsc-wrapped'] + 'tsc-wrapped/src/collector.js';
}
var match = m.exec(id);
if (match) {
var packageName = match[1];
@@ -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();
}
-1
View File
@@ -9,7 +9,6 @@
"ng-xi18n": "./src/extract_i18n.js"
},
"dependencies": {
"@angular/tsc-wrapped": "5.0.0-beta.7",
"reflect-metadata": "^0.1.2",
"minimist": "^1.2.0",
"tsickle": "^0.24.0",
@@ -431,6 +431,10 @@ function addReferencesToSourceFile(sf: ts.SourceFile, genFileNames: string[]) {
sf.referencedFiles = newReferencedFiles;
}
export function getOriginalReferences(sourceFile: ts.SourceFile): ts.FileReference[]|undefined {
return sourceFile && (sourceFile as any).originalReferencedFiles;
}
function dotRelative(from: string, to: string): string {
const rPath: string = path.relative(from, to).replace(/\\/g, '/');
return rPath.startsWith('.') ? rPath : './' + rPath;
@@ -15,7 +15,7 @@ import {TypeCheckHost, translateDiagnostics} from '../diagnostics/translate_diag
import {ModuleMetadata, createBundleIndexHost} from '../metadata/index';
import {CompilerHost, CompilerOptions, CustomTransformers, DEFAULT_ERROR_CODE, Diagnostic, EmitFlags, Program, SOURCE, TsEmitArguments, TsEmitCallback} from './api';
import {TsCompilerAotCompilerTypeCheckHostAdapter} from './compiler_host';
import {TsCompilerAotCompilerTypeCheckHostAdapter, getOriginalReferences} from './compiler_host';
import {LowerMetadataCache, getExpressionLoweringTransformFactory} from './lower_expressions';
import {getAngularEmitterTransformFactory} from './node_emitter_transform';
import {GENERATED_FILES, StructureIsReused, tsStructureIsReused} from './util';
@@ -173,15 +173,34 @@ class AngularCompilerProgram implements Program {
};
}
const emitResult = emitCallback({
program: this.tsProgram,
host: this.host,
options: this.options,
writeFile: createWriteFileCallback(genFiles, this.host, outSrcMapping),
emitOnlyDtsFiles: (emitFlags & (EmitFlags.DTS | EmitFlags.JS)) == EmitFlags.DTS,
customTransformers: this.calculateTransforms(genFiles, customTransformers)
});
// Restore the original references before we emit so TypeScript doesn't emit
// a reference to the .d.ts file.
const augmentedReferences = new Map<ts.SourceFile, ts.FileReference[]>();
for (const sourceFile of this.tsProgram.getSourceFiles()) {
const originalReferences = getOriginalReferences(sourceFile);
if (originalReferences) {
augmentedReferences.set(sourceFile, sourceFile.referencedFiles);
sourceFile.referencedFiles = originalReferences;
}
}
let emitResult: ts.EmitResult;
try {
emitResult = emitCallback({
program: this.tsProgram,
host: this.host,
options: this.options,
writeFile: createWriteFileCallback(genFiles, this.host, outSrcMapping),
emitOnlyDtsFiles: (emitFlags & (EmitFlags.DTS | EmitFlags.JS)) == EmitFlags.DTS,
customTransformers: this.calculateTransforms(genFiles, customTransformers)
});
} finally {
// Restore the references back to the augmented value to ensure that the
// checks that TypeScript makes for project structure reuse will succeed.
for (const [sourceFile, references] of Array.from(augmentedReferences)) {
sourceFile.referencedFiles = references;
}
}
if (!outSrcMapping.length) {
// if no files were emitted by TypeScript, also don't emit .json files
@@ -464,6 +483,7 @@ function getAotCompilerOptions(options: CompilerOptions): AotCompilerOptions {
enableSummariesForJit: true,
preserveWhitespaces: options.preserveWhitespaces,
fullTemplateTypeCheck: options.fullTemplateTypeCheck,
rootDir: options.rootDir,
};
}

Some files were not shown because too many files have changed in this diff Show More