Skip to content

Feature request: debounce delay in watch mode #4178

@olivier-thatch

Description

@olivier-thatch

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions