@@ -19,7 +19,8 @@ const copyright = "CopyrightNotice.txt";
19
19
const cleanTasks = [ ] ;
20
20
21
21
22
- // TODO(jakebailey): This is really gross. Waiting on: https://github.com/microsoft/TypeScript/issues/25613
22
+ // TODO(jakebailey): This is really gross. Waiting on https://github.com/microsoft/TypeScript/issues/25613,
23
+ // or at least control over noEmit / emitDeclarationOnly in build mode.
23
24
let currentlyBuilding = 0 ;
24
25
let oldTsconfigBase ;
25
26
@@ -166,18 +167,16 @@ function esbuildTask(entrypoint, outfile, exportIsTsObject = false, performanceM
166
167
bundle : true ,
167
168
outfile : performanceMatters ? preBabel : outfile ,
168
169
platform : "node" ,
169
- // TODO: also specify minimal browser targets
170
- target : "node10" , // Node 10 is the oldest benchmarker.
170
+ target : "es2018" , // This covers Node 10.
171
171
format : "cjs" ,
172
172
sourcemap : true ,
173
- external : [ "./node_modules/*" ] , // TODO(jakebailey): does the test runner import relatively from scripts?
173
+ external : [ "./node_modules/*" ] ,
174
174
conditions : [ "require" ] ,
175
175
supported : {
176
- // "const-and-let": false, // Unfortunately, no: https://github.com/evanw/esbuild/issues/297
177
- "object-rest-spread" : false , // See : https://github.com/evanw/esbuild/releases/tag/v0.14.46
176
+ // "const-and-let": false, // https://github.com/evanw/esbuild/issues/297
177
+ "object-rest-spread" : false , // Performance enhancement, see : https://github.com/evanw/esbuild/releases/tag/v0.14.46
178
178
} ,
179
- // legalComments: "none", // TODO(jakebailey): enable once we add copyright headers to our source files.
180
- // logLevel: "info",
179
+ // legalComments: "none", // If we add copyright headers to the source files, uncomment.
181
180
} ;
182
181
183
182
if ( exportIsTsObject ) {
@@ -237,11 +236,12 @@ const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnost
237
236
238
237
239
238
const esbuildTsc = esbuildTask ( "./src/tsc/tsc.ts" , "./built/local/tsc.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
239
+ const writeTscCJSShim = ( ) => writeCJSReexport ( "./built/local/tsc/tsc.js" , "./built/local/tsc.js" ) ;
240
240
241
241
242
242
const buildTsc = ( ) => {
243
243
if ( cmdLineOptions . bundle ) return esbuildTsc . build ( ) ;
244
- writeCJSReexport ( "./built/local/tsc/tsc.js" , "./built/local/tsc.js" ) ;
244
+ writeTscCJSShim ( ) ;
245
245
return buildProject ( "src/tsc" ) ;
246
246
} ;
247
247
task ( "tsc" , series ( lkgPreBuild , buildTsc ) ) ;
@@ -252,8 +252,11 @@ cleanTasks.push(cleanTsc);
252
252
task ( "clean-tsc" , cleanTsc ) ;
253
253
task ( "clean-tsc" ) . description = "Cleans outputs for the command-line compiler" ;
254
254
255
- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
256
- const watchTsc = ( ) => cmdLineOptions . bundle ? esbuildTsc . watch ( ) : watchProject ( "src/tsc" ) ;
255
+ const watchTsc = ( ) => {
256
+ if ( cmdLineOptions . bundle ) return esbuildTsc . watch ( ) ;
257
+ writeTscCJSShim ( ) ;
258
+ return watchProject ( "src/tsc" ) ;
259
+ } ;
257
260
task ( "watch-tsc" , series ( lkgPreBuild , parallel ( watchLib , watchDiagnostics , watchTsc ) ) ) ;
258
261
task ( "watch-tsc" ) . description = "Watch for changes and rebuild the command-line compiler only." ;
259
262
@@ -263,15 +266,15 @@ const localPreBuild = parallel(generateLibs, series(buildScripts, generateDiagno
263
266
// Pre-build steps to use based on supplied options.
264
267
const preBuild = cmdLineOptions . lkg ? lkgPreBuild : localPreBuild ;
265
268
266
- const esbuildServices = esbuildTask ( "./src/typescript/typescript.ts" , "./built/local/typescript.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
267
-
268
269
// TODO(jakebailey): rename this; no longer "services".
269
270
271
+ const esbuildServices = esbuildTask ( "./src/typescript/typescript.ts" , "./built/local/typescript.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
272
+ const writeServicesCJSShim = ( ) => writeCJSReexport ( "./built/local/typescript/typescript.js" , "./built/local/typescript.js" ) ;
270
273
const buildServicesProject = ( ) => buildProject ( "src/typescript" ) ;
271
274
272
275
const buildServices = ( ) => {
273
276
if ( cmdLineOptions . bundle ) return esbuildServices . build ( ) ;
274
- writeCJSReexport ( "./built/local/typescript/typescript.js" , "./built/local/typescript.js" ) ;
277
+ writeServicesCJSShim ( ) ;
275
278
return buildServicesProject ( ) ;
276
279
} ;
277
280
@@ -287,8 +290,11 @@ cleanTasks.push(cleanServices);
287
290
task ( "clean-services" , cleanServices ) ;
288
291
task ( "clean-services" ) . description = "Cleans outputs for the language service" ;
289
292
290
- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
291
- const watchServices = ( ) => cmdLineOptions . bundle ? esbuildServices . watch ( ) : watchProject ( "src/typescript" ) ;
293
+ const watchServices = ( ) => {
294
+ if ( cmdLineOptions . bundle ) return esbuildServices . watch ( ) ;
295
+ writeServicesCJSShim ( ) ;
296
+ return watchProject ( "src/typescript" ) ;
297
+ } ;
292
298
task ( "watch-services" , series ( preBuild , parallel ( watchLib , watchDiagnostics , watchServices ) ) ) ;
293
299
task ( "watch-services" ) . description = "Watches for changes and rebuild language service only" ;
294
300
task ( "watch-services" ) . flags = {
@@ -300,10 +306,11 @@ task("dts-services", series(preBuild, buildServicesProject, dtsServices));
300
306
task ( "dts-services" ) . description = "Builds typescript.d.ts" ;
301
307
302
308
const esbuildServer = esbuildTask ( "./src/tsserver/server.ts" , "./built/local/tsserver.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
309
+ const writeServerCJSShim = ( ) => writeCJSReexport ( "./built/local/tsserver/server.js" , "./built/local/tsserver.js" ) ;
303
310
304
311
const buildServer = ( ) => {
305
312
if ( cmdLineOptions . bundle ) return esbuildServer . build ( ) ;
306
- writeCJSReexport ( "./built/local/tsserver/server.js" , "./built/local/tsserver.js" ) ;
313
+ writeServerCJSShim ( ) ;
307
314
return buildProject ( "src/tsserver" ) ;
308
315
} ;
309
316
buildServer . displayName = "buildServer" ;
@@ -319,8 +326,11 @@ cleanTasks.push(cleanServer);
319
326
task ( "clean-tsserver" , cleanServer ) ;
320
327
task ( "clean-tsserver" ) . description = "Cleans outputs for the language server" ;
321
328
322
- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
323
- const watchServer = ( ) => cmdLineOptions . bundle ? esbuildServer . watch ( ) : watchProject ( "src/tsserver" ) ;
329
+ const watchServer = ( ) => {
330
+ if ( cmdLineOptions . bundle ) return esbuildServer . watch ( ) ;
331
+ writeServerCJSShim ( ) ;
332
+ return watchProject ( "src/tsserver" ) ;
333
+ } ;
324
334
task ( "watch-tsserver" , series ( preBuild , parallel ( watchLib , watchDiagnostics , watchServer ) ) ) ;
325
335
task ( "watch-tsserver" ) . description = "Watch for changes and rebuild the language server only" ;
326
336
task ( "watch-tsserver" ) . flags = {
@@ -343,11 +353,12 @@ task("watch-min").flags = {
343
353
} ;
344
354
345
355
const esbuildLssl = esbuildTask ( "./src/tsserverlibrary/tsserverlibrary.ts" , "./built/local/tsserverlibrary.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
356
+ const writeLsslCJSShim = ( ) => writeCJSReexport ( "./built/local/tsserverlibrary/tsserverlibrary.js" , "./built/local/tsserverlibrary.js" ) ;
346
357
347
358
const buildLsslProject = ( ) => buildProject ( "src/tsserverlibrary" ) ;
348
359
const buildLssl = ( ) => {
349
360
if ( cmdLineOptions . bundle ) return esbuildLssl . build ( ) ;
350
- writeCJSReexport ( "./built/local/tsserverlibrary/tsserverlibrary.js" , "./built/local/tsserverlibrary.js" ) ;
361
+ writeLsslCJSShim ( ) ;
351
362
return buildLsslProject ( ) ;
352
363
} ;
353
364
task ( "lssl" , series ( preBuild , buildLssl ) ) ;
@@ -361,9 +372,11 @@ cleanTasks.push(cleanLssl);
361
372
task ( "clean-lssl" , cleanLssl ) ;
362
373
task ( "clean-lssl" ) . description = "Clean outputs for the language service server library" ;
363
374
364
- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
365
- const watchLssl = ( ) => cmdLineOptions . bundle ? esbuildLssl . watch ( ) : watchProject ( "src/tsserverlibrary" ) ;
366
-
375
+ const watchLssl = ( ) => {
376
+ if ( cmdLineOptions . bundle ) return esbuildLssl . watch ( ) ;
377
+ writeLsslCJSShim ( ) ;
378
+ return watchProject ( "src/tsserverlibrary" ) ;
379
+ } ;
367
380
task ( "watch-lssl" , series ( preBuild , parallel ( watchLib , watchDiagnostics , watchLssl ) ) ) ;
368
381
task ( "watch-lssl" ) . description = "Watch for changes and rebuild tsserverlibrary only" ;
369
382
task ( "watch-lssl" ) . flags = {
@@ -380,10 +393,11 @@ task("dts", dts);
380
393
381
394
const testRunner = "./built/local/run.js" ;
382
395
const esbuildTests = esbuildTask ( "./src/testRunner/_namespaces/Harness.ts" , testRunner ) ;
396
+ const writeTestsCJSShim = ( ) => writeCJSReexport ( "./built/local/testRunner/runner.js" , testRunner ) ;
383
397
384
398
const buildTests = ( ) => {
385
399
if ( cmdLineOptions . bundle ) return esbuildTests . build ( ) ;
386
- writeCJSReexport ( "./built/local/testRunner/runner.js" , testRunner ) ;
400
+ writeTestsCJSShim ( ) ;
387
401
return buildProject ( "src/testRunner" ) ;
388
402
} ;
389
403
task ( "tests" , series ( preBuild , parallel ( buildLssl , buildTests ) ) ) ;
@@ -397,8 +411,11 @@ cleanTasks.push(cleanTests);
397
411
task ( "clean-tests" , cleanTests ) ;
398
412
task ( "clean-tests" ) . description = "Cleans the outputs for the test infrastructure" ;
399
413
400
- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
401
- const watchTests = ( ) => cmdLineOptions . bundle ? esbuildTests . watch ( ) : watchProject ( "src/testRunner" ) ;
414
+ const watchTests = ( ) => {
415
+ if ( cmdLineOptions . bundle ) return esbuildTests . watch ( ) ;
416
+ writeTestsCJSShim ( ) ;
417
+ return watchProject ( "src/testRunner" ) ;
418
+ } ;
402
419
403
420
const buildEslintRules = ( ) => buildProject ( "scripts/eslint" ) ;
404
421
task ( "build-eslint-rules" , buildEslintRules ) ;
@@ -450,7 +467,6 @@ const esbuildTypingsInstaller = esbuildTask("./src/typingsInstaller/nodeTypingsI
450
467
451
468
const buildTypingsInstaller = ( ) => {
452
469
if ( cmdLineOptions . bundle ) return esbuildTypingsInstaller . build ( ) ;
453
- // TODO(jakebailey): In --bundle=false, can we emit to this directly?
454
470
writeCJSReexport ( "./built/typingsInstaller/nodeTypingsInstaller.js" , "./built/local/typingsInstaller.js" ) ;
455
471
return buildProject ( "src/typingsInstaller" ) ;
456
472
} ;
@@ -584,16 +600,19 @@ task("importDefinitelyTypedTests").description = "Runs the importDefinitelyTyped
584
600
const cleanBuilt = ( ) => del ( "built" ) ;
585
601
586
602
const produceLKG = async ( ) => {
587
- // TODO(jakebailey): there are probably more files here that are needed.
603
+ if ( ! cmdLineOptions . bundle ) {
604
+ throw new Error ( "LKG cannot be created when --bundle=false" ) ;
605
+ }
606
+
588
607
const expectedFiles = [
608
+ "built/local/cancellationToken.js" ,
589
609
"built/local/tsc.js" ,
590
610
"built/local/tsserver.js" ,
591
- "built/local/typescript.js" ,
592
- "built/local/typescript.d.ts" ,
593
611
"built/local/tsserverlibrary.js" ,
594
612
"built/local/tsserverlibrary.d.ts" ,
613
+ "built/local/typescript.js" ,
614
+ "built/local/typescript.d.ts" ,
595
615
"built/local/typingsInstaller.js" ,
596
- "built/local/cancellationToken.js" ,
597
616
"built/local/watchGuard.js" ,
598
617
] . concat ( libs . map ( lib => lib . target ) ) ;
599
618
const missingFiles = expectedFiles
@@ -624,8 +643,6 @@ task("generate-spec").description = "Generates a Markdown version of the Languag
624
643
task ( "clean" , series ( parallel ( cleanTasks ) , cleanBuilt ) ) ;
625
644
task ( "clean" ) . description = "Cleans build outputs" ;
626
645
627
- // TODO(jakebailey): Figure out what needs to change below.
628
-
629
646
const configureNightly = ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.js" , "dev" , "package.json" , "src/compiler/corePublic.ts" ] ) ;
630
647
task ( "configure-nightly" , series ( buildScripts , configureNightly ) ) ;
631
648
task ( "configure-nightly" ) . description = "Runs scripts/configurePrerelease.ts to prepare a build for nightly publishing" ;
0 commit comments