1
1
#!/usr/bin/env node
2
2
3
- import * as closure from 'google-closure-compiler' ;
4
3
import * as fs from 'fs' ;
5
4
import * as minimist from 'minimist' ;
6
5
import * as path from 'path' ;
@@ -23,21 +22,17 @@ interface Settings {
23
22
24
23
/** If provided, path to save externs to. */
25
24
externsPath ? : string ;
26
-
27
- /** Path to write the final JS bundle to. */
28
- outputPath: string ;
29
25
}
30
26
31
27
function usage ( ) {
32
28
console . error ( `usage: tsickle [tsickle args] -- [tsc args]
33
29
34
30
example:
35
- tsickle --output bundle .js -- -p src --noImplicitAny
31
+ tsickle --externs=/foo/externs .js -- -p src --noImplicitAny
36
32
37
33
tsickle flags are:
38
34
--saveTemporaries save intermediate .js files to disk
39
35
--externs=PATH save generated Closure externs.js to PATH
40
- --output=PATH write final Closure bundle to PATH
41
36
` ) ;
42
37
}
43
38
@@ -48,7 +43,6 @@ tsickle flags are:
48
43
function loadSettingsFromArgs ( args : string [ ] ) : { settings: Settings , tscArgs : string [ ] } {
49
44
let settings : Settings = {
50
45
saveTemporaries : null ,
51
- outputPath : null ,
52
46
} ;
53
47
let parsedArgs = minimist ( args ) ;
54
48
for ( let flag of Object . keys ( parsedArgs ) ) {
@@ -64,9 +58,6 @@ function loadSettingsFromArgs(args: string[]): {settings: Settings, tscArgs: str
64
58
case 'externs' :
65
59
settings . externsPath = parsedArgs [ flag ] ;
66
60
break ;
67
- case 'output' :
68
- settings . outputPath = parsedArgs [ flag ] ;
69
- break ;
70
61
case '_' :
71
62
// This is part of the minimist API, and holds args after the '--'.
72
63
break ;
@@ -76,8 +67,8 @@ function loadSettingsFromArgs(args: string[]): {settings: Settings, tscArgs: str
76
67
process . exit ( 1 ) ;
77
68
}
78
69
}
79
- if ( ! settings . outputPath && ! settings . externsPath ) {
80
- console . error ( 'must specify --output or -- externs path' ) ;
70
+ if ( ! settings . externsPath ) {
71
+ console . error ( 'must specify --externs path' ) ;
81
72
usage ( ) ;
82
73
process . exit ( 1 ) ;
83
74
}
@@ -220,32 +211,6 @@ function toClosureJS(options: ts.CompilerOptions, fileNames: string[]):
220
211
return { jsFiles} ;
221
212
}
222
213
223
- function closureCompile (
224
- jsFiles : { [ fileName : string ] : string } , outFile : string ,
225
- callback : ( exitCode : number , output : string ) => void ) : void {
226
- const closureOptions : closure . CompileOptions = {
227
- // Read input files from stdin as JSON.
228
- 'json_streams' : 'IN' ,
229
- // Write output file to disk.
230
- 'js_output_file' : outFile ,
231
- 'warning_level' : 'VERBOSE' ,
232
- 'language_in' : 'ECMASCRIPT6_STRICT' ,
233
- 'compilation_level' : 'ADVANCED_OPTIMIZATIONS' ,
234
- } ;
235
-
236
- let compiler = new closure . compiler ( closureOptions ) ;
237
- let process = compiler . run ( ( exitCode , stdout , stderr ) => { callback ( exitCode , stderr ) ; } ) ;
238
-
239
- let jsonInput : closure . JSONStreamFile [ ] = [ ] ;
240
- for ( let fileName of Object . keys ( jsFiles ) ) {
241
- jsonInput . push ( {
242
- path : fileName ,
243
- src : jsFiles [ fileName ] ,
244
- } ) ;
245
- }
246
- process . stdin . end ( JSON . stringify ( jsonInput ) ) ;
247
- }
248
-
249
214
function main ( args : string [ ] ) {
250
215
let { settings , tscArgs } = loadSettingsFromArgs ( args ) ;
251
216
let { options , fileNames , errors } = loadTscConfig ( tscArgs ) ;
@@ -275,14 +240,6 @@ function main(args: string[]) {
275
240
if ( settings . externsPath ) {
276
241
fs . writeFileSync ( settings . externsPath , jsFiles [ internalExternsFileName ] ) ;
277
242
}
278
-
279
- if ( settings . outputPath ) {
280
- // Run Closure compiiler to convert JS files to output bundle.
281
- closureCompile ( jsFiles , settings . outputPath , ( exitCode , output ) => {
282
- if ( output ) console . error ( output ) ;
283
- process . exit ( exitCode ) ;
284
- } ) ;
285
- }
286
243
}
287
244
288
245
// CLI entry point
0 commit comments