You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
build({entryPoints: ["./file.ts"],write: false,plugins: [{name: "test",setup(b){b.onEnd((result)=>{// throw new Error("Error description"); // <-- This get a nice log// This is not logged (but correctly fails the build)result.errors.push({pluginName: "test",id: "some-id",text: "Error description",detail: null,notes: [],location: null,});});},},],});
The text was updated successfully, but these errors were encountered:
This isn't really the right way to do this. At this point the build has already pretty much ended. The result object has already been generated. What you are suggesting would require esbuild to re-scan over the result object after every plugin and try to see which errors are things that should be logged. But it's not obvious or clear which ones should be. Just the ones added after the original length of the array (what if a plugin replaces an error instead of adding one)? Just the ones that are different (should this check shallow equality or deep)? This is also pointlessly inefficient.
The best way to fix this to me seems to be to allow onEnd to return errors and warnings like the other APIs:
// These all work:b.onStart(()=>({errors: [{text: 'onStart'}]}))b.onResolve({filter: /./},()=>({errors: [{text: 'onResolve'}]}))b.onLoad({filter: /./},()=>({errors: [{text: 'onLoad'}]}))// This currently doesn't work:b.onEnd(()=>({errors: [{text: 'onEnd'}]}))
This is a breaking change because it would mean breaking the Go API, so it would have to wait for a breaking change release.
Repro:
The text was updated successfully, but these errors were encountered: