perf(compiler): only use tsickle if needed (#19275)

PR Close #19275
This commit is contained in:
Tobias Bosch 2017-09-15 18:02:22 -07:00 committed by Igor Minar
parent edd5f5a333
commit 8f95b751e0
1 changed files with 10 additions and 5 deletions

View File

@ -16,6 +16,7 @@ import * as path from 'path';
import * as tsickle from 'tsickle';
import * as api from './transformers/api';
import * as ngc from './transformers/entry_points';
import {GENERATED_FILES} from './transformers/util';
import {exitCodeFromResult, performCompilation, readConfiguration, formatDiagnostics, Diagnostics, ParsedConfiguration, PerformCompilationResult} from './perform_compile';
import {performWatchCompilation, createPerformWatchHost} from './perform_watch';
@ -38,17 +39,21 @@ export function main(
return reportErrorsAndExit(options, compileDiags, consoleError);
}
function createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback {
function createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback|undefined {
const transformDecorators = options.annotationsAs !== 'decorators';
const transformTypesToClosure = options.annotateForClosureCompiler;
if (!transformDecorators && !transformTypesToClosure) {
return undefined;
}
const tsickleHost: tsickle.TsickleHost = {
shouldSkipTsickleProcessing: (fileName) => /\.d\.ts$/.test(fileName),
shouldSkipTsickleProcessing: (fileName) =>
/\.d\.ts$/.test(fileName) || GENERATED_FILES.test(fileName),
pathToModuleName: (context, importPath) => '',
shouldIgnoreWarningsForPath: (filePath) => false,
fileNameToModuleId: (fileName) => fileName,
googmodule: false,
untyped: true,
convertIndexImportShorthand: true,
transformDecorators: options.annotationsAs !== 'decorators',
transformTypesToClosure: options.annotateForClosureCompiler,
convertIndexImportShorthand: true, transformDecorators, transformTypesToClosure,
};
return ({