esbuild
esbuild copied to clipboard
Throwing an error within a plugin does not stop the build
Details
When creating a plugin, throwing an error inside it won't stop the build, it will just cause it to timeout.
How to reproduce
I didn't know how to create a repro on the playground for a plugin, so I am pasting the code of the plugin here:
import { Plugin, PluginBuild } from 'esbuild';
export const moduleExportsPlugin = (): Plugin => ({
name: 'module-exports',
setup(build: PluginBuild) {
build.onEnd(_result => {
throw new Error('module.exports already exists, unknown use case');
});
},
});
Versions
It seems a regression, in v0.16.x It worked fine, since 0.17.x it causes the unexpected behaviour
I can't reproduce this. Here's what I tried:
require('esbuild').build({
plugins: [{
name: 'name',
setup(build) {
build.onEnd(() => {
throw new Error
})
},
}],
}).then(
() => console.log('success'),
() => console.log('failure'),
)
That prints failure on the latest version of esbuild. You can also see this live in the playground.