@@ -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 { exec , readJson , getDiffTool , getDirSize , memoize , needsUpdate , Debouncer , Deferred } from "./scripts/build/utils.mjs" ;
10
- import { runConsoleTests , refBaseline , localBaseline , refRwcBaseline , localRwcBaseline , cleanTestDirs } from "./scripts/build/tests.mjs" ;
9
+ import {
10
+ exec ,
11
+ readJson ,
12
+ getDiffTool ,
13
+ getDirSize ,
14
+ memoize ,
15
+ needsUpdate ,
16
+ Debouncer ,
17
+ Deferred ,
18
+ } from "./scripts/build/utils.mjs" ;
19
+ import {
20
+ runConsoleTests ,
21
+ refBaseline ,
22
+ localBaseline ,
23
+ refRwcBaseline ,
24
+ localRwcBaseline ,
25
+ cleanTestDirs ,
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
@@ -330,13 +360,19 @@ function entrypointBuildTask(options) {
330
360
const watch = task ( {
331
361
name : `watch-${ options . name } ` ,
332
362
hiddenFromTaskList : true , // This is best effort.
333
- dependencies : ( options . buildDeps ?? [ ] ) . concat ( options . mainDeps ?? [ ] ) . concat ( cmdLineOptions . bundle ? [ ] : [ shim ] ) ,
363
+ dependencies : ( options . buildDeps ?? [ ] ) . concat ( options . mainDeps ?? [ ] ) . concat (
364
+ cmdLineOptions . bundle ? [ ] : [ shim ] ,
365
+ ) ,
334
366
run : ( ) => {
335
367
// These watch functions return promises that resolve once watch mode has started,
336
368
// allowing them to operate as regular tasks, while creating unresolved promises
337
369
// in the background that keep the process running after all tasks have exited.
338
370
if ( ! printedWatchWarning ) {
339
- console . error ( chalk . yellowBright ( "Warning: watch mode is incomplete and may not work as expected. Use at your own risk." ) ) ;
371
+ console . error (
372
+ chalk . yellowBright (
373
+ "Warning: watch mode is incomplete and may not work as expected. Use at your own risk." ,
374
+ ) ,
375
+ ) ;
340
376
printedWatchWarning = true ;
341
377
}
342
378
@@ -380,7 +416,12 @@ export const dtsServices = task({
380
416
description : "Bundles typescript.d.ts" ,
381
417
dependencies : [ buildServices ] ,
382
418
run : async ( ) => {
383
- if ( needsUpdate ( "./built/local/typescript/tsconfig.tsbuildinfo" , [ "./built/local/typescript.d.ts" , "./built/local/typescript.internal.d.ts" ] ) ) {
419
+ if (
420
+ needsUpdate ( "./built/local/typescript/tsconfig.tsbuildinfo" , [
421
+ "./built/local/typescript.d.ts" ,
422
+ "./built/local/typescript.internal.d.ts" ,
423
+ ] )
424
+ ) {
384
425
await runDtsBundler ( "./built/local/typescript/typescript.d.ts" , "./built/local/typescript.d.ts" ) ;
385
426
}
386
427
} ,
@@ -439,8 +480,16 @@ export const dtsLssl = task({
439
480
description : "Bundles tsserverlibrary.d.ts" ,
440
481
dependencies : [ buildLssl ] ,
441
482
run : async ( ) => {
442
- if ( needsUpdate ( "./built/local/tsserverlibrary/tsconfig.tsbuildinfo" , [ "./built/local/tsserverlibrary.d.ts" , "./built/local/tsserverlibrary.internal.d.ts" ] ) ) {
443
- await runDtsBundler ( "./built/local/tsserverlibrary/tsserverlibrary.d.ts" , "./built/local/tsserverlibrary.d.ts" ) ;
483
+ if (
484
+ needsUpdate ( "./built/local/tsserverlibrary/tsconfig.tsbuildinfo" , [
485
+ "./built/local/tsserverlibrary.d.ts" ,
486
+ "./built/local/tsserverlibrary.internal.d.ts" ,
487
+ ] )
488
+ ) {
489
+ await runDtsBundler (
490
+ "./built/local/tsserverlibrary/tsserverlibrary.d.ts" ,
491
+ "./built/local/tsserverlibrary.d.ts" ,
492
+ ) ;
444
493
}
445
494
} ,
446
495
} ) ;
@@ -573,7 +622,13 @@ export const watchOtherOutputs = task({
573
622
name : "watch-other-outputs" ,
574
623
description : "Builds miscelaneous scripts and documents distributed with the LKG" ,
575
624
hiddenFromTaskList : true ,
576
- dependencies : [ watchCancellationToken , watchTypingsInstaller , watchWatchGuard , generateTypesMap , copyBuiltLocalDiagnosticMessages ] ,
625
+ dependencies : [
626
+ watchCancellationToken ,
627
+ watchTypingsInstaller ,
628
+ watchWatchGuard ,
629
+ generateTypesMap ,
630
+ copyBuiltLocalDiagnosticMessages ,
631
+ ] ,
577
632
} ) ;
578
633
579
634
const buildLocal = task ( {
@@ -584,7 +639,9 @@ const buildLocal = task({
584
639
export const local = task ( {
585
640
name : "local" ,
586
641
description : "Builds the full compiler and services" ,
587
- dependencies : [ localize , tsc , tsserver , services , lssl , otherOutputs , dts ] . concat ( cmdLineOptions . typecheck ? [ buildLocal ] : [ ] ) ,
642
+ dependencies : [ localize , tsc , tsserver , services , lssl , otherOutputs , dts ] . concat (
643
+ cmdLineOptions . typecheck ? [ buildLocal ] : [ ] ,
644
+ ) ,
588
645
} ) ;
589
646
export default local ;
590
647
@@ -656,7 +713,10 @@ export const runTestsAndWatch = task({
656
713
if ( ! token . signaled ) {
657
714
running = true ;
658
715
try {
659
- await runConsoleTests ( testRunner , "mocha-fivemat-progress-reporter" , /*runInParallel*/ false , { token, watching : true } ) ;
716
+ await runConsoleTests ( testRunner , "mocha-fivemat-progress-reporter" , /*runInParallel*/ false , {
717
+ token,
718
+ watching : true ,
719
+ } ) ;
660
720
}
661
721
catch {
662
722
// ignore
@@ -815,7 +875,10 @@ export const updateSublime = task({
815
875
dependencies : [ tsserver ] ,
816
876
run : async ( ) => {
817
877
for ( const file of [ "built/local/tsserver.js" , "built/local/tsserver.js.map" ] ) {
818
- await fs . promises . copyFile ( file , path . resolve ( "../TypeScript-Sublime-Plugin/tsserver/" , path . basename ( file ) ) ) ;
878
+ await fs . promises . copyFile (
879
+ file ,
880
+ path . resolve ( "../TypeScript-Sublime-Plugin/tsserver/" , path . basename ( file ) ) ,
881
+ ) ;
819
882
}
820
883
} ,
821
884
} ) ;
@@ -851,7 +914,10 @@ export const produceLKG = task({
851
914
. concat ( localizationTargets )
852
915
. filter ( f => ! fs . existsSync ( f ) ) ;
853
916
if ( missingFiles . length > 0 ) {
854
- 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" ) ) ;
917
+ throw new Error (
918
+ "Cannot replace the LKG unless all built targets are present in directory 'built/local/'. The following files are missing:\n"
919
+ + missingFiles . join ( "\n" ) ,
920
+ ) ;
855
921
}
856
922
const sizeBefore = getDirSize ( "lib" ) ;
857
923
await exec ( process . execPath , [ "scripts/produceLKG.mjs" ] ) ;
@@ -872,7 +938,13 @@ export const generateSpec = task({
872
938
name : "generate-spec" ,
873
939
description : "Generates a Markdown version of the Language Specification" ,
874
940
hiddenFromTaskList : true ,
875
- run : ( ) => exec ( "cscript" , [ "//nologo" , "scripts/word2md.mjs" , path . resolve ( "doc/TypeScript Language Specification - ARCHIVED.docx" ) , path . resolve ( "doc/spec-ARCHIVED.md" ) ] ) ,
941
+ run : ( ) =>
942
+ exec ( "cscript" , [
943
+ "//nologo" ,
944
+ "scripts/word2md.mjs" ,
945
+ path . resolve ( "doc/TypeScript Language Specification - ARCHIVED.docx" ) ,
946
+ path . resolve ( "doc/spec-ARCHIVED.md" ) ,
947
+ ] ) ,
876
948
} ) ;
877
949
878
950
export const cleanBuilt = task ( {
@@ -890,19 +962,37 @@ export const clean = task({
890
962
export const configureNightly = task ( {
891
963
name : "configure-nightly" ,
892
964
description : "Runs scripts/configurePrerelease.mjs to prepare a build for nightly publishing" ,
893
- run : ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.mjs" , "dev" , "package.json" , "src/compiler/corePublic.ts" ] ) ,
965
+ run : ( ) =>
966
+ exec ( process . execPath , [
967
+ "scripts/configurePrerelease.mjs" ,
968
+ "dev" ,
969
+ "package.json" ,
970
+ "src/compiler/corePublic.ts" ,
971
+ ] ) ,
894
972
} ) ;
895
973
896
974
export const configureInsiders = task ( {
897
975
name : "configure-insiders" ,
898
976
description : "Runs scripts/configurePrerelease.mjs to prepare a build for insiders publishing" ,
899
- run : ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.mjs" , "insiders" , "package.json" , "src/compiler/corePublic.ts" ] ) ,
977
+ run : ( ) =>
978
+ exec ( process . execPath , [
979
+ "scripts/configurePrerelease.mjs" ,
980
+ "insiders" ,
981
+ "package.json" ,
982
+ "src/compiler/corePublic.ts" ,
983
+ ] ) ,
900
984
} ) ;
901
985
902
986
export const configureExperimental = task ( {
903
987
name : "configure-experimental" ,
904
988
description : "Runs scripts/configurePrerelease.mjs to prepare a build for experimental publishing" ,
905
- run : ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.mjs" , "experimental" , "package.json" , "src/compiler/corePublic.ts" ] ) ,
989
+ run : ( ) =>
990
+ exec ( process . execPath , [
991
+ "scripts/configurePrerelease.mjs" ,
992
+ "experimental" ,
993
+ "package.json" ,
994
+ "src/compiler/corePublic.ts" ,
995
+ ] ) ,
906
996
} ) ;
907
997
908
998
export const help = task ( {
0 commit comments