nollup
nollup copied to clipboard
feat: Leading and trailing edge debounce for the file watch
This PR removes the 100ms wait before starting compilation of changed files and instead introduces a leading+trailing edge debounce + an md5 hash.
The previous behavior was to wait until the 100ms after the last time the user saved a file, then it would compile.
Now it will immediately compile upon first save, and if the file is saved again it will debounce in a similar manner to previously. It will also hash the file and check if it has changed since the last compile. The debounce has been increased to 300ms.
Hmmm. Will need to test this one out a bit. There was a few situations I've been trying to address with the delay, and it was the quickest hack I could think of:
-
Sometimes when starting for the first time, hundreds of change events trigger, and it will rebuild hundreds of times and eventually start running.
-
Multiple events can trigger for the one file on a single save and might throw distinct events.
-
If multiple files are saved at the same time (for example, find and replace), could trigger multiple builds.
Might take a bit longer to get back to you on this one!