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