Delayed FileWatching: Maybe a OutOfProcessNodeJSServiceOptions property?
Greetings,
I have a node application that uses rollup.js to produce esm modules for my dotnet program.
Rollup has a watch feature that executes the compilation of a node project when code changes.
In my case, rollup delete old files and ands new ones (using file chunk hashes - so their different each compilation).
The deleting of old files and writing of new files causes the FileWatcher in OutOfProcessNodeJSService to go crazy for bit.
It rapidly tries to kill processes and spin up new ones.
Can we add a delay or throttle option to the FileWatcher?
We could do with something like webpack's aggregateTimeout option: "Add a delay before rebuilding once the first file changed. This allows webpack to aggregate any other changes made during this time period into one rebuild. Pass a value in milliseconds". Could also consider debouncing.
Would you like to have a go at it? This is the relevant method:
https://github.com/JeringTech/Javascript.NodeJS/blob/5999180f381cb41405f47eb31015be27dfb7facb/src/NodeJS/NodeJSServiceImplementations/OutOfProcess/OutOfProcessNodeJSService.cs#L572-L585
This is what I came up with:
https://github.com/JeringTech/Javascript.NodeJS/pull/182