esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

WatchMode.onRebuild not called if initial build failed

Open Vendicated opened this issue 3 years ago • 3 comments

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

Vendicated avatar Aug 29 '22 16:08 Vendicated

https://github.com/Vendicated/EsbuildRepro

Vendicated avatar Aug 29 '22 16:08 Vendicated

https://github.com/evanw/esbuild/pull/2282

susiwen8 avatar Aug 29 '22 17:08 susiwen8

Yes, this is a known issue. I'm planning to redesign this API to fix this error.

evanw avatar Aug 29 '22 22:08 evanw