@@ -127,6 +127,22 @@ const buildSrc = () => buildProject("src");
127127// But, if we are bundling, we are running only d.ts emit, so maybe this is fast?
128128task ( "build-src" , series ( preSrc , buildSrc ) ) ;
129129
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+
130146/** @type {string | undefined } */
131147let copyrightHeader ;
132148function getCopyrightHeader ( ) {
@@ -143,6 +159,7 @@ function getCopyrightHeader() {
143159 * @param {boolean } performanceMatters True if this is a bundle where performance matters, so should be optimized at the cost of build time.
144160 */
145161function esbuildTask ( entrypoint , outfile , exportIsTsObject = false , performanceMatters = false ) {
162+ performanceMatters = false ;
146163 const preBabel = `${ outfile } .tmp.js` ;
147164
148165 /** @type {esbuild.BuildOptions } */
@@ -251,10 +268,13 @@ const preBuild = cmdLineOptions.lkg ? lkgPreBuild : localPreBuild;
251268const esbuildServices = esbuildTask ( "./src/typescript/typescript.ts" , "./built/local/typescript.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
252269
253270// TODO(jakebailey): rename this; no longer "services".
271+
272+ const buildServicesProject = ( ) => buildProject ( "src/typescript" ) ;
273+
254274const buildServices = ( ) => {
255275 if ( cmdLineOptions . bundle ) return esbuildServices . build ( ) ;
256276 writeCJSReexport ( "./built/local/typescript/typescript.js" , "./built/local/typescript.js" ) ;
257- return buildProject ( "src/typescript" ) ;
277+ return buildServicesProject ( ) ;
258278} ;
259279
260280task ( "services" , series ( preBuild , buildServices ) ) ;
@@ -277,6 +297,9 @@ task("watch-services").flags = {
277297 " --built" : "Compile using the built version of the compiler."
278298} ;
279299
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" ;
280303
281304const esbuildServer = esbuildTask ( "./src/tsserver/server.ts" , "./built/local/tsserver.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
282305
@@ -323,10 +346,11 @@ task("watch-min").flags = {
323346
324347const esbuildLssl = esbuildTask ( "./src/tsserverlibrary/tsserverlibrary.ts" , "./built/local/tsserverlibrary.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
325348
349+ const buildLsslProject = ( ) => buildProject ( "src/tsserverlibrary" ) ;
326350const buildLssl = ( ) => {
327351 if ( cmdLineOptions . bundle ) return esbuildLssl . build ( ) ;
328352 writeCJSReexport ( "./built/local/tsserverlibrary/tsserverlibrary.js" , "./built/local/tsserverlibrary.js" ) ;
329- return buildProject ( "src/tsserverlibrary" ) ;
353+ return buildLsslProject ( ) ;
330354} ;
331355task ( "lssl" , series ( preBuild , buildLssl ) ) ;
332356task ( "lssl" ) . description = "Builds language service server library" ;
@@ -348,6 +372,14 @@ task("watch-lssl").flags = {
348372 " --built" : "Compile using the built version of the compiler."
349373} ;
350374
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+
351383const testRunner = "./built/local/run.js" ;
352384const esbuildTests = esbuildTask ( "./src/testRunner/_namespaces/Harness.ts" , testRunner ) ;
353385
@@ -458,7 +490,7 @@ const buildOtherOutputs = parallel(buildCancellationToken, buildTypingsInstaller
458490task ( "other-outputs" , series ( preBuild , buildOtherOutputs ) ) ;
459491task ( "other-outputs" ) . description = "Builds miscelaneous scripts and documents distributed with the LKG" ;
460492
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 ) ) ) ;
462494task ( "local" ) . description = "Builds the full compiler and services" ;
463495task ( "local" ) . flags = {
464496 " --built" : "Compile using the built version of the compiler."
@@ -474,7 +506,7 @@ const preTest = parallel(buildTsc, buildTests, buildServices, buildLssl);
474506preTest . displayName = "preTest" ;
475507
476508const 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 ) ) ;
478510task ( "runtests" ) . description = "Runs the tests using the built run.js file." ;
479511task ( "runtests" ) . flags = {
480512 "-t --tests=<regex>" : "Pattern for tests to run." ,
@@ -493,7 +525,7 @@ task("runtests").flags = {
493525} ;
494526
495527const 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 ) ) ;
497529task ( "runtests-parallel" ) . description = "Runs all the tests in parallel using the built run.js file." ;
498530task ( "runtests-parallel" ) . flags = {
499531 " --light" : "Run tests in light mode (fewer verifications, but tests run faster)." ,
@@ -597,8 +629,7 @@ const produceLKG = async () => {
597629 }
598630} ;
599631
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 ) ) ;
602633task ( "LKG" ) . description = "Makes a new LKG out of the built js files" ;
603634task ( "LKG" ) . flags = {
604635 " --built" : "Compile using the built version of the compiler." ,
0 commit comments