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