refactor(compiler-cli): remove tsickle from dependencies (#25649)
Users can still install tsickle if they want closure-compatible output. PR Close #25649
This commit is contained in:
parent
a22fb91e1a
commit
29761ea5f8
|
@ -12,7 +12,6 @@
|
|||
"dependencies": {
|
||||
"reflect-metadata": "^0.1.2",
|
||||
"minimist": "^1.2.0",
|
||||
"tsickle": "^0.32.1",
|
||||
"chokidar": "^1.4.2",
|
||||
"convert-source-map": "^1.5.1",
|
||||
"magic-string": "^0.25.0",
|
||||
|
|
|
@ -11,11 +11,8 @@
|
|||
import 'reflect-metadata';
|
||||
|
||||
import * as ts from 'typescript';
|
||||
import * as fs from 'fs';
|
||||
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, filterErrorsAndWarnings} from './perform_compile';
|
||||
|
@ -66,6 +63,7 @@ function createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback|un
|
|||
convertIndexImportShorthand: false, transformDecorators, transformTypesToClosure,
|
||||
};
|
||||
|
||||
if (options.annotateForClosureCompiler || options.annotationsAs === 'static fields') {
|
||||
return ({
|
||||
program,
|
||||
targetSourceFile,
|
||||
|
@ -76,12 +74,26 @@ function createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback|un
|
|||
host,
|
||||
options
|
||||
}) =>
|
||||
tsickle.emitWithTsickle(
|
||||
program, {...tsickleHost, options, host}, host, options, targetSourceFile,
|
||||
writeFile, cancellationToken, emitOnlyDtsFiles, {
|
||||
// tslint:disable-next-line:no-require-imports only depend on tsickle if requested
|
||||
require('tsickle').emitWithTsickle(
|
||||
program, {...tsickleHost, options, host}, host, options, targetSourceFile, writeFile,
|
||||
cancellationToken, emitOnlyDtsFiles, {
|
||||
beforeTs: customTransformers.before,
|
||||
afterTs: customTransformers.after,
|
||||
});
|
||||
} else {
|
||||
return ({
|
||||
program,
|
||||
targetSourceFile,
|
||||
writeFile,
|
||||
cancellationToken,
|
||||
emitOnlyDtsFiles,
|
||||
customTransformers = {},
|
||||
}) =>
|
||||
program.emit(
|
||||
targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles,
|
||||
{after: customTransformers.after, before: customTransformers.before});
|
||||
}
|
||||
}
|
||||
|
||||
export interface NgcParsedConfiguration extends ParsedConfiguration { watch?: boolean; }
|
||||
|
|
|
@ -554,10 +554,10 @@ describe('ngc transformer command-line', () => {
|
|||
});
|
||||
|
||||
describe('closure', () => {
|
||||
it('should not generate closure specific code by default', () => {
|
||||
it('should not run tsickle by default', () => {
|
||||
writeConfig(`{
|
||||
"extends": "./tsconfig-base.json",
|
||||
"files": ["mymodule.ts"]
|
||||
"files": ["mymodule.ts"],
|
||||
}`);
|
||||
write('mymodule.ts', `
|
||||
import {NgModule, Component} from '@angular/core';
|
||||
|
@ -575,7 +575,8 @@ describe('ngc transformer command-line', () => {
|
|||
const mymodulejs = path.resolve(outDir, 'mymodule.js');
|
||||
const mymoduleSource = fs.readFileSync(mymodulejs, 'utf8');
|
||||
expect(mymoduleSource).not.toContain('@fileoverview added by tsickle');
|
||||
expect(mymoduleSource).toContain('MyComp.decorators = [');
|
||||
expect(mymoduleSource).toContain('MyComp = __decorate');
|
||||
expect(mymoduleSource).not.toContain('MyComp.decorators = [');
|
||||
});
|
||||
|
||||
it('should add closure annotations', () => {
|
||||
|
|
Loading…
Reference in New Issue