@@ -127,6 +127,22 @@ const buildSrc = () => buildProject("src");
127
127
// But, if we are bundling, we are running only d.ts emit, so maybe this is fast?
128
128
task ( "build-src" , series ( preSrc , buildSrc ) ) ;
129
129
130
+ /**
131
+ * @param {string } entrypoint
132
+ * @param {string } output
133
+ */
134
+ async function runDtsBundler ( entrypoint , output ) {
135
+ // Want to preserve @internal ? Pass `--stripInternal=false` when running the dts task.
136
+ await exec ( process . execPath , [
137
+ "./scripts/dtsBundler.js" ,
138
+ "--entrypoint" ,
139
+ entrypoint ,
140
+ "--output" ,
141
+ output ,
142
+ `--stripInternal=${ cmdLineOptions . stripInternal } ` ,
143
+ ] ) ;
144
+ }
145
+
130
146
/** @type {string | undefined } */
131
147
let copyrightHeader ;
132
148
function getCopyrightHeader ( ) {
@@ -143,6 +159,7 @@ function getCopyrightHeader() {
143
159
* @param {boolean } performanceMatters True if this is a bundle where performance matters, so should be optimized at the cost of build time.
144
160
*/
145
161
function esbuildTask ( entrypoint , outfile , exportIsTsObject = false , performanceMatters = false ) {
162
+ performanceMatters = false ;
146
163
const preBabel = `${ outfile } .tmp.js` ;
147
164
148
165
/** @type {esbuild.BuildOptions } */
@@ -251,10 +268,13 @@ const preBuild = cmdLineOptions.lkg ? lkgPreBuild : localPreBuild;
251
268
const esbuildServices = esbuildTask ( "./src/typescript/typescript.ts" , "./built/local/typescript.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
252
269
253
270
// TODO(jakebailey): rename this; no longer "services".
271
+
272
+ const buildServicesProject = ( ) => buildProject ( "src/typescript" ) ;
273
+
254
274
const buildServices = ( ) => {
255
275
if ( cmdLineOptions . bundle ) return esbuildServices . build ( ) ;
256
276
writeCJSReexport ( "./built/local/typescript/typescript.js" , "./built/local/typescript.js" ) ;
257
- return buildProject ( "src/typescript" ) ;
277
+ return buildServicesProject ( ) ;
258
278
} ;
259
279
260
280
task ( "services" , series ( preBuild , buildServices ) ) ;
@@ -277,6 +297,9 @@ task("watch-services").flags = {
277
297
" --built" : "Compile using the built version of the compiler."
278
298
} ;
279
299
300
+ const dtsServices = ( ) => runDtsBundler ( "./built/local/typescript/typescript.d.ts" , "./built/local/typescript.d.ts" ) ;
301
+ task ( "dts-services" , series ( preBuild , buildServicesProject , dtsServices ) ) ;
302
+ task ( "dts-services" ) . description = "Builds typescript.d.ts" ;
280
303
281
304
const esbuildServer = esbuildTask ( "./src/tsserver/server.ts" , "./built/local/tsserver.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
282
305
@@ -323,10 +346,11 @@ task("watch-min").flags = {
323
346
324
347
const esbuildLssl = esbuildTask ( "./src/tsserverlibrary/tsserverlibrary.ts" , "./built/local/tsserverlibrary.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
325
348
349
+ const buildLsslProject = ( ) => buildProject ( "src/tsserverlibrary" ) ;
326
350
const buildLssl = ( ) => {
327
351
if ( cmdLineOptions . bundle ) return esbuildLssl . build ( ) ;
328
352
writeCJSReexport ( "./built/local/tsserverlibrary/tsserverlibrary.js" , "./built/local/tsserverlibrary.js" ) ;
329
- return buildProject ( "src/tsserverlibrary" ) ;
353
+ return buildLsslProject ( ) ;
330
354
} ;
331
355
task ( "lssl" , series ( preBuild , buildLssl ) ) ;
332
356
task ( "lssl" ) . description = "Builds language service server library" ;
@@ -348,6 +372,14 @@ task("watch-lssl").flags = {
348
372
" --built" : "Compile using the built version of the compiler."
349
373
} ;
350
374
375
+ const dtsLssl = ( ) => runDtsBundler ( "./built/local/tsserverlibrary/tsserverlibrary.d.ts" , "./built/local/tsserverlibrary.d.ts" ) ;
376
+ task ( "dts-lssl" , series ( preBuild , buildLsslProject , dtsLssl ) ) ;
377
+ task ( "dts-lssl" ) . description = "Builds tsserverlibrary.d.ts" ;
378
+
379
+ // TODO(jakebailey): this is probably not efficient, but, gulp.
380
+ const dts = series ( preBuild , parallel ( buildServicesProject , buildLsslProject ) , parallel ( dtsServices , dtsLssl ) ) ;
381
+ task ( "dts" , dts ) ;
382
+
351
383
const testRunner = "./built/local/run.js" ;
352
384
const esbuildTests = esbuildTask ( "./src/testRunner/_namespaces/Harness.ts" , testRunner ) ;
353
385
@@ -458,7 +490,7 @@ const buildOtherOutputs = parallel(buildCancellationToken, buildTypingsInstaller
458
490
task ( "other-outputs" , series ( preBuild , buildOtherOutputs ) ) ;
459
491
task ( "other-outputs" ) . description = "Builds miscelaneous scripts and documents distributed with the LKG" ;
460
492
461
- task ( "local" , series ( preBuild , parallel ( localize , buildTsc , buildServer , buildServices , buildLssl , buildOtherOutputs ) ) ) ;
493
+ task ( "local" , series ( preBuild , parallel ( localize , buildTsc , buildServer , buildServices , buildLssl , buildOtherOutputs , dts ) ) ) ;
462
494
task ( "local" ) . description = "Builds the full compiler and services" ;
463
495
task ( "local" ) . flags = {
464
496
" --built" : "Compile using the built version of the compiler."
@@ -474,7 +506,7 @@ const preTest = parallel(buildTsc, buildTests, buildServices, buildLssl);
474
506
preTest . displayName = "preTest" ;
475
507
476
508
const runTests = ( ) => runConsoleTests ( testRunner , "mocha-fivemat-progress-reporter" , /*runInParallel*/ false , /*watchMode*/ false ) ;
477
- task ( "runtests" , series ( preBuild , preTest , runTests ) ) ;
509
+ task ( "runtests" , series ( preBuild , preTest , dts , runTests ) ) ;
478
510
task ( "runtests" ) . description = "Runs the tests using the built run.js file." ;
479
511
task ( "runtests" ) . flags = {
480
512
"-t --tests=<regex>" : "Pattern for tests to run." ,
@@ -493,7 +525,7 @@ task("runtests").flags = {
493
525
} ;
494
526
495
527
const runTestsParallel = ( ) => runConsoleTests ( testRunner , "min" , /*runInParallel*/ cmdLineOptions . workers > 1 , /*watchMode*/ false ) ;
496
- task ( "runtests-parallel" , series ( preBuild , preTest , runTestsParallel ) ) ;
528
+ task ( "runtests-parallel" , series ( preBuild , preTest , dts , runTestsParallel ) ) ;
497
529
task ( "runtests-parallel" ) . description = "Runs all the tests in parallel using the built run.js file." ;
498
530
task ( "runtests-parallel" ) . flags = {
499
531
" --light" : "Run tests in light mode (fewer verifications, but tests run faster)." ,
@@ -597,8 +629,7 @@ const produceLKG = async () => {
597
629
}
598
630
} ;
599
631
600
- // TODO(jakebailey): dependencies on dts
601
- task ( "LKG" , series ( lkgPreBuild , parallel ( localize , buildTsc , buildServer , buildServices , buildLssl , buildOtherOutputs ) , produceLKG ) ) ;
632
+ task ( "LKG" , series ( lkgPreBuild , parallel ( localize , buildTsc , buildServer , buildServices , buildLssl , buildOtherOutputs , dts ) , produceLKG ) ) ;
602
633
task ( "LKG" ) . description = "Makes a new LKG out of the built js files" ;
603
634
task ( "LKG" ) . flags = {
604
635
" --built" : "Compile using the built version of the compiler." ,
0 commit comments