@@ -853,6 +853,9 @@ namespace ts {
853853 getConfigFileParsingDiagnostics ( config ) ,
854854 config . projectReferences
855855 ) ;
856+ if ( state . watch ) {
857+ state . builderPrograms . set ( projectPath , program ) ;
858+ }
856859 step ++ ;
857860 }
858861
@@ -982,7 +985,7 @@ namespace ts {
982985 if ( emitResult . emittedFiles && state . writeFileName ) {
983986 emitResult . emittedFiles . forEach ( name => listEmittedFile ( state , config , name ) ) ;
984987 }
985- afterProgramDone ( state , projectPath , program , config ) ;
988+ afterProgramDone ( state , program , config ) ;
986989 step = BuildStep . QueueReferencingProjects ;
987990 return emitResult ;
988991 }
@@ -1023,7 +1026,7 @@ namespace ts {
10231026 newestDeclarationFileContentChangedTime ,
10241027 oldestOutputFileName
10251028 } ) ;
1026- afterProgramDone ( state , projectPath , program , config ) ;
1029+ afterProgramDone ( state , program , config ) ;
10271030 step = BuildStep . QueueReferencingProjects ;
10281031 buildResult = resultFlags ;
10291032 return emitDiagnostics ;
@@ -1269,7 +1272,6 @@ namespace ts {
12691272
12701273 function afterProgramDone < T extends BuilderProgram > (
12711274 state : SolutionBuilderState < T > ,
1272- proj : ResolvedConfigFilePath ,
12731275 program : T | undefined ,
12741276 config : ParsedCommandLine
12751277 ) {
@@ -1278,10 +1280,7 @@ namespace ts {
12781280 if ( state . host . afterProgramEmitAndDiagnostics ) {
12791281 state . host . afterProgramEmitAndDiagnostics ( program ) ;
12801282 }
1281- if ( state . watch ) {
1282- program . releaseProgram ( ) ;
1283- state . builderPrograms . set ( proj , program ) ;
1284- }
1283+ program . releaseProgram ( ) ;
12851284 }
12861285 else if ( state . host . afterEmitBundle ) {
12871286 state . host . afterEmitBundle ( config ) ;
@@ -1304,7 +1303,7 @@ namespace ts {
13041303 // List files if any other build error using program (emit errors already report files)
13051304 state . projectStatus . set ( resolvedPath , { type : UpToDateStatusType . Unbuildable , reason : `${ errorType } errors` } ) ;
13061305 if ( canEmitBuildInfo ) return { buildResult, step : BuildStep . EmitBuildInfo } ;
1307- afterProgramDone ( state , resolvedPath , program , config ) ;
1306+ afterProgramDone ( state , program , config ) ;
13081307 return { buildResult, step : BuildStep . QueueReferencingProjects } ;
13091308 }
13101309
@@ -1809,38 +1808,6 @@ namespace ts {
18091808 ) ) ;
18101809 }
18111810
1812- function isSameFile ( state : SolutionBuilderState , file1 : string , file2 : string ) {
1813- return comparePaths ( file1 , file2 , state . currentDirectory , ! state . host . useCaseSensitiveFileNames ( ) ) === Comparison . EqualTo ;
1814- }
1815-
1816- function isOutputFile ( state : SolutionBuilderState , fileName : string , configFile : ParsedCommandLine ) {
1817- if ( configFile . options . noEmit ) return false ;
1818-
1819- // ts or tsx files are not output
1820- if ( ! fileExtensionIs ( fileName , Extension . Dts ) &&
1821- ( fileExtensionIs ( fileName , Extension . Ts ) || fileExtensionIs ( fileName , Extension . Tsx ) ) ) {
1822- return false ;
1823- }
1824-
1825- // If options have --outFile or --out, check if its that
1826- const out = outFile ( configFile . options ) ;
1827- if ( out && ( isSameFile ( state , fileName , out ) || isSameFile ( state , fileName , removeFileExtension ( out ) + Extension . Dts ) ) ) {
1828- return true ;
1829- }
1830-
1831- // If declarationDir is specified, return if its a file in that directory
1832- if ( configFile . options . declarationDir && containsPath ( configFile . options . declarationDir , fileName , state . currentDirectory , ! state . host . useCaseSensitiveFileNames ( ) ) ) {
1833- return true ;
1834- }
1835-
1836- // If --outDir, check if file is in that directory
1837- if ( configFile . options . outDir && containsPath ( configFile . options . outDir , fileName , state . currentDirectory , ! state . host . useCaseSensitiveFileNames ( ) ) ) {
1838- return true ;
1839- }
1840-
1841- return ! forEach ( configFile . fileNames , inputFile => isSameFile ( state , fileName , inputFile ) ) ;
1842- }
1843-
18441811 function watchWildCardDirectories ( state : SolutionBuilderState , resolved : ResolvedConfigFileName , resolvedPath : ResolvedConfigFilePath , parsed : ParsedCommandLine ) {
18451812 if ( ! state . watch ) return ;
18461813 updateWatchingWildcardDirectories (
@@ -1850,16 +1817,18 @@ namespace ts {
18501817 state . hostWithWatch ,
18511818 dir ,
18521819 fileOrDirectory => {
1853- const fileOrDirectoryPath = toPath ( state , fileOrDirectory ) ;
1854- if ( fileOrDirectoryPath !== toPath ( state , dir ) && hasExtension ( fileOrDirectoryPath ) && ! isSupportedSourceFileName ( fileOrDirectory , parsed . options ) ) {
1855- state . writeLog ( `Project: ${ resolved } Detected file add/remove of non supported extension: ${ fileOrDirectory } ` ) ;
1856- return ;
1857- }
1858-
1859- if ( isOutputFile ( state , fileOrDirectory , parsed ) ) {
1860- state . writeLog ( `${ fileOrDirectory } is output file` ) ;
1861- return ;
1862- }
1820+ if ( isIgnoredFileFromWildCardWatching ( {
1821+ watchedDirPath : toPath ( state , dir ) ,
1822+ fileOrDirectory,
1823+ fileOrDirectoryPath : toPath ( state , fileOrDirectory ) ,
1824+ configFileName : resolved ,
1825+ configFileSpecs : parsed . configFileSpecs ! ,
1826+ currentDirectory : state . currentDirectory ,
1827+ options : parsed . options ,
1828+ program : state . builderPrograms . get ( resolvedPath ) ,
1829+ useCaseSensitiveFileNames : state . parseConfigFileHost . useCaseSensitiveFileNames ,
1830+ writeLog : s => state . writeLog ( s )
1831+ } ) ) return ;
18631832
18641833 invalidateProjectAndScheduleBuilds ( state , resolvedPath , ConfigFileProgramReloadLevel . Partial ) ;
18651834 } ,
0 commit comments