@@ -16,6 +16,9 @@ const SUPPORTS_RECURSIVE_WATCHING = IS_OSX || IS_WIN;
16
16
const watcherLimit =
17
17
+ process . env . WATCHPACK_WATCHER_LIMIT || ( IS_OSX ? 2000 : 10000 ) ;
18
18
19
+ const recursiveWatcherLogging = ! ! process . env
20
+ . WATCHPACK_RECURSIVE_WATCHER_LOGGING ;
21
+
19
22
let isBatch = false ;
20
23
let watcherCount = 0 ;
21
24
@@ -93,12 +96,28 @@ class RecursiveWatcher {
93
96
this . watcher = watcher ;
94
97
watcher . on ( "change" , ( type , filename ) => {
95
98
if ( ! filename ) {
99
+ if ( recursiveWatcherLogging ) {
100
+ process . stderr . write (
101
+ `[watchpack] dispatch ${ type } event in recursive watcher (${
102
+ this . rootPath
103
+ } ) to all watchers\n`
104
+ ) ;
105
+ }
96
106
for ( const w of this . mapWatcherToPath . keys ( ) ) {
97
107
w . emit ( "change" , type ) ;
98
108
}
99
109
} else {
100
110
const dir = path . dirname ( filename ) ;
101
111
const watchers = this . mapPathToWatchers . get ( dir ) ;
112
+ if ( recursiveWatcherLogging ) {
113
+ process . stderr . write (
114
+ `[watchpack] dispatch ${ type } event in recursive watcher (${
115
+ this . rootPath
116
+ } ) for '${ filename } ' to ${
117
+ watchers ? watchers . size : 0
118
+ } watchers\n`
119
+ ) ;
120
+ }
102
121
if ( watchers === undefined ) return ;
103
122
for ( const w of watchers ) {
104
123
w . emit ( "change" , type , path . basename ( filename ) ) ;
@@ -118,6 +137,11 @@ class RecursiveWatcher {
118
137
} ) ;
119
138
}
120
139
watcherCount ++ ;
140
+ if ( recursiveWatcherLogging ) {
141
+ process . stderr . write (
142
+ `[watchpack] created recursive watcher at ${ rootPath } \n`
143
+ ) ;
144
+ }
121
145
}
122
146
123
147
add ( filePath , watcher ) {
@@ -147,6 +171,11 @@ class RecursiveWatcher {
147
171
recursiveWatchers . delete ( this . rootPath ) ;
148
172
watcherCount -- ;
149
173
if ( this . watcher ) this . watcher . close ( ) ;
174
+ if ( recursiveWatcherLogging ) {
175
+ process . stderr . write (
176
+ `[watchpack] closed recursive watcher at ${ this . rootPath } \n`
177
+ ) ;
178
+ }
150
179
}
151
180
}
152
181
0 commit comments