Javascript.NodeJS icon indicating copy to clipboard operation
Javascript.NodeJS copied to clipboard

Delayed FileWatching: Maybe a OutOfProcessNodeJSServiceOptions property?

Open Zettersten opened this issue 2 years ago • 2 comments

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?

Zettersten avatar Sep 29 '23 18:09 Zettersten

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

JeremyTCD avatar Oct 02 '23 10:10 JeremyTCD

This is what I came up with:

https://github.com/JeringTech/Javascript.NodeJS/pull/182

Zettersten avatar Oct 11 '23 14:10 Zettersten