@@ -6,7 +6,7 @@ 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 , needsUpdate , getDiffTool , getDirSize , memoize } from "./scripts/build/utils.mjs" ;
9
+ import { exec , readJson , getDiffTool , getDirSize , memoize , needsUpdate } from "./scripts/build/utils.mjs" ;
10
10
import { runConsoleTests , refBaseline , localBaseline , refRwcBaseline , localRwcBaseline } from "./scripts/build/tests.mjs" ;
11
11
import { buildProject as realBuildProject , cleanProject , watchProject } from "./scripts/build/projects.mjs" ;
12
12
import { localizationDirectories } from "./scripts/build/localization.mjs" ;
@@ -81,22 +81,18 @@ export const generateLibs = task({
81
81
description : "Builds the library targets" ,
82
82
run : async ( ) => {
83
83
await fs . promises . mkdir ( "./built/local" , { recursive : true } ) ;
84
- const allSources = libs ( ) . flatMap ( ( lib ) => lib . sources ) ;
85
- const allTargets = libs ( ) . flatMap ( ( lib ) => lib . target ) ;
86
- if ( needsUpdate ( [ copyrightFilename , ...allSources ] , allTargets ) ) {
87
- for ( const lib of libs ( ) ) {
88
- let output = await copyright ( ) ;
89
-
90
- for ( const source of lib . sources ) {
91
- const contents = await fs . promises . readFile ( source , "utf-8" ) ;
92
- // TODO(jakebailey): "\n\n" is for compatibility with our current tests; our test baselines
93
- // are sensitive to the positions of things in the lib files. Eventually remove this,
94
- // or remove lib.d.ts line numbers from our baselines.
95
- output += "\n\n" + contents . replace ( / \r \n / g, "\n" ) ;
96
- }
97
-
98
- await fs . promises . writeFile ( lib . target , output ) ;
84
+ for ( const lib of libs ( ) ) {
85
+ let output = await copyright ( ) ;
86
+
87
+ for ( const source of lib . sources ) {
88
+ const contents = await fs . promises . readFile ( source , "utf-8" ) ;
89
+ // TODO(jakebailey): "\n\n" is for compatibility with our current tests; our test baselines
90
+ // are sensitive to the positions of things in the lib files. Eventually remove this,
91
+ // or remove lib.d.ts line numbers from our baselines.
92
+ output += "\n\n" + contents . replace ( / \r \n / g, "\n" ) ;
99
93
}
94
+
95
+ await fs . promises . writeFile ( lib . target , output ) ;
100
96
}
101
97
} ,
102
98
} ) ;
@@ -110,9 +106,7 @@ export const generateDiagnostics = task({
110
106
name : "generate-diagnostics" ,
111
107
description : "Generates a diagnostic file in TypeScript based on an input JSON file" ,
112
108
run : async ( ) => {
113
- if ( needsUpdate ( diagnosticMessagesJson , [ diagnosticMessagesGeneratedJson , diagnosticInformationMapTs ] ) ) {
114
- await exec ( process . execPath , [ "scripts/processDiagnosticMessages.mjs" , diagnosticMessagesJson ] ) ;
115
- }
109
+ await exec ( process . execPath , [ "scripts/processDiagnosticMessages.mjs" , diagnosticMessagesJson ] ) ;
116
110
}
117
111
} ) ;
118
112
@@ -410,7 +404,11 @@ export const dtsServices = task({
410
404
name : "dts-services" ,
411
405
description : "Bundles typescript.d.ts" ,
412
406
dependencies : [ buildServices ] ,
413
- run : ( ) => runDtsBundler ( "./built/local/typescript/typescript.d.ts" , "./built/local/typescript.d.ts" ) ,
407
+ run : async ( ) => {
408
+ if ( needsUpdate ( "./built/local/typescript/tsconfig.tsbuildinfo" , [ "./built/local/typescript.d.ts" , "./built/local/typescript.internal.d.ts" ] ) ) {
409
+ runDtsBundler ( "./built/local/typescript/typescript.d.ts" , "./built/local/typescript.d.ts" ) ;
410
+ }
411
+ } ,
414
412
} ) ;
415
413
416
414
@@ -464,7 +462,11 @@ export const dtsLssl = task({
464
462
name : "dts-lssl" ,
465
463
description : "Bundles tsserverlibrary.d.ts" ,
466
464
dependencies : [ buildLssl ] ,
467
- run : ( ) => runDtsBundler ( "./built/local/tsserverlibrary/tsserverlibrary.d.ts" , "./built/local/tsserverlibrary.d.ts" )
465
+ run : async ( ) => {
466
+ if ( needsUpdate ( "./built/local/tsserverlibrary/tsconfig.tsbuildinfo" , [ "./built/local/tsserverlibrary.d.ts" , "./built/local/tsserverlibrary.internal.d.ts" ] ) ) {
467
+ await runDtsBundler ( "./built/local/tsserverlibrary/tsserverlibrary.d.ts" , "./built/local/tsserverlibrary.d.ts" ) ;
468
+ }
469
+ }
468
470
} ) ;
469
471
470
472
export const dts = task ( {
@@ -560,11 +562,9 @@ export const generateTypesMap = task({
560
562
run : async ( ) => {
561
563
const source = "src/server/typesMap.json" ;
562
564
const target = "built/local/typesMap.json" ;
563
- if ( needsUpdate ( source , target ) ) {
564
- const contents = await fs . promises . readFile ( source , "utf-8" ) ;
565
- JSON . parse ( contents ) ;
566
- await fs . promises . writeFile ( target , contents ) ;
567
- }
565
+ const contents = await fs . promises . readFile ( source , "utf-8" ) ;
566
+ JSON . parse ( contents ) ; // Validates that the JSON parses.
567
+ await fs . promises . writeFile ( target , contents ) ;
568
568
}
569
569
} ) ;
570
570
@@ -577,11 +577,9 @@ const copyBuiltLocalDiagnosticMessages = task({
577
577
name : "copy-built-local-diagnostic-messages" ,
578
578
dependencies : [ generateDiagnostics ] ,
579
579
run : async ( ) => {
580
- if ( needsUpdate ( diagnosticMessagesGeneratedJson , builtLocalDiagnosticMessagesGeneratedJson ) ) {
581
- const contents = await fs . promises . readFile ( diagnosticMessagesGeneratedJson , "utf-8" ) ;
582
- JSON . parse ( contents ) ;
583
- await fs . promises . writeFile ( builtLocalDiagnosticMessagesGeneratedJson , contents ) ;
584
- }
580
+ const contents = await fs . promises . readFile ( diagnosticMessagesGeneratedJson , "utf-8" ) ;
581
+ JSON . parse ( contents ) ; // Validates that the JSON parses.
582
+ await fs . promises . writeFile ( builtLocalDiagnosticMessagesGeneratedJson , contents ) ;
585
583
}
586
584
} ) ;
587
585
0 commit comments