esbuild-webpack-plugin

raw JSON →
1.1.0 verified Fri May 01 auth: no javascript maintenance

A webpack plugin that uses esbuild as a JavaScript minifier. Version 1.1.0 requires webpack 4+ and ships TypeScript type definitions. It provides a faster alternative to TerserPlugin by leveraging esbuild's built-in minification, which can significantly reduce build times especially for large projects. The plugin supports custom esbuild options such as target and minify settings. No other minifier plugin is needed; it replaces TerserPlugin in the webpack minimizer configuration. Development appears active but no recent commits (last commit in 2020).

error TypeError: ESBuildPlugin is not a constructor
cause CommonJS require returns an object with default property, not the class directly.
fix
Use require('esbuild-webpack-plugin').default or import syntax.
error Error: webpack.optimize.minimizer[0] is not a plugin
cause Minimizer expects a plugin instance, but ESBuildPlugin is used incorrectly.
fix
Ensure you instantiate the plugin: new ESBuildPlugin(). Not a reference to the class.
breaking Plugin requires webpack 4+. Does not work with webpack 5.
fix Use an alternative like esbuild-loader or upgrade to a webpack 5 compatible plugin.
gotcha CommonJS require does not return the constructor directly; must use .default
fix Use require('esbuild-webpack-plugin').default or switch to ES import syntax.
deprecated Package has not been updated since 2020. May not work with newer esbuild versions.
fix Consider using esbuild-loader for active maintenance.
npm install esbuild-webpack-plugin
yarn add esbuild-webpack-plugin
pnpm add esbuild-webpack-plugin

Replaces TerserPlugin with esbuild for minification in webpack 4+.

// webpack.config.js
const ESBuildPlugin = require('esbuild-webpack-plugin').default;

module.exports = {
  optimization: {
    minimizer: [
      new ESBuildPlugin(),
    ],
  },
};