@@ -2,6 +2,8 @@ import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginSt
22import chokidar , { FSWatcher } from 'chokidar' ;
33import { extname } from 'path' ;
44import { Watcher , WatchFileSystem , WatchFileSystemOptions } from './WatchFileSystem' ;
5+ import { Compiler } from 'webpack' ;
6+ import { clearFilesChange , updateFilesChange } from '../reporter' ;
57
68const IGNORED_DIRS = [ 'node_modules' , '.git' , '.yarn' , '.pnp' ] ;
79
@@ -13,17 +15,13 @@ class InclusiveNodeWatchFileSystem implements WatchFileSystem {
1315 get watcher ( ) {
1416 return this . watchFileSystem . watcher || this . watchFileSystem . wfs ?. watcher ;
1517 }
16-
17- readonly changedFiles : Set < string > ;
18- readonly removedFiles : Set < string > ;
1918 readonly dirsWatchers : Map < string , FSWatcher | undefined > ;
2019
2120 constructor (
2221 private watchFileSystem : WatchFileSystem ,
22+ private compiler : Compiler ,
2323 private pluginState : ForkTsCheckerWebpackPluginState
2424 ) {
25- this . changedFiles = new Set ( ) ;
26- this . removedFiles = new Set ( ) ;
2725 this . dirsWatchers = new Map ( ) ;
2826 }
2927
@@ -38,8 +36,7 @@ class InclusiveNodeWatchFileSystem implements WatchFileSystem {
3836 callback ?: Function ,
3937 callbackUndelayed ?: Function
4038 ) : Watcher {
41- this . changedFiles . clear ( ) ;
42- this . removedFiles . clear ( ) ;
39+ clearFilesChange ( this . compiler ) ;
4340
4441 // use standard watch file system for files and missing
4542 const standardWatcher = this . watchFileSystem . watch (
@@ -54,14 +51,12 @@ class InclusiveNodeWatchFileSystem implements WatchFileSystem {
5451
5552 this . watcher ?. on ( 'change' , ( file : string ) => {
5653 if ( typeof file === 'string' && ! isIgnored ( file ) ) {
57- this . changedFiles . add ( file ) ;
58- this . removedFiles . delete ( file ) ;
54+ updateFilesChange ( this . compiler , { changedFiles : [ file ] } ) ;
5955 }
6056 } ) ;
6157 this . watcher ?. on ( 'remove' , ( file : string ) => {
6258 if ( typeof file === 'string' && ! isIgnored ( file ) ) {
63- this . removedFiles . add ( file ) ;
64- this . changedFiles . delete ( file ) ;
59+ updateFilesChange ( this . compiler , { deletedFiles : [ file ] } ) ;
6560 }
6661 } ) ;
6762
@@ -105,8 +100,7 @@ class InclusiveNodeWatchFileSystem implements WatchFileSystem {
105100 return ;
106101 }
107102
108- this . changedFiles . add ( file ) ;
109- this . removedFiles . delete ( file ) ;
103+ updateFilesChange ( this . compiler , { changedFiles : [ file ] } ) ;
110104
111105 const mtime = stats ?. mtimeMs || stats ?. ctimeMs || 1 ;
112106
@@ -124,8 +118,7 @@ class InclusiveNodeWatchFileSystem implements WatchFileSystem {
124118 return ;
125119 }
126120
127- this . removedFiles . add ( file ) ;
128- this . changedFiles . delete ( file ) ;
121+ updateFilesChange ( this . compiler , { deletedFiles : [ file ] } ) ;
129122
130123 this . watcher ?. _onRemove ( dirToWatch , file , 'rename' ) ;
131124 } ) ;
@@ -137,8 +130,7 @@ class InclusiveNodeWatchFileSystem implements WatchFileSystem {
137130 return {
138131 ...standardWatcher ,
139132 close : ( ) => {
140- this . changedFiles . clear ( ) ;
141- this . removedFiles . clear ( ) ;
133+ clearFilesChange ( this . compiler ) ;
142134
143135 if ( standardWatcher ) {
144136 standardWatcher . close ( ) ;
0 commit comments