Skip to content
New issue

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

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

Already on GitHub? # to your account

--watch should delete destination files on build errors #3643

Closed
marcandre opened this issue Feb 13, 2024 · 4 comments
Closed

--watch should delete destination files on build errors #3643

marcandre opened this issue Feb 13, 2024 · 4 comments
Labels

Comments

@marcandre
Copy link

marcandre commented Feb 13, 2024

tldnr; esbuild --watch should delete existing destination files in case of build errors, or at minimum have an option to do so.

esbuild --watch is a nice and simple way to insure that changes in source files are reflected in a destination file.

Unfortunately, if an error is introduced in a source, an error is logged and the destination file is kept intact, reflecting the sources as they were the last time the build succeeded.

This breaks the contract of reflecting the changes in the sources in the destinations file.

Keeping the destination unchanged makes it much harder for other tools to detect errors. The CLI doesn't offer any way (that I know of) to do anything interesting besides the error logging (and parsing the error log is a terrible option).

One is forced to either use --serve and change the way the built assets are accessed (I haven't verified, but I assume the server returns an error code in that case), or else change the build pipeline entirely just so a plugin can be used to do something interesting.

The ideal behaviour IMO should be to delete the destination file. If this is deemed unacceptable (e.g. for compatibility reasons), then an option --delete-on-error or similar would be a good solution.

Thank you for esbuild

@evanw
Copy link
Owner

evanw commented Feb 20, 2024

I can try to do this but I imagine it could trip people up if it's unexpected. So it seems like a good idea to wait until the next breaking change release to make this change.

@evanw evanw added the breaking label Feb 20, 2024
@marcandre
Copy link
Author

Awesome, I'm glad you are receptive to the idea.

How frequent are these breaking change releases approximately?

@evanw
Copy link
Owner

evanw commented Feb 20, 2024

You can see for yourself here: https://github.com/evanw/esbuild/releases. I have no set schedule around breaking change releases and make no commitment to when they will happen. I try to batch breaking changes together to avoid disrupting people too much by doing breaking changes all the time. The breaking label helps me keep track of these for the next batch of them.

@marcandre
Copy link
Author

Great, thank you! ❤️

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

No branches or pull requests

2 participants