rollup-plugin-esbuild-minify

raw JSON →
1.3.0 verified Mon Apr 27 auth: no javascript

Rollup plugin that minifies or cleans up generated bundles using esbuild. Current stable version 1.3.0 (April 2025), with an active release cadence supporting Rollup 2, 3, and 4. It is simpler than rollup-plugin-esbuild as it focuses solely on minification of bundled JavaScript output, and is faster than @rollup/plugin-terser. Supports configurable log level, log limit, legal comment handling, and a minify toggle to pretty-print instead. Requires Node.js 14.18+ and Rollup ^2 || ^3 || ^4 as a peer dependency.

error Error [ERR_REQUIRE_ESM]: require() of ES Module ... from ... not supported.
cause Using CommonJS require() to import an ESM-only package.
fix
Use import syntax: import { minify } from 'rollup-plugin-esbuild-minify'
error TypeError: Cannot read properties of undefined (reading 'esbuild')
cause The plugin expects esbuild to be installed as a peer dependency, but it's missing.
fix
Install esbuild: npm install esbuild
gotcha Setting minify to false will pretty-print the code, not leave it untouched. This can cause unexpected transformations if you only want to disable minification.
fix To disable minification entirely, set minify: false, but be aware that esbuild still reformats the code.
deprecated Rollup v2 support deprecated since v1.1.1; v1.1.2 added exports field, but Rollup 2 still works.
fix Upgrade to v1.2.0+ or keep using v1.1.x if stuck on Rollup 2.
breaking v1.1.1 dropped support for Rollup <2; v1.1.2 added exports field that may break CJS bundlers that don't understand exports.
fix Use a bundler that supports the exports field, or stay on v1.1.0.
npm install rollup-plugin-esbuild-minify
yarn add rollup-plugin-esbuild-minify
pnpm add rollup-plugin-esbuild-minify

Basic Rollup configuration using the minify plugin with options for logging and legal comments.

import { minify } from 'rollup-plugin-esbuild-minify';

export default {
  input: 'src/index.js',
  output: {
    file: 'dist/bundle.js',
    format: 'iife',
    sourcemap: true
  },
  plugins: [
    minify({
      logLevel: 'warning',
      logLimit: 10,
      legalComments: 'none',
      minify: true
    })
  ]
};