esbuild
esbuild copied to clipboard
WatchMode.onRebuild not called if initial build failed
If you have multiple esbuild watchers running and one of them fails, that watcher will stop calling onRebuild even though the watcher is still running and rebuilding that file
Build Script
import esbuild from "esbuild";
const watch = {
onRebuild: (err) => {
if (err) console.error("Build Error", err.message);
else console.log("Rebuilt!");
}
};
await Promise.all([
esbuild.build({
entryPoints: ["index.js"],
outfile: "out.js",
watch
}), esbuild.build({
entryPoints: ["other.js"],
outfile: "otherOut.js",
watch
})
]).catch(() => 0);
if index.js has an error initially and you then change index.js to fix the error and add something new, esbuild will rebuild it but not print the "Rebuilt". It works as expected if the initial build succeeds
https://user-images.githubusercontent.com/45497981/187244627-98664e4a-fee6-41dc-8101-f001ccf5dbfe.mp4
https://github.com/Vendicated/EsbuildRepro
https://github.com/evanw/esbuild/pull/2282
Yes, this is a known issue. I'm planning to redesign this API to fix this error.