Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch mode rebuilds cause touch/update to every output file #2104

Closed
maranomynet opened this issue Mar 15, 2022 · 3 comments · Fixed by #2816
Closed

Watch mode rebuilds cause touch/update to every output file #2104

maranomynet opened this issue Mar 15, 2022 · 3 comments · Fixed by #2816

Comments

@maranomynet
Copy link

maranomynet commented Mar 15, 2022

Hi. Is there a way to configure Esbuild in watch mode to only touch/rewrite the bundles (output files) that actually changed with the rebuild.

I'd even be willing to sacrifice a bit of speed.

Use case: I'm running a separate watch task to monitor the contents of the outdir, and perform further actions on the files that changed.

The fact that every output file fires a change-event on every incremental rebuild is making things very busy+slow.

I've done my best to hunt for answers, but to no avail. Any suggestions?

@maranomynet maranomynet changed the title Watch mode rebuilds do touch/update every output file Watch mode rebuilds cause touch/update to every output file Mar 15, 2022
@evanw
Copy link
Owner

evanw commented Mar 15, 2022

This is intentional. After running esbuild, the build outputs should always be newer than the build inputs. Not doing this means build results could appear to be stale, which would be a bug in esbuild.

If you want to change this behavior, you could use write: false and then only write out the files that have changed.

@maranomynet
Copy link
Author

maranomynet commented Mar 15, 2022

Thanks, for your answer.

This would be a nice feature though (as an option), and more in line with how e.g. Rollup does partial rebuild.

Working with result.outputFiles requires maintaining one's own in-memory cache of build results to compare against, and messing with fs.exists, fs.mkdir, etc.

@maranomynet
Copy link
Author

I'm still thinking about your claim that all built files should at all times be newer than the source files.

I agree this makes perfect sense after a fresh build.

But I'm not sure I agree this holds in watch mode when incremental builds are pretty much the expected outcome — at least in the use-case outlined above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants