@@ -326,6 +326,7 @@ function getCompilerOptionsOfBuildOptions(buildOptions: BuildOptions): CompilerO
326326 commonOptionsWithBuild . forEach ( option => {
327327 if ( hasProperty ( buildOptions , option . name ) ) result [ option . name ] = buildOptions [ option . name ] ;
328328 } ) ;
329+ result . tscBuild = true ;
329330 return result ;
330331}
331332
@@ -1460,7 +1461,7 @@ function buildErrors<T extends BuilderProgram>(
14601461 errorType : string ,
14611462) {
14621463 // Since buildinfo has changeset and diagnostics when doing multi file emit, only --out cannot emit buildinfo if it has errors
1463- const canEmitBuildInfo = program && ! program . getCompilerOptions ( ) . outFile ;
1464+ const canEmitBuildInfo = program && ! program . getCompilerOptions ( ) . outFile && isIncrementalCompilation ( program . getCompilerOptions ( ) ) ;
14641465
14651466 reportAndStoreErrors ( state , resolvedPath , diagnostics ) ;
14661467 state . projectStatus . set ( resolvedPath , { type : UpToDateStatusType . Unbuildable , reason : `${ errorType } errors` } ) ;
@@ -1652,6 +1653,7 @@ function getUpToDateStatusWorker<T extends BuilderProgram>(state: SolutionBuilde
16521653 let buildInfoTime : Date | undefined ;
16531654 let buildInfoProgram : ProgramBuildInfo | undefined ;
16541655 let buildInfoVersionMap : ReturnType < typeof getBuildInfoFileVersionMap > | undefined ;
1656+ const isIncremental = isIncrementalCompilation ( project . options ) ;
16551657 if ( buildInfoPath ) {
16561658 const buildInfoCacheEntry = getBuildInfoCacheEntry ( state , buildInfoPath , resolvedPath ) ;
16571659 buildInfoTime = buildInfoCacheEntry ?. modifiedTime || ts_getModifiedTime ( host , buildInfoPath ) ;
@@ -1677,7 +1679,7 @@ function getUpToDateStatusWorker<T extends BuilderProgram>(state: SolutionBuilde
16771679 fileName : buildInfoPath ,
16781680 } ;
16791681 }
1680- if ( buildInfo . program && buildInfo . version !== version ) {
1682+ if ( ( buildInfo . program || ! isIncremental ) && buildInfo . version !== version ) {
16811683 return {
16821684 type : UpToDateStatusType . TsVersionOutputOfDate ,
16831685 version : buildInfo . version ,
@@ -1735,7 +1737,7 @@ function getUpToDateStatusWorker<T extends BuilderProgram>(state: SolutionBuilde
17351737
17361738 const inputPath = buildInfoProgram ? toPath ( state , inputFile ) : undefined ;
17371739 // If an buildInfo is older than the newest input, we can stop checking
1738- if ( buildInfoTime && buildInfoTime < inputTime ) {
1740+ if ( isIncremental && buildInfoTime && buildInfoTime < inputTime ) {
17391741 let version : string | undefined ;
17401742 let currentVersion : string | undefined ;
17411743 if ( buildInfoProgram ) {
@@ -1783,11 +1785,12 @@ function getUpToDateStatusWorker<T extends BuilderProgram>(state: SolutionBuilde
17831785
17841786 // Now see if all outputs are newer than the newest input
17851787 // Dont check output timestamps if we have buildinfo telling us output is uptodate
1786- if ( ! buildInfoPath ) {
1788+ if ( ! isIncremental ) {
17871789 // Collect the expected outputs of this project
17881790 const outputs = getAllProjectOutputs ( project , ! host . useCaseSensitiveFileNames ( ) ) ;
17891791 const outputTimeStampMap = getOutputTimeStampMap ( state , resolvedPath ) ;
17901792 for ( const output of outputs ) {
1793+ if ( output === buildInfoPath ) continue ;
17911794 const path = toPath ( state , output ) ;
17921795 // Output is missing; can stop checking
17931796 let outputTime = outputTimeStampMap ?. get ( path ) ;
@@ -1921,7 +1924,8 @@ function updateOutputTimestampsWorker<T extends BuilderProgram>(
19211924 if ( proj . options . noEmit ) return ;
19221925 let now : Date | undefined ;
19231926 const buildInfoPath = getTsBuildInfoEmitOutputFilePath ( proj . options ) ;
1924- if ( buildInfoPath ) {
1927+ const isIncremental = isIncrementalCompilation ( proj . options ) ;
1928+ if ( buildInfoPath && isIncremental ) {
19251929 // For incremental projects, only buildinfo needs to be upto date with timestamp check
19261930 // as we dont check output files for up-to-date ness
19271931 if ( ! skipOutputs ?. has ( toPath ( state , buildInfoPath ) ) ) {
@@ -1947,8 +1951,9 @@ function updateOutputTimestampsWorker<T extends BuilderProgram>(
19471951 reportStatus ( state , verboseMessage , proj . options . configFilePath ! ) ;
19481952 }
19491953 host . setModifiedTime ( file , now ||= getCurrentTime ( state . host ) ) ;
1954+ if ( file === buildInfoPath ) getBuildInfoCacheEntry ( state , buildInfoPath , projectPath ) ! . modifiedTime = now ;
19501955 // Store output timestamps in a map because non incremental build will need to check them to determine up-to-dateness
1951- if ( outputTimeStampMap ) {
1956+ else if ( outputTimeStampMap ) {
19521957 outputTimeStampMap . set ( path , now ) ;
19531958 modifiedOutputs ! . add ( path ) ;
19541959 }
0 commit comments