@@ -6,7 +6,7 @@ import { task } from "hereby";
66import _glob from "glob" ;
77import util from "util" ;
88import 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" ;
1010import { runConsoleTests , refBaseline , localBaseline , refRwcBaseline , localRwcBaseline } from "./scripts/build/tests.mjs" ;
1111import { buildProject as realBuildProject , cleanProject , watchProject } from "./scripts/build/projects.mjs" ;
1212import { localizationDirectories } from "./scripts/build/localization.mjs" ;
@@ -81,22 +81,18 @@ export const generateLibs = task({
8181 description : "Builds the library targets" ,
8282 run : async ( ) => {
8383 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" ) ;
9993 }
94+
95+ await fs . promises . writeFile ( lib . target , output ) ;
10096 }
10197 } ,
10298} ) ;
@@ -110,9 +106,7 @@ export const generateDiagnostics = task({
110106 name : "generate-diagnostics" ,
111107 description : "Generates a diagnostic file in TypeScript based on an input JSON file" ,
112108 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 ] ) ;
116110 }
117111} ) ;
118112
@@ -410,7 +404,11 @@ export const dtsServices = task({
410404 name : "dts-services" ,
411405 description : "Bundles typescript.d.ts" ,
412406 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+ } ,
414412} ) ;
415413
416414
@@ -464,7 +462,11 @@ export const dtsLssl = task({
464462 name : "dts-lssl" ,
465463 description : "Bundles tsserverlibrary.d.ts" ,
466464 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+ }
468470} ) ;
469471
470472export const dts = task ( {
@@ -560,11 +562,9 @@ export const generateTypesMap = task({
560562 run : async ( ) => {
561563 const source = "src/server/typesMap.json" ;
562564 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 ) ;
568568 }
569569} ) ;
570570
@@ -577,11 +577,9 @@ const copyBuiltLocalDiagnosticMessages = task({
577577 name : "copy-built-local-diagnostic-messages" ,
578578 dependencies : [ generateDiagnostics ] ,
579579 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 ) ;
585583 }
586584} ) ;
587585
0 commit comments