-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 behavior on failed first builds #1037
Comments
Just got a chance to look into this. It looks like it works with the CLI and Go APIs but not with the JavaScript API because the JavaScript API is designed to throw an exception when there are build errors. I'll need to think about how to solve this from an API design perspective. |
Some of the different challenges around handling the state transitions are described here: #814 (comment). |
There's an interesting problem with doing this: #1063. If the initial build fails due to a plugin throwing an error, esbuild doesn't necessarily have enough information to know what to watch. In that case allowing watch mode to progress if the initial build fails could potentially leave watch mode in a broken state. Just linking these two issues because they seem related. |
Because of evanw/esbuild#1037, we can't recover dev if esbuild fails on first run. The workaround is to end the process if it does so, until we have a better fix. Reported in #731
Because of evanw/esbuild#1037, we can't recover dev if esbuild fails on first run. The workaround is to end the process if it does so, until we have a better fix. Reported in #731
I used EDIT: Applying this patch with patch-package seems to do the trick for my use case! diff --git a/node_modules/esbuild/lib/main.js b/node_modules/esbuild/lib/main.js
index 094cde7..e754aa1 100644
--- a/node_modules/esbuild/lib/main.js
+++ b/node_modules/esbuild/lib/main.js
@@ -1245,7 +1245,7 @@ function createChannel(streamIn) {
};
copyResponseToResult(response, result);
runOnEndCallbacks(result, logPluginError, () => {
- if (result.errors.length > 0) {
+ if (result.errors.length > 0 && !watch) {
return callback2(failureErrorWithLog("Build failed", result.errors, result.warnings), null);
}
if (response.rebuild) { |
I've noticed that watch mode only works if the first build is successful. Is this intentional?
My use case is a large repository with many apps and a single development server that lazily builds these apps in watch mode as they are requested. The server also establishes a web socket connection so the apps reload on successful rebuilds or render an error overlay if the build failed. Ideally the server could rely on esbuild's watch mode completely to know when to send these web socket messages, but currently I would have to set up my own watcher and retry starting esbuild in watch mode in the case where the build fails on the first try.
The text was updated successfully, but these errors were encountered: