Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit cf5903a

Browse files
jjuddevmar
authored andcommitted
Stop writing the externs file twice (#158)
The externs were being written twice: once to their output location specified on the CLI and again to './tsickle_externs.js'. This removes tsickle_externs.js. The file appears to be a remnant of the closure compilation part of the CLI, which has been removed.
1 parent 47217b0 commit cf5903a

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/main.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ import * as ts from 'typescript';
88
import * as cli_support from './cli_support';
99
import * as tsickle from './tsickle';
1010

11-
/**
12-
* Internal file name for the generated Closure externs.
13-
* This is never written to disk, but should be unique with respect to
14-
* the js files that may actually exist.
15-
*/
16-
const internalExternsFileName = 'tsickle_externs.js';
17-
1811
/** Tsickle settings passed on the command line. */
1912
interface Settings {
2013
/** If provided, path to save externs to. */
@@ -137,7 +130,7 @@ function createSourceReplacingCompilerHost(
137130
* Doesn't write any files to disk; all JS content is returned in a map.
138131
*/
139132
function toClosureJS(options: ts.CompilerOptions, fileNames: string[]):
140-
{jsFiles?: {[fileName: string]: string}, errors?: ts.Diagnostic[]} {
133+
{jsFiles?: {[fileName: string]: string}, externs?: string, errors?: ts.Diagnostic[]} {
141134
// Parse and load the program without tsickle processing.
142135
// This is so:
143136
// - error messages point at the original source text
@@ -194,9 +187,7 @@ function toClosureJS(options: ts.CompilerOptions, fileNames: string[]):
194187
}
195188
}
196189

197-
jsFiles[internalExternsFileName] = tsickleExterns;
198-
199-
return {jsFiles};
190+
return {jsFiles, externs: tsickleExterns};
200191
}
201192

202193
function main(args: string[]) {
@@ -209,7 +200,8 @@ function main(args: string[]) {
209200

210201
// Run tsickle+TSC to convert inputs to Closure JS files.
211202
let jsFiles: {[fileName: string]: string};
212-
({jsFiles, errors} = toClosureJS(options, fileNames));
203+
let externs: string;
204+
({jsFiles, externs, errors} = toClosureJS(options, fileNames));
213205
if (errors && errors.length > 0) {
214206
console.error(tsickle.formatDiagnostics(errors));
215207
process.exit(1);
@@ -224,7 +216,7 @@ function main(args: string[]) {
224216
}
225217

226218
if (settings.externsPath) {
227-
fs.writeFileSync(settings.externsPath, jsFiles[internalExternsFileName]);
219+
fs.writeFileSync(settings.externsPath, externs);
228220
}
229221
}
230222

0 commit comments

Comments
 (0)