@@ -171,8 +171,8 @@ function esbuildTask(entrypoint, outfile, exportIsTsObject = false, performanceM
171171 external : [ "./node_modules/*" ] ,
172172 conditions : [ "require" ] ,
173173 supported : {
174- // "const-and-let": false, // Unfortunately, no: https://github.com/evanw/esbuild/issues/297
175- "object-rest-spread" : false , // See : https://github.com/evanw/esbuild/releases/tag/v0.14.46
174+ // "const-and-let": false, // https://github.com/evanw/esbuild/issues/297
175+ "object-rest-spread" : false , // Performance enhancement, see : https://github.com/evanw/esbuild/releases/tag/v0.14.46
176176 } ,
177177 // legalComments: "none", // If we add copyright headers to the source files, uncomment.
178178 } ;
@@ -252,11 +252,12 @@ const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnost
252252
253253
254254const esbuildTsc = esbuildTask ( "./src/tsc/tsc.ts" , "./built/local/tsc.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
255+ const writeTscCJSShim = ( ) => writeCJSReexport ( "./built/local/tsc/tsc.js" , "./built/local/tsc.js" ) ;
255256
256257
257258const buildTsc = ( ) => {
258259 if ( cmdLineOptions . bundle ) return esbuildTsc . build ( ) ;
259- writeCJSReexport ( "./built/local/tsc/tsc.js" , "./built/local/tsc.js" ) ;
260+ writeTscCJSShim ( ) ;
260261 return buildProject ( "src/tsc" ) ;
261262} ;
262263task ( "tsc" , series ( lkgPreBuild , buildTsc ) ) ;
@@ -267,8 +268,11 @@ cleanTasks.push(cleanTsc);
267268task ( "clean-tsc" , cleanTsc ) ;
268269task ( "clean-tsc" ) . description = "Cleans outputs for the command-line compiler" ;
269270
270- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
271- const watchTsc = ( ) => cmdLineOptions . bundle ? esbuildTsc . watch ( ) : watchProject ( "src/tsc" ) ;
271+ const watchTsc = ( ) => {
272+ if ( cmdLineOptions . bundle ) return esbuildTsc . watch ( ) ;
273+ writeTscCJSShim ( ) ;
274+ return watchProject ( "src/tsc" ) ;
275+ } ;
272276task ( "watch-tsc" , series ( lkgPreBuild , parallel ( watchLib , watchDiagnostics , watchTsc ) ) ) ;
273277task ( "watch-tsc" ) . description = "Watch for changes and rebuild the command-line compiler only." ;
274278
@@ -278,15 +282,15 @@ const localPreBuild = parallel(generateLibs, series(buildScripts, generateDiagno
278282// Pre-build steps to use based on supplied options.
279283const preBuild = cmdLineOptions . lkg ? lkgPreBuild : localPreBuild ;
280284
281- const esbuildServices = esbuildTask ( "./src/typescript/typescript.ts" , "./built/local/typescript.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
282-
283285// TODO(jakebailey): rename this; no longer "services".
284286
287+ const esbuildServices = esbuildTask ( "./src/typescript/typescript.ts" , "./built/local/typescript.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
288+ const writeServicesCJSShim = ( ) => writeCJSReexport ( "./built/local/typescript/typescript.js" , "./built/local/typescript.js" ) ;
285289const buildServicesProject = ( ) => buildProject ( "src/typescript" ) ;
286290
287291const buildServices = ( ) => {
288292 if ( cmdLineOptions . bundle ) return esbuildServices . build ( ) ;
289- writeCJSReexport ( "./built/local/typescript/typescript.js" , "./built/local/typescript.js" ) ;
293+ writeServicesCJSShim ( ) ;
290294 return buildServicesProject ( ) ;
291295} ;
292296
@@ -302,8 +306,11 @@ cleanTasks.push(cleanServices);
302306task ( "clean-services" , cleanServices ) ;
303307task ( "clean-services" ) . description = "Cleans outputs for the language service" ;
304308
305- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
306- const watchServices = ( ) => cmdLineOptions . bundle ? esbuildServices . watch ( ) : watchProject ( "src/typescript" ) ;
309+ const watchServices = ( ) => {
310+ if ( cmdLineOptions . bundle ) return esbuildServices . watch ( ) ;
311+ writeServicesCJSShim ( ) ;
312+ return watchProject ( "src/typescript" ) ;
313+ } ;
307314task ( "watch-services" , series ( preBuild , parallel ( watchLib , watchDiagnostics , watchServices ) ) ) ;
308315task ( "watch-services" ) . description = "Watches for changes and rebuild language service only" ;
309316task ( "watch-services" ) . flags = {
@@ -315,10 +322,11 @@ task("dts-services", series(preBuild, buildServicesProject, dtsServices));
315322task ( "dts-services" ) . description = "Builds typescript.d.ts" ;
316323
317324const esbuildServer = esbuildTask ( "./src/tsserver/server.ts" , "./built/local/tsserver.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
325+ const writeServerCJSShim = ( ) => writeCJSReexport ( "./built/local/tsserver/server.js" , "./built/local/tsserver.js" ) ;
318326
319327const buildServer = ( ) => {
320328 if ( cmdLineOptions . bundle ) return esbuildServer . build ( ) ;
321- writeCJSReexport ( "./built/local/tsserver/server.js" , "./built/local/tsserver.js" ) ;
329+ writeServerCJSShim ( ) ;
322330 return buildProject ( "src/tsserver" ) ;
323331} ;
324332buildServer . displayName = "buildServer" ;
@@ -334,8 +342,11 @@ cleanTasks.push(cleanServer);
334342task ( "clean-tsserver" , cleanServer ) ;
335343task ( "clean-tsserver" ) . description = "Cleans outputs for the language server" ;
336344
337- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
338- const watchServer = ( ) => cmdLineOptions . bundle ? esbuildServer . watch ( ) : watchProject ( "src/tsserver" ) ;
345+ const watchServer = ( ) => {
346+ if ( cmdLineOptions . bundle ) return esbuildServer . watch ( ) ;
347+ writeServerCJSShim ( ) ;
348+ return watchProject ( "src/tsserver" ) ;
349+ } ;
339350task ( "watch-tsserver" , series ( preBuild , parallel ( watchLib , watchDiagnostics , watchServer ) ) ) ;
340351task ( "watch-tsserver" ) . description = "Watch for changes and rebuild the language server only" ;
341352task ( "watch-tsserver" ) . flags = {
@@ -358,11 +369,12 @@ task("watch-min").flags = {
358369} ;
359370
360371const esbuildLssl = esbuildTask ( "./src/tsserverlibrary/tsserverlibrary.ts" , "./built/local/tsserverlibrary.js" , /* exportIsTsObject */ true , /* performanceMatters */ true ) ;
372+ const writeLsslCJSShim = ( ) => writeCJSReexport ( "./built/local/tsserverlibrary/tsserverlibrary.js" , "./built/local/tsserverlibrary.js" ) ;
361373
362374const buildLsslProject = ( ) => buildProject ( "src/tsserverlibrary" ) ;
363375const buildLssl = ( ) => {
364376 if ( cmdLineOptions . bundle ) return esbuildLssl . build ( ) ;
365- writeCJSReexport ( "./built/local/tsserverlibrary/tsserverlibrary.js" , "./built/local/tsserverlibrary.js" ) ;
377+ writeLsslCJSShim ( ) ;
366378 return buildLsslProject ( ) ;
367379} ;
368380task ( "lssl" , series ( preBuild , buildLssl ) ) ;
@@ -376,9 +388,11 @@ cleanTasks.push(cleanLssl);
376388task ( "clean-lssl" , cleanLssl ) ;
377389task ( "clean-lssl" ) . description = "Clean outputs for the language service server library" ;
378390
379- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
380- const watchLssl = ( ) => cmdLineOptions . bundle ? esbuildLssl . watch ( ) : watchProject ( "src/tsserverlibrary" ) ;
381-
391+ const watchLssl = ( ) => {
392+ if ( cmdLineOptions . bundle ) return esbuildLssl . watch ( ) ;
393+ writeLsslCJSShim ( ) ;
394+ return watchProject ( "src/tsserverlibrary" ) ;
395+ } ;
382396task ( "watch-lssl" , series ( preBuild , parallel ( watchLib , watchDiagnostics , watchLssl ) ) ) ;
383397task ( "watch-lssl" ) . description = "Watch for changes and rebuild tsserverlibrary only" ;
384398task ( "watch-lssl" ) . flags = {
@@ -395,10 +409,11 @@ task("dts", dts);
395409
396410const testRunner = "./built/local/run.js" ;
397411const esbuildTests = esbuildTask ( "./src/testRunner/_namespaces/Harness.ts" , testRunner ) ;
412+ const writeTestsCJSShim = ( ) => writeCJSReexport ( "./built/local/testRunner/runner.js" , testRunner ) ;
398413
399414const buildTests = ( ) => {
400415 if ( cmdLineOptions . bundle ) return esbuildTests . build ( ) ;
401- writeCJSReexport ( "./built/local/testRunner/runner.js" , testRunner ) ;
416+ writeTestsCJSShim ( ) ;
402417 return buildProject ( "src/testRunner" ) ;
403418} ;
404419task ( "tests" , series ( preBuild , parallel ( buildLssl , buildTests ) ) ) ;
@@ -412,8 +427,11 @@ cleanTasks.push(cleanTests);
412427task ( "clean-tests" , cleanTests ) ;
413428task ( "clean-tests" ) . description = "Cleans the outputs for the test infrastructure" ;
414429
415- // TODO(jakebailey): watch mode doesn't mix with --bundle=false.
416- const watchTests = ( ) => cmdLineOptions . bundle ? esbuildTests . watch ( ) : watchProject ( "src/testRunner" ) ;
430+ const watchTests = ( ) => {
431+ if ( cmdLineOptions . bundle ) return esbuildTests . watch ( ) ;
432+ writeTestsCJSShim ( ) ;
433+ return watchProject ( "src/testRunner" ) ;
434+ } ;
417435
418436const buildEslintRules = ( ) => buildProject ( "scripts/eslint" ) ;
419437task ( "build-eslint-rules" , buildEslintRules ) ;
@@ -465,7 +483,6 @@ const esbuildTypingsInstaller = esbuildTask("./src/typingsInstaller/nodeTypingsI
465483
466484const buildTypingsInstaller = ( ) => {
467485 if ( cmdLineOptions . bundle ) return esbuildTypingsInstaller . build ( ) ;
468- // TODO(jakebailey): In --bundle=false, can we emit to this directly?
469486 writeCJSReexport ( "./built/typingsInstaller/nodeTypingsInstaller.js" , "./built/local/typingsInstaller.js" ) ;
470487 return buildProject ( "src/typingsInstaller" ) ;
471488} ;
@@ -599,16 +616,19 @@ task("importDefinitelyTypedTests").description = "Runs the importDefinitelyTyped
599616const cleanBuilt = ( ) => del ( "built" ) ;
600617
601618const produceLKG = async ( ) => {
602- // TODO(jakebailey): there are probably more files here that are needed.
619+ if ( ! cmdLineOptions . bundle ) {
620+ throw new Error ( "LKG cannot be created when --bundle=false" ) ;
621+ }
622+
603623 const expectedFiles = [
624+ "built/local/cancellationToken.js" ,
604625 "built/local/tsc.js" ,
605626 "built/local/tsserver.js" ,
606- "built/local/typescript.js" ,
607- "built/local/typescript.d.ts" ,
608627 "built/local/tsserverlibrary.js" ,
609628 "built/local/tsserverlibrary.d.ts" ,
629+ "built/local/typescript.js" ,
630+ "built/local/typescript.d.ts" ,
610631 "built/local/typingsInstaller.js" ,
611- "built/local/cancellationToken.js" ,
612632 "built/local/watchGuard.js" ,
613633 ] . concat ( libs . map ( lib => lib . target ) ) ;
614634 const missingFiles = expectedFiles
@@ -639,8 +659,6 @@ task("generate-spec").description = "Generates a Markdown version of the Languag
639659task ( "clean" , series ( parallel ( cleanTasks ) , cleanBuilt ) ) ;
640660task ( "clean" ) . description = "Cleans build outputs" ;
641661
642- // TODO(jakebailey): Figure out what needs to change below.
643-
644662const configureNightly = ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.js" , "dev" , "package.json" , "src/compiler/corePublic.ts" ] ) ;
645663task ( "configure-nightly" , series ( buildScripts , configureNightly ) ) ;
646664task ( "configure-nightly" ) . description = "Runs scripts/configurePrerelease.ts to prepare a build for nightly publishing" ;
0 commit comments