@@ -127,6 +127,15 @@ 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 } projectPath
132+ * @param {string } entrypoint
133+ * @param {string } output
134+ */
135+ async function runDtsBundler ( projectPath , entrypoint , output ) {
136+ await exec ( process . execPath , [ "./scripts/dtsBundler.js" , projectPath , entrypoint , output ] ) ;
137+ }
138+
130139/** @type {string | undefined } */
131140let copyrightHeader ;
132141function getCopyrightHeader ( ) {
@@ -143,6 +152,7 @@ function getCopyrightHeader() {
143152 * @param {boolean } performanceMatters True if this is a bundle where performance matters, so should be optimized at the cost of build time.
144153 */
145154function esbuildTask ( entrypoint , outfile , exportIsTsObject = false , performanceMatters = false ) {
155+ performanceMatters = false ;
146156 const preBabel = `${ outfile } .tmp.js` ;
147157
148158 /** @type {esbuild.BuildOptions } */
@@ -251,10 +261,13 @@ const preBuild = cmdLineOptions.lkg ? lkgPreBuild : localPreBuild;
251261const esbuildServices = esbuildTask ( "./src/typescript/typescript.ts" , "./built/local/typescript.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
252262
253263// TODO(jakebailey): rename this; no longer "services".
264+
265+ const buildServicesProject = ( ) => buildProject ( "src/typescript" ) ;
266+
254267const buildServices = ( ) => {
255268 if ( cmdLineOptions . bundle ) return esbuildServices . build ( ) ;
256269 writeCJSReexport ( "./built/local/typescript/typescript.js" , "./built/local/typescript.js" ) ;
257- return buildProject ( "src/typescript" ) ;
270+ return buildServicesProject ( ) ;
258271} ;
259272
260273task ( "services" , series ( preBuild , buildServices ) ) ;
@@ -277,6 +290,9 @@ task("watch-services").flags = {
277290 " --built" : "Compile using the built version of the compiler."
278291} ;
279292
293+ const dtsServices = ( ) => runDtsBundler ( "./src/typescript/tsconfig.json" , "./built/local/typescript/typescript.d.ts" , "./built/local/typescript.d.ts" ) ;
294+ task ( "dts-services" , series ( preBuild , buildServicesProject , dtsServices ) ) ;
295+ task ( "dts-services" ) . description = "Builds typescript.d.ts" ;
280296
281297const esbuildServer = esbuildTask ( "./src/tsserver/server.ts" , "./built/local/tsserver.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
282298
@@ -323,10 +339,11 @@ task("watch-min").flags = {
323339
324340const esbuildLssl = esbuildTask ( "./src/tsserverlibrary/tsserverlibrary.ts" , "./built/local/tsserverlibrary.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
325341
342+ const buildLsslProject = ( ) => buildProject ( "src/tsserverlibrary" ) ;
326343const buildLssl = ( ) => {
327344 if ( cmdLineOptions . bundle ) return esbuildLssl . build ( ) ;
328345 writeCJSReexport ( "./built/local/tsserverlibrary/tsserverlibrary.js" , "./built/local/tsserverlibrary.js" ) ;
329- return buildProject ( "src/tsserverlibrary" ) ;
346+ return buildLsslProject ( ) ;
330347} ;
331348task ( "lssl" , series ( preBuild , buildLssl ) ) ;
332349task ( "lssl" ) . description = "Builds language service server library" ;
@@ -348,6 +365,14 @@ task("watch-lssl").flags = {
348365 " --built" : "Compile using the built version of the compiler."
349366} ;
350367
368+ const dtsLssl = ( ) => runDtsBundler ( "./src/tsserverlibrary/tsconfig.json" , "./built/local/tsserverlibrary/tsserverlibrary.d.ts" , "./built/local/tsserverlibrary.d.ts" ) ;
369+ task ( "dts-lssl" , series ( preBuild , buildLsslProject , dtsLssl ) ) ;
370+ task ( "dts-lssl" ) . description = "Builds tsserverlibrary.d.ts" ;
371+
372+ // TODO(jakebailey): this is probably not efficient, but, gulp.
373+ const dts = series ( preBuild , parallel ( dtsServices , dtsLssl ) ) ;
374+ task ( "dts" , dts ) ;
375+
351376const testRunner = "./built/local/run.js" ;
352377const esbuildTests = esbuildTask ( "./src/testRunner/_namespaces/Harness.ts" , testRunner ) ;
353378
@@ -458,7 +483,7 @@ const buildOtherOutputs = parallel(buildCancellationToken, buildTypingsInstaller
458483task ( "other-outputs" , series ( preBuild , buildOtherOutputs ) ) ;
459484task ( "other-outputs" ) . description = "Builds miscelaneous scripts and documents distributed with the LKG" ;
460485
461- task ( "local" , series ( preBuild , parallel ( localize , buildTsc , buildServer , buildServices , buildLssl , buildOtherOutputs ) ) ) ;
486+ task ( "local" , series ( preBuild , parallel ( localize , buildTsc , buildServer , buildServices , buildLssl , buildOtherOutputs , dts ) ) ) ;
462487task ( "local" ) . description = "Builds the full compiler and services" ;
463488task ( "local" ) . flags = {
464489 " --built" : "Compile using the built version of the compiler."
@@ -474,7 +499,7 @@ const preTest = parallel(buildTsc, buildTests, buildServices, buildLssl);
474499preTest . displayName = "preTest" ;
475500
476501const runTests = ( ) => runConsoleTests ( testRunner , "mocha-fivemat-progress-reporter" , /*runInParallel*/ false , /*watchMode*/ false ) ;
477- task ( "runtests" , series ( preBuild , preTest , runTests ) ) ;
502+ task ( "runtests" , series ( preBuild , preTest , dts , runTests ) ) ;
478503task ( "runtests" ) . description = "Runs the tests using the built run.js file." ;
479504task ( "runtests" ) . flags = {
480505 "-t --tests=<regex>" : "Pattern for tests to run." ,
@@ -493,7 +518,7 @@ task("runtests").flags = {
493518} ;
494519
495520const runTestsParallel = ( ) => runConsoleTests ( testRunner , "min" , /*runInParallel*/ cmdLineOptions . workers > 1 , /*watchMode*/ false ) ;
496- task ( "runtests-parallel" , series ( preBuild , preTest , runTestsParallel ) ) ;
521+ task ( "runtests-parallel" , series ( preBuild , preTest , dts , runTestsParallel ) ) ;
497522task ( "runtests-parallel" ) . description = "Runs all the tests in parallel using the built run.js file." ;
498523task ( "runtests-parallel" ) . flags = {
499524 " --light" : "Run tests in light mode (fewer verifications, but tests run faster)." ,
@@ -597,8 +622,7 @@ const produceLKG = async () => {
597622 }
598623} ;
599624
600- // TODO(jakebailey): dependencies on dts
601- task ( "LKG" , series ( lkgPreBuild , parallel ( localize , buildTsc , buildServer , buildServices , buildLssl , buildOtherOutputs ) , produceLKG ) ) ;
625+ task ( "LKG" , series ( lkgPreBuild , parallel ( localize , buildTsc , buildServer , buildServices , buildLssl , buildOtherOutputs , dts ) , produceLKG ) ) ;
602626task ( "LKG" ) . description = "Makes a new LKG out of the built js files" ;
603627task ( "LKG" ) . flags = {
604628 " --built" : "Compile using the built version of the compiler." ,
0 commit comments