@@ -171,8 +171,8 @@ function esbuildTask(entrypoint, outfile, exportIsTsObject = false, performanceM
171
171
external : [ "./node_modules/*" ] ,
172
172
conditions : [ "require" ] ,
173
173
supported : {
174
- // "const-and-let": false, // Unfortunately, no: https://github.com/evanw/esbuild/issues/297
175
- "object-rest-spread" : false , // See : https://github.com/evanw/esbuild/releases/tag/v0.14.46
174
+ // "const-and-let": false, // https://github.com/evanw/esbuild/issues/297
175
+ "object-rest-spread" : false , // Performance enhancement, see : https://github.com/evanw/esbuild/releases/tag/v0.14.46
176
176
} ,
177
177
// legalComments: "none", // If we add copyright headers to the source files, uncomment.
178
178
} ;
@@ -252,11 +252,12 @@ const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnost
252
252
253
253
254
254
const esbuildTsc = esbuildTask ( "./src/tsc/tsc.ts" , "./built/local/tsc.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
255
+ const writeTscCJSShim = ( ) => writeCJSReexport ( "./built/local/tsc/tsc.js" , "./built/local/tsc.js" ) ;
255
256
256
257
257
258
const buildTsc = ( ) => {
258
259
if ( cmdLineOptions . bundle ) return esbuildTsc . build ( ) ;
259
- writeCJSReexport ( "./built/local/tsc/tsc.js" , "./built/local/tsc.js" ) ;
260
+ writeTscCJSShim ( ) ;
260
261
return buildProject ( "src/tsc" ) ;
261
262
} ;
262
263
task ( "tsc" , series ( lkgPreBuild , buildTsc ) ) ;
@@ -267,8 +268,11 @@ cleanTasks.push(cleanTsc);
267
268
task ( "clean-tsc" , cleanTsc ) ;
268
269
task ( "clean-tsc" ) . description = "Cleans outputs for the command-line compiler" ;
269
270
270
- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
271
- const watchTsc = ( ) => cmdLineOptions . bundle ? esbuildTsc . watch ( ) : watchProject ( "src/tsc" ) ;
271
+ const watchTsc = ( ) => {
272
+ if ( cmdLineOptions . bundle ) return esbuildTsc . watch ( ) ;
273
+ writeTscCJSShim ( ) ;
274
+ return watchProject ( "src/tsc" ) ;
275
+ } ;
272
276
task ( "watch-tsc" , series ( lkgPreBuild , parallel ( watchLib , watchDiagnostics , watchTsc ) ) ) ;
273
277
task ( "watch-tsc" ) . description = "Watch for changes and rebuild the command-line compiler only." ;
274
278
@@ -278,15 +282,15 @@ const localPreBuild = parallel(generateLibs, series(buildScripts, generateDiagno
278
282
// Pre-build steps to use based on supplied options.
279
283
const preBuild = cmdLineOptions . lkg ? lkgPreBuild : localPreBuild ;
280
284
281
- const esbuildServices = esbuildTask ( "./src/typescript/typescript.ts" , "./built/local/typescript.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
282
-
283
285
// TODO(jakebailey): rename this; no longer "services".
284
286
287
+ const esbuildServices = esbuildTask ( "./src/typescript/typescript.ts" , "./built/local/typescript.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
288
+ const writeServicesCJSShim = ( ) => writeCJSReexport ( "./built/local/typescript/typescript.js" , "./built/local/typescript.js" ) ;
285
289
const buildServicesProject = ( ) => buildProject ( "src/typescript" ) ;
286
290
287
291
const buildServices = ( ) => {
288
292
if ( cmdLineOptions . bundle ) return esbuildServices . build ( ) ;
289
- writeCJSReexport ( "./built/local/typescript/typescript.js" , "./built/local/typescript.js" ) ;
293
+ writeServicesCJSShim ( ) ;
290
294
return buildServicesProject ( ) ;
291
295
} ;
292
296
@@ -302,8 +306,11 @@ cleanTasks.push(cleanServices);
302
306
task ( "clean-services" , cleanServices ) ;
303
307
task ( "clean-services" ) . description = "Cleans outputs for the language service" ;
304
308
305
- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
306
- const watchServices = ( ) => cmdLineOptions . bundle ? esbuildServices . watch ( ) : watchProject ( "src/typescript" ) ;
309
+ const watchServices = ( ) => {
310
+ if ( cmdLineOptions . bundle ) return esbuildServices . watch ( ) ;
311
+ writeServicesCJSShim ( ) ;
312
+ return watchProject ( "src/typescript" ) ;
313
+ } ;
307
314
task ( "watch-services" , series ( preBuild , parallel ( watchLib , watchDiagnostics , watchServices ) ) ) ;
308
315
task ( "watch-services" ) . description = "Watches for changes and rebuild language service only" ;
309
316
task ( "watch-services" ) . flags = {
@@ -315,10 +322,11 @@ task("dts-services", series(preBuild, buildServicesProject, dtsServices));
315
322
task ( "dts-services" ) . description = "Builds typescript.d.ts" ;
316
323
317
324
const esbuildServer = esbuildTask ( "./src/tsserver/server.ts" , "./built/local/tsserver.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
325
+ const writeServerCJSShim = ( ) => writeCJSReexport ( "./built/local/tsserver/server.js" , "./built/local/tsserver.js" ) ;
318
326
319
327
const buildServer = ( ) => {
320
328
if ( cmdLineOptions . bundle ) return esbuildServer . build ( ) ;
321
- writeCJSReexport ( "./built/local/tsserver/server.js" , "./built/local/tsserver.js" ) ;
329
+ writeServerCJSShim ( ) ;
322
330
return buildProject ( "src/tsserver" ) ;
323
331
} ;
324
332
buildServer . displayName = "buildServer" ;
@@ -334,8 +342,11 @@ cleanTasks.push(cleanServer);
334
342
task ( "clean-tsserver" , cleanServer ) ;
335
343
task ( "clean-tsserver" ) . description = "Cleans outputs for the language server" ;
336
344
337
- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
338
- const watchServer = ( ) => cmdLineOptions . bundle ? esbuildServer . watch ( ) : watchProject ( "src/tsserver" ) ;
345
+ const watchServer = ( ) => {
346
+ if ( cmdLineOptions . bundle ) return esbuildServer . watch ( ) ;
347
+ writeServerCJSShim ( ) ;
348
+ return watchProject ( "src/tsserver" ) ;
349
+ } ;
339
350
task ( "watch-tsserver" , series ( preBuild , parallel ( watchLib , watchDiagnostics , watchServer ) ) ) ;
340
351
task ( "watch-tsserver" ) . description = "Watch for changes and rebuild the language server only" ;
341
352
task ( "watch-tsserver" ) . flags = {
@@ -358,11 +369,12 @@ task("watch-min").flags = {
358
369
} ;
359
370
360
371
const esbuildLssl = esbuildTask ( "./src/tsserverlibrary/tsserverlibrary.ts" , "./built/local/tsserverlibrary.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
372
+ const writeLsslCJSShim = ( ) => writeCJSReexport ( "./built/local/tsserverlibrary/tsserverlibrary.js" , "./built/local/tsserverlibrary.js" ) ;
361
373
362
374
const buildLsslProject = ( ) => buildProject ( "src/tsserverlibrary" ) ;
363
375
const buildLssl = ( ) => {
364
376
if ( cmdLineOptions . bundle ) return esbuildLssl . build ( ) ;
365
- writeCJSReexport ( "./built/local/tsserverlibrary/tsserverlibrary.js" , "./built/local/tsserverlibrary.js" ) ;
377
+ writeLsslCJSShim ( ) ;
366
378
return buildLsslProject ( ) ;
367
379
} ;
368
380
task ( "lssl" , series ( preBuild , buildLssl ) ) ;
@@ -376,9 +388,11 @@ cleanTasks.push(cleanLssl);
376
388
task ( "clean-lssl" , cleanLssl ) ;
377
389
task ( "clean-lssl" ) . description = "Clean outputs for the language service server library" ;
378
390
379
- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
380
- const watchLssl = ( ) => cmdLineOptions . bundle ? esbuildLssl . watch ( ) : watchProject ( "src/tsserverlibrary" ) ;
381
-
391
+ const watchLssl = ( ) => {
392
+ if ( cmdLineOptions . bundle ) return esbuildLssl . watch ( ) ;
393
+ writeLsslCJSShim ( ) ;
394
+ return watchProject ( "src/tsserverlibrary" ) ;
395
+ } ;
382
396
task ( "watch-lssl" , series ( preBuild , parallel ( watchLib , watchDiagnostics , watchLssl ) ) ) ;
383
397
task ( "watch-lssl" ) . description = "Watch for changes and rebuild tsserverlibrary only" ;
384
398
task ( "watch-lssl" ) . flags = {
@@ -395,10 +409,11 @@ task("dts", dts);
395
409
396
410
const testRunner = "./built/local/run.js" ;
397
411
const esbuildTests = esbuildTask ( "./src/testRunner/_namespaces/Harness.ts" , testRunner ) ;
412
+ const writeTestsCJSShim = ( ) => writeCJSReexport ( "./built/local/testRunner/runner.js" , testRunner ) ;
398
413
399
414
const buildTests = ( ) => {
400
415
if ( cmdLineOptions . bundle ) return esbuildTests . build ( ) ;
401
- writeCJSReexport ( "./built/local/testRunner/runner.js" , testRunner ) ;
416
+ writeTestsCJSShim ( ) ;
402
417
return buildProject ( "src/testRunner" ) ;
403
418
} ;
404
419
task ( "tests" , series ( preBuild , parallel ( buildLssl , buildTests ) ) ) ;
@@ -412,8 +427,11 @@ cleanTasks.push(cleanTests);
412
427
task ( "clean-tests" , cleanTests ) ;
413
428
task ( "clean-tests" ) . description = "Cleans the outputs for the test infrastructure" ;
414
429
415
- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
416
- const watchTests = ( ) => cmdLineOptions . bundle ? esbuildTests . watch ( ) : watchProject ( "src/testRunner" ) ;
430
+ const watchTests = ( ) => {
431
+ if ( cmdLineOptions . bundle ) return esbuildTests . watch ( ) ;
432
+ writeTestsCJSShim ( ) ;
433
+ return watchProject ( "src/testRunner" ) ;
434
+ } ;
417
435
418
436
const buildEslintRules = ( ) => buildProject ( "scripts/eslint" ) ;
419
437
task ( "build-eslint-rules" , buildEslintRules ) ;
@@ -465,7 +483,6 @@ const esbuildTypingsInstaller = esbuildTask("./src/typingsInstaller/nodeTypingsI
465
483
466
484
const buildTypingsInstaller = ( ) => {
467
485
if ( cmdLineOptions . bundle ) return esbuildTypingsInstaller . build ( ) ;
468
- // TODO(jakebailey): In --bundle=false, can we emit to this directly?
469
486
writeCJSReexport ( "./built/typingsInstaller/nodeTypingsInstaller.js" , "./built/local/typingsInstaller.js" ) ;
470
487
return buildProject ( "src/typingsInstaller" ) ;
471
488
} ;
@@ -599,16 +616,19 @@ task("importDefinitelyTypedTests").description = "Runs the importDefinitelyTyped
599
616
const cleanBuilt = ( ) => del ( "built" ) ;
600
617
601
618
const produceLKG = async ( ) => {
602
- // TODO(jakebailey): there are probably more files here that are needed.
619
+ if ( ! cmdLineOptions . bundle ) {
620
+ throw new Error ( "LKG cannot be created when --bundle=false" ) ;
621
+ }
622
+
603
623
const expectedFiles = [
624
+ "built/local/cancellationToken.js" ,
604
625
"built/local/tsc.js" ,
605
626
"built/local/tsserver.js" ,
606
- "built/local/typescript.js" ,
607
- "built/local/typescript.d.ts" ,
608
627
"built/local/tsserverlibrary.js" ,
609
628
"built/local/tsserverlibrary.d.ts" ,
629
+ "built/local/typescript.js" ,
630
+ "built/local/typescript.d.ts" ,
610
631
"built/local/typingsInstaller.js" ,
611
- "built/local/cancellationToken.js" ,
612
632
"built/local/watchGuard.js" ,
613
633
] . concat ( libs . map ( lib => lib . target ) ) ;
614
634
const missingFiles = expectedFiles
@@ -639,8 +659,6 @@ task("generate-spec").description = "Generates a Markdown version of the Languag
639
659
task ( "clean" , series ( parallel ( cleanTasks ) , cleanBuilt ) ) ;
640
660
task ( "clean" ) . description = "Cleans build outputs" ;
641
661
642
- // TODO(jakebailey): Figure out what needs to change below.
643
-
644
662
const configureNightly = ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.js" , "dev" , "package.json" , "src/compiler/corePublic.ts" ] ) ;
645
663
task ( "configure-nightly" , series ( buildScripts , configureNightly ) ) ;
646
664
task ( "configure-nightly" ) . description = "Runs scripts/configurePrerelease.ts to prepare a build for nightly publishing" ;
0 commit comments