-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
When esbuild is running in watch mode and it detects a change, it immediately triggers a new build. If many files are being updated in a very short timeframe, this can cause build errors (if e.g. some files are missing). The build will eventually succeed, but the build errors are noisy.
For example, in our case we use orval to generate a TypeScript client library for our backend API. When orval is invoked, it deletes all of the existing client library files and regenerates them from scratch. esbuild picks up on the first event and triggers a rebuild while orval is not done regenerating the library, which causes the build to fail. Once orval is done, esbuild runs again and the build succeeds.
This could be solved by adding a debounce delay configuration option for esbuild's watch mode. Something like this:
await ctx.watch({ debounce: 1000 })With this option, when a file event occurs, esbuild would wait for the specified delay before triggering a new build, and the wait period would be reset to the full debounce delay if any other file event occurs.