@@ -6,8 +6,24 @@ import { task } from "hereby";
6
6
import _glob from "glob" ;
7
7
import util from "util" ;
8
8
import chalk from "chalk" ;
9
- import { Debouncer , Deferred , exec , getDiffTool , getDirSize , memoize , needsUpdate , readJson } from "./scripts/build/utils.mjs" ;
10
- import { cleanTestDirs , localBaseline , localRwcBaseline , refBaseline , refRwcBaseline , runConsoleTests } from "./scripts/build/tests.mjs" ;
9
+ import {
10
+ Debouncer ,
11
+ Deferred ,
12
+ exec ,
13
+ getDiffTool ,
14
+ getDirSize ,
15
+ memoize ,
16
+ needsUpdate ,
17
+ readJson ,
18
+ } from "./scripts/build/utils.mjs" ;
19
+ import {
20
+ cleanTestDirs ,
21
+ localBaseline ,
22
+ localRwcBaseline ,
23
+ refBaseline ,
24
+ refRwcBaseline ,
25
+ runConsoleTests ,
26
+ } from "./scripts/build/tests.mjs" ;
11
27
import { buildProject as realBuildProject , cleanProject , watchProject } from "./scripts/build/projects.mjs" ;
12
28
import { localizationDirectories } from "./scripts/build/localization.mjs" ;
13
29
import cmdLineOptions from "./scripts/build/options.mjs" ;
@@ -40,7 +56,10 @@ const buildProjectWithEmit = async (...args) => {
40
56
41
57
if ( currentlyBuilding === 0 ) {
42
58
oldTsconfigBase = fs . readFileSync ( tsconfigBasePath , "utf-8" ) ;
43
- fs . writeFileSync ( tsconfigBasePath , oldTsconfigBase . replace ( `"emitDeclarationOnly": true,` , `"emitDeclarationOnly": false, // DO NOT COMMIT` ) ) ;
59
+ fs . writeFileSync (
60
+ tsconfigBasePath ,
61
+ oldTsconfigBase . replace ( `"emitDeclarationOnly": true,` , `"emitDeclarationOnly": false, // DO NOT COMMIT` ) ,
62
+ ) ;
44
63
}
45
64
46
65
currentlyBuilding ++ ;
@@ -138,7 +157,12 @@ const localize = task({
138
157
dependencies : [ generateDiagnostics ] ,
139
158
run : async ( ) => {
140
159
if ( needsUpdate ( diagnosticMessagesGeneratedJson , generatedLCGFile ) ) {
141
- await exec ( process . execPath , [ "scripts/generateLocalizedDiagnosticMessages.mjs" , "src/loc/lcl" , "built/local" , diagnosticMessagesGeneratedJson ] , { ignoreExitCode : true } ) ;
160
+ await exec ( process . execPath , [
161
+ "scripts/generateLocalizedDiagnosticMessages.mjs" ,
162
+ "src/loc/lcl" ,
163
+ "built/local" ,
164
+ diagnosticMessagesGeneratedJson ,
165
+ ] , { ignoreExitCode : true } ) ;
142
166
}
143
167
} ,
144
168
} ) ;
@@ -224,7 +248,9 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
224
248
//
225
249
// See: https://github.com/evanw/esbuild/issues/1958
226
250
return {
227
- errors : [ { text : 'Attempted to bundle from node_modules; ensure "external" is set correctly.' } ] ,
251
+ errors : [ {
252
+ text : 'Attempted to bundle from node_modules; ensure "external" is set correctly.' ,
253
+ } ] ,
228
254
} ;
229
255
} ) ;
230
256
} ,
@@ -266,7 +292,8 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
266
292
267
293
return {
268
294
build : async ( ) => esbuild . build ( await getOptions ( ) ) ,
269
- watch : async ( ) => esbuild . build ( { ...await getOptions ( ) , watch : taskOptions . watchMode ?? true , logLevel : "info" } ) ,
295
+ watch : async ( ) =>
296
+ esbuild . build ( { ...await getOptions ( ) , watch : taskOptions . watchMode ?? true , logLevel : "info" } ) ,
270
297
} ;
271
298
}
272
299
@@ -317,7 +344,10 @@ function entrypointBuildTask(options) {
317
344
const outDir = path . dirname ( options . output ) ;
318
345
await fs . promises . mkdir ( outDir , { recursive : true } ) ;
319
346
const moduleSpecifier = path . relative ( outDir , options . builtEntrypoint ) ;
320
- await fs . promises . writeFile ( options . output , `module.exports = require("./${ moduleSpecifier . replace ( / [ \\ / ] / g, "/" ) } ")` ) ;
347
+ await fs . promises . writeFile (
348
+ options . output ,
349
+ `module.exports = require("./${ moduleSpecifier . replace ( / [ \\ / ] / g, "/" ) } ")` ,
350
+ ) ;
321
351
} ,
322
352
} ) ;
323
353
@@ -341,13 +371,19 @@ function entrypointBuildTask(options) {
341
371
const watch = task ( {
342
372
name : `watch-${ options . name } ` ,
343
373
hiddenFromTaskList : true , // This is best effort.
344
- dependencies : ( options . buildDeps ?? [ ] ) . concat ( options . mainDeps ?? [ ] ) . concat ( cmdLineOptions . bundle ? [ ] : [ shim ] ) ,
374
+ dependencies : ( options . buildDeps ?? [ ] ) . concat ( options . mainDeps ?? [ ] ) . concat (
375
+ cmdLineOptions . bundle ? [ ] : [ shim ] ,
376
+ ) ,
345
377
run : ( ) => {
346
378
// These watch functions return promises that resolve once watch mode has started,
347
379
// allowing them to operate as regular tasks, while creating unresolved promises
348
380
// in the background that keep the process running after all tasks have exited.
349
381
if ( ! printedWatchWarning ) {
350
- console . error ( chalk . yellowBright ( "Warning: watch mode is incomplete and may not work as expected. Use at your own risk." ) ) ;
382
+ console . error (
383
+ chalk . yellowBright (
384
+ "Warning: watch mode is incomplete and may not work as expected. Use at your own risk." ,
385
+ ) ,
386
+ ) ;
351
387
printedWatchWarning = true ;
352
388
}
353
389
@@ -391,7 +427,12 @@ export const dtsServices = task({
391
427
description : "Bundles typescript.d.ts" ,
392
428
dependencies : [ buildServices ] ,
393
429
run : async ( ) => {
394
- if ( needsUpdate ( "./built/local/typescript/tsconfig.tsbuildinfo" , [ "./built/local/typescript.d.ts" , "./built/local/typescript.internal.d.ts" ] ) ) {
430
+ if (
431
+ needsUpdate ( "./built/local/typescript/tsconfig.tsbuildinfo" , [
432
+ "./built/local/typescript.d.ts" ,
433
+ "./built/local/typescript.internal.d.ts" ,
434
+ ] )
435
+ ) {
395
436
await runDtsBundler ( "./built/local/typescript/typescript.d.ts" , "./built/local/typescript.d.ts" ) ;
396
437
}
397
438
} ,
@@ -445,8 +486,16 @@ export const dtsLssl = task({
445
486
description : "Bundles tsserverlibrary.d.ts" ,
446
487
dependencies : [ buildLssl ] ,
447
488
run : async ( ) => {
448
- if ( needsUpdate ( "./built/local/tsserverlibrary/tsconfig.tsbuildinfo" , [ "./built/local/tsserverlibrary.d.ts" , "./built/local/tsserverlibrary.internal.d.ts" ] ) ) {
449
- await runDtsBundler ( "./built/local/tsserverlibrary/tsserverlibrary.d.ts" , "./built/local/tsserverlibrary.d.ts" ) ;
489
+ if (
490
+ needsUpdate ( "./built/local/tsserverlibrary/tsconfig.tsbuildinfo" , [
491
+ "./built/local/tsserverlibrary.d.ts" ,
492
+ "./built/local/tsserverlibrary.internal.d.ts" ,
493
+ ] )
494
+ ) {
495
+ await runDtsBundler (
496
+ "./built/local/tsserverlibrary/tsserverlibrary.d.ts" ,
497
+ "./built/local/tsserverlibrary.d.ts" ,
498
+ ) ;
450
499
}
451
500
} ,
452
501
} ) ;
@@ -579,7 +628,13 @@ export const watchOtherOutputs = task({
579
628
name : "watch-other-outputs" ,
580
629
description : "Builds miscelaneous scripts and documents distributed with the LKG" ,
581
630
hiddenFromTaskList : true ,
582
- dependencies : [ watchCancellationToken , watchTypingsInstaller , watchWatchGuard , generateTypesMap , copyBuiltLocalDiagnosticMessages ] ,
631
+ dependencies : [
632
+ watchCancellationToken ,
633
+ watchTypingsInstaller ,
634
+ watchWatchGuard ,
635
+ generateTypesMap ,
636
+ copyBuiltLocalDiagnosticMessages ,
637
+ ] ,
583
638
} ) ;
584
639
585
640
export const local = task ( {
@@ -657,7 +712,10 @@ export const runTestsAndWatch = task({
657
712
if ( ! token . signaled ) {
658
713
running = true ;
659
714
try {
660
- await runConsoleTests ( testRunner , "mocha-fivemat-progress-reporter" , /*runInParallel*/ false , { token, watching : true } ) ;
715
+ await runConsoleTests ( testRunner , "mocha-fivemat-progress-reporter" , /*runInParallel*/ false , {
716
+ token,
717
+ watching : true ,
718
+ } ) ;
661
719
}
662
720
catch {
663
721
// ignore
@@ -816,7 +874,10 @@ export const updateSublime = task({
816
874
dependencies : [ tsserver ] ,
817
875
run : async ( ) => {
818
876
for ( const file of [ "built/local/tsserver.js" , "built/local/tsserver.js.map" ] ) {
819
- await fs . promises . copyFile ( file , path . resolve ( "../TypeScript-Sublime-Plugin/tsserver/" , path . basename ( file ) ) ) ;
877
+ await fs . promises . copyFile (
878
+ file ,
879
+ path . resolve ( "../TypeScript-Sublime-Plugin/tsserver/" , path . basename ( file ) ) ,
880
+ ) ;
820
881
}
821
882
} ,
822
883
} ) ;
@@ -852,7 +913,10 @@ export const produceLKG = task({
852
913
. concat ( localizationTargets )
853
914
. filter ( f => ! fs . existsSync ( f ) ) ;
854
915
if ( missingFiles . length > 0 ) {
855
- throw new Error ( "Cannot replace the LKG unless all built targets are present in directory 'built/local/'. The following files are missing:\n" + missingFiles . join ( "\n" ) ) ;
916
+ throw new Error (
917
+ "Cannot replace the LKG unless all built targets are present in directory 'built/local/'. The following files are missing:\n"
918
+ + missingFiles . join ( "\n" ) ,
919
+ ) ;
856
920
}
857
921
const sizeBefore = getDirSize ( "lib" ) ;
858
922
await exec ( process . execPath , [ "scripts/produceLKG.mjs" ] ) ;
@@ -873,7 +937,13 @@ export const generateSpec = task({
873
937
name : "generate-spec" ,
874
938
description : "Generates a Markdown version of the Language Specification" ,
875
939
hiddenFromTaskList : true ,
876
- run : ( ) => exec ( "cscript" , [ "//nologo" , "scripts/word2md.mjs" , path . resolve ( "doc/TypeScript Language Specification - ARCHIVED.docx" ) , path . resolve ( "doc/spec-ARCHIVED.md" ) ] ) ,
940
+ run : ( ) =>
941
+ exec ( "cscript" , [
942
+ "//nologo" ,
943
+ "scripts/word2md.mjs" ,
944
+ path . resolve ( "doc/TypeScript Language Specification - ARCHIVED.docx" ) ,
945
+ path . resolve ( "doc/spec-ARCHIVED.md" ) ,
946
+ ] ) ,
877
947
} ) ;
878
948
879
949
export const cleanBuilt = task ( {
@@ -891,19 +961,37 @@ export const clean = task({
891
961
export const configureNightly = task ( {
892
962
name : "configure-nightly" ,
893
963
description : "Runs scripts/configurePrerelease.mjs to prepare a build for nightly publishing" ,
894
- run : ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.mjs" , "dev" , "package.json" , "src/compiler/corePublic.ts" ] ) ,
964
+ run : ( ) =>
965
+ exec ( process . execPath , [
966
+ "scripts/configurePrerelease.mjs" ,
967
+ "dev" ,
968
+ "package.json" ,
969
+ "src/compiler/corePublic.ts" ,
970
+ ] ) ,
895
971
} ) ;
896
972
897
973
export const configureInsiders = task ( {
898
974
name : "configure-insiders" ,
899
975
description : "Runs scripts/configurePrerelease.mjs to prepare a build for insiders publishing" ,
900
- run : ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.mjs" , "insiders" , "package.json" , "src/compiler/corePublic.ts" ] ) ,
976
+ run : ( ) =>
977
+ exec ( process . execPath , [
978
+ "scripts/configurePrerelease.mjs" ,
979
+ "insiders" ,
980
+ "package.json" ,
981
+ "src/compiler/corePublic.ts" ,
982
+ ] ) ,
901
983
} ) ;
902
984
903
985
export const configureExperimental = task ( {
904
986
name : "configure-experimental" ,
905
987
description : "Runs scripts/configurePrerelease.mjs to prepare a build for experimental publishing" ,
906
- run : ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.mjs" , "experimental" , "package.json" , "src/compiler/corePublic.ts" ] ) ,
988
+ run : ( ) =>
989
+ exec ( process . execPath , [
990
+ "scripts/configurePrerelease.mjs" ,
991
+ "experimental" ,
992
+ "package.json" ,
993
+ "src/compiler/corePublic.ts" ,
994
+ ] ) ,
907
995
} ) ;
908
996
909
997
export const help = task ( {
0 commit comments