@@ -170,8 +170,8 @@ function esbuildTask(entrypoint, outfile, exportIsTsObject = false) {
170170 external : [ "./node_modules/*" ] ,
171171 conditions : [ "require" ] ,
172172 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
175175 } ,
176176 // legalComments: "none", // If we add copyright headers to the source files, uncomment.
177177 plugins : [
@@ -248,11 +248,12 @@ const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnost
248248
249249
250250const 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" ) ;
251252
252253
253254const buildTsc = ( ) => {
254255 if ( cmdLineOptions . bundle ) return esbuildTsc . build ( ) ;
255- writeCJSReexport ( "./built/local/tsc/tsc.js" , "./built/local/tsc.js" ) ;
256+ writeTscCJSShim ( ) ;
256257 return buildProject ( "src/tsc" ) ;
257258} ;
258259task ( "tsc" , series ( lkgPreBuild , buildTsc ) ) ;
@@ -263,8 +264,11 @@ cleanTasks.push(cleanTsc);
263264task ( "clean-tsc" , cleanTsc ) ;
264265task ( "clean-tsc" ) . description = "Cleans outputs for the command-line compiler" ;
265266
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+ } ;
268272task ( "watch-tsc" , series ( lkgPreBuild , parallel ( watchLib , watchDiagnostics , watchTsc ) ) ) ;
269273task ( "watch-tsc" ) . description = "Watch for changes and rebuild the command-line compiler only." ;
270274
@@ -274,15 +278,15 @@ const localPreBuild = parallel(generateLibs, series(buildScripts, generateDiagno
274278// Pre-build steps to use based on supplied options.
275279const preBuild = cmdLineOptions . lkg ? lkgPreBuild : localPreBuild ;
276280
277- const esbuildServices = esbuildTask ( "./src/typescript/typescript.ts" , "./built/local/typescript.js" , /* exportIsTsObject */ true ) ;
278-
279281// TODO(jakebailey): rename this; no longer "services".
280282
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" ) ;
281285const buildServicesProject = ( ) => buildProject ( "src/typescript" ) ;
282286
283287const buildServices = ( ) => {
284288 if ( cmdLineOptions . bundle ) return esbuildServices . build ( ) ;
285- writeCJSReexport ( "./built/local/typescript/typescript.js" , "./built/local/typescript.js" ) ;
289+ writeServicesCJSShim ( ) ;
286290 return buildServicesProject ( ) ;
287291} ;
288292
@@ -298,8 +302,11 @@ cleanTasks.push(cleanServices);
298302task ( "clean-services" , cleanServices ) ;
299303task ( "clean-services" ) . description = "Cleans outputs for the language service" ;
300304
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+ } ;
303310task ( "watch-services" , series ( preBuild , parallel ( watchLib , watchDiagnostics , watchServices ) ) ) ;
304311task ( "watch-services" ) . description = "Watches for changes and rebuild language service only" ;
305312task ( "watch-services" ) . flags = {
@@ -311,10 +318,11 @@ task("dts-services", series(preBuild, buildServicesProject, dtsServices));
311318task ( "dts-services" ) . description = "Builds typescript.d.ts" ;
312319
313320const 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" ) ;
314322
315323const buildServer = ( ) => {
316324 if ( cmdLineOptions . bundle ) return esbuildServer . build ( ) ;
317- writeCJSReexport ( "./built/local/tsserver/server.js" , "./built/local/tsserver.js" ) ;
325+ writeServerCJSShim ( ) ;
318326 return buildProject ( "src/tsserver" ) ;
319327} ;
320328buildServer . displayName = "buildServer" ;
@@ -330,8 +338,11 @@ cleanTasks.push(cleanServer);
330338task ( "clean-tsserver" , cleanServer ) ;
331339task ( "clean-tsserver" ) . description = "Cleans outputs for the language server" ;
332340
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+ } ;
335346task ( "watch-tsserver" , series ( preBuild , parallel ( watchLib , watchDiagnostics , watchServer ) ) ) ;
336347task ( "watch-tsserver" ) . description = "Watch for changes and rebuild the language server only" ;
337348task ( "watch-tsserver" ) . flags = {
@@ -354,11 +365,12 @@ task("watch-min").flags = {
354365} ;
355366
356367const 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" ) ;
357369
358370const buildLsslProject = ( ) => buildProject ( "src/tsserverlibrary" ) ;
359371const buildLssl = ( ) => {
360372 if ( cmdLineOptions . bundle ) return esbuildLssl . build ( ) ;
361- writeCJSReexport ( "./built/local/tsserverlibrary/tsserverlibrary.js" , "./built/local/tsserverlibrary.js" ) ;
373+ writeLsslCJSShim ( ) ;
362374 return buildLsslProject ( ) ;
363375} ;
364376task ( "lssl" , series ( preBuild , buildLssl ) ) ;
@@ -372,9 +384,11 @@ cleanTasks.push(cleanLssl);
372384task ( "clean-lssl" , cleanLssl ) ;
373385task ( "clean-lssl" ) . description = "Clean outputs for the language service server library" ;
374386
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+ } ;
378392task ( "watch-lssl" , series ( preBuild , parallel ( watchLib , watchDiagnostics , watchLssl ) ) ) ;
379393task ( "watch-lssl" ) . description = "Watch for changes and rebuild tsserverlibrary only" ;
380394task ( "watch-lssl" ) . flags = {
@@ -391,10 +405,11 @@ task("dts", dts);
391405
392406const testRunner = "./built/local/run.js" ;
393407const esbuildTests = esbuildTask ( "./src/testRunner/_namespaces/Harness.ts" , testRunner ) ;
408+ const writeTestsCJSShim = ( ) => writeCJSReexport ( "./built/local/testRunner/runner.js" , testRunner ) ;
394409
395410const buildTests = ( ) => {
396411 if ( cmdLineOptions . bundle ) return esbuildTests . build ( ) ;
397- writeCJSReexport ( "./built/local/testRunner/runner.js" , testRunner ) ;
412+ writeTestsCJSShim ( ) ;
398413 return buildProject ( "src/testRunner" ) ;
399414} ;
400415task ( "tests" , series ( preBuild , parallel ( buildLssl , buildTests ) ) ) ;
@@ -408,8 +423,11 @@ cleanTasks.push(cleanTests);
408423task ( "clean-tests" , cleanTests ) ;
409424task ( "clean-tests" ) . description = "Cleans the outputs for the test infrastructure" ;
410425
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+ } ;
413431
414432const buildEslintRules = ( ) => buildProject ( "scripts/eslint" ) ;
415433task ( "build-eslint-rules" , buildEslintRules ) ;
@@ -461,7 +479,6 @@ const esbuildTypingsInstaller = esbuildTask("./src/typingsInstaller/nodeTypingsI
461479
462480const buildTypingsInstaller = ( ) => {
463481 if ( cmdLineOptions . bundle ) return esbuildTypingsInstaller . build ( ) ;
464- // TODO(jakebailey): In --bundle=false, can we emit to this directly?
465482 writeCJSReexport ( "./built/typingsInstaller/nodeTypingsInstaller.js" , "./built/local/typingsInstaller.js" ) ;
466483 return buildProject ( "src/typingsInstaller" ) ;
467484} ;
@@ -595,16 +612,19 @@ task("importDefinitelyTypedTests").description = "Runs the importDefinitelyTyped
595612const cleanBuilt = ( ) => del ( "built" ) ;
596613
597614const 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+
599619 const expectedFiles = [
620+ "built/local/cancellationToken.js" ,
600621 "built/local/tsc.js" ,
601622 "built/local/tsserver.js" ,
602- "built/local/typescript.js" ,
603- "built/local/typescript.d.ts" ,
604623 "built/local/tsserverlibrary.js" ,
605624 "built/local/tsserverlibrary.d.ts" ,
625+ "built/local/typescript.js" ,
626+ "built/local/typescript.d.ts" ,
606627 "built/local/typingsInstaller.js" ,
607- "built/local/cancellationToken.js" ,
608628 "built/local/watchGuard.js" ,
609629 ] . concat ( libs . map ( lib => lib . target ) ) ;
610630 const missingFiles = expectedFiles
@@ -635,8 +655,6 @@ task("generate-spec").description = "Generates a Markdown version of the Languag
635655task ( "clean" , series ( parallel ( cleanTasks ) , cleanBuilt ) ) ;
636656task ( "clean" ) . description = "Cleans build outputs" ;
637657
638- // TODO(jakebailey): Figure out what needs to change below.
639-
640658const configureNightly = ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.js" , "dev" , "package.json" , "src/compiler/corePublic.ts" ] ) ;
641659task ( "configure-nightly" , series ( buildScripts , configureNightly ) ) ;
642660task ( "configure-nightly" ) . description = "Runs scripts/configurePrerelease.ts to prepare a build for nightly publishing" ;
0 commit comments