@@ -2,6 +2,8 @@ import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginSt
2
2
import chokidar , { FSWatcher } from 'chokidar' ;
3
3
import { extname } from 'path' ;
4
4
import { Watcher , WatchFileSystem , WatchFileSystemOptions } from './WatchFileSystem' ;
5
+ import { Compiler } from 'webpack' ;
6
+ import { clearFilesChange , updateFilesChange } from '../reporter' ;
5
7
6
8
const IGNORED_DIRS = [ 'node_modules' , '.git' , '.yarn' , '.pnp' ] ;
7
9
@@ -13,17 +15,13 @@ class InclusiveNodeWatchFileSystem implements WatchFileSystem {
13
15
get watcher ( ) {
14
16
return this . watchFileSystem . watcher || this . watchFileSystem . wfs ?. watcher ;
15
17
}
16
-
17
- readonly changedFiles : Set < string > ;
18
- readonly removedFiles : Set < string > ;
19
18
readonly dirsWatchers : Map < string , FSWatcher | undefined > ;
20
19
21
20
constructor (
22
21
private watchFileSystem : WatchFileSystem ,
22
+ private compiler : Compiler ,
23
23
private pluginState : ForkTsCheckerWebpackPluginState
24
24
) {
25
- this . changedFiles = new Set ( ) ;
26
- this . removedFiles = new Set ( ) ;
27
25
this . dirsWatchers = new Map ( ) ;
28
26
}
29
27
@@ -38,8 +36,7 @@ class InclusiveNodeWatchFileSystem implements WatchFileSystem {
38
36
callback ?: Function ,
39
37
callbackUndelayed ?: Function
40
38
) : Watcher {
41
- this . changedFiles . clear ( ) ;
42
- this . removedFiles . clear ( ) ;
39
+ clearFilesChange ( this . compiler ) ;
43
40
44
41
// use standard watch file system for files and missing
45
42
const standardWatcher = this . watchFileSystem . watch (
@@ -54,14 +51,12 @@ class InclusiveNodeWatchFileSystem implements WatchFileSystem {
54
51
55
52
this . watcher ?. on ( 'change' , ( file : string ) => {
56
53
if ( typeof file === 'string' && ! isIgnored ( file ) ) {
57
- this . changedFiles . add ( file ) ;
58
- this . removedFiles . delete ( file ) ;
54
+ updateFilesChange ( this . compiler , { changedFiles : [ file ] } ) ;
59
55
}
60
56
} ) ;
61
57
this . watcher ?. on ( 'remove' , ( file : string ) => {
62
58
if ( typeof file === 'string' && ! isIgnored ( file ) ) {
63
- this . removedFiles . add ( file ) ;
64
- this . changedFiles . delete ( file ) ;
59
+ updateFilesChange ( this . compiler , { deletedFiles : [ file ] } ) ;
65
60
}
66
61
} ) ;
67
62
@@ -105,8 +100,7 @@ class InclusiveNodeWatchFileSystem implements WatchFileSystem {
105
100
return ;
106
101
}
107
102
108
- this . changedFiles . add ( file ) ;
109
- this . removedFiles . delete ( file ) ;
103
+ updateFilesChange ( this . compiler , { changedFiles : [ file ] } ) ;
110
104
111
105
const mtime = stats ?. mtimeMs || stats ?. ctimeMs || 1 ;
112
106
@@ -124,8 +118,7 @@ class InclusiveNodeWatchFileSystem implements WatchFileSystem {
124
118
return ;
125
119
}
126
120
127
- this . removedFiles . add ( file ) ;
128
- this . changedFiles . delete ( file ) ;
121
+ updateFilesChange ( this . compiler , { deletedFiles : [ file ] } ) ;
129
122
130
123
this . watcher ?. _onRemove ( dirToWatch , file , 'rename' ) ;
131
124
} ) ;
@@ -137,8 +130,7 @@ class InclusiveNodeWatchFileSystem implements WatchFileSystem {
137
130
return {
138
131
...standardWatcher ,
139
132
close : ( ) => {
140
- this . changedFiles . clear ( ) ;
141
- this . removedFiles . clear ( ) ;
133
+ clearFilesChange ( this . compiler ) ;
142
134
143
135
if ( standardWatcher ) {
144
136
standardWatcher . close ( ) ;
0 commit comments