Registry / devops / rollup-plugin-esbuild

rollup-plugin-esbuild

JSON →
library6.2.1jsnpmunverified

A Rollup plugin that uses esbuild for fast TypeScript/ESNext compilation and minification, replacing rollup-plugin-typescript2, @rollup/plugin-typescript, and rollup-plugin-terser. Current stable version is 6.2.1 (released Feb 2025), with active maintenance and releases every few months. Key differentiators: full esbuild integration (including JSX, define, loaders), built-in optimizeDeps for pre-bundling, standalone minify plugin, and support for Rollup 1-4. Requires esbuild >=0.18.0 and Rollup ^1.20.0 || ^2.0.0 || ^3.0.0 || ^4.0.0. Ships TypeScript types.

npm install rollup-plugin-esbuild
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-ESBU
R
rollup-plugin-esbuild
devopsjavascriptv6.2.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export
✓ import esbuild from 'rollup-plugin-esbuild'
✗ const esbuild = require('rollup-plugin-esbuild')
Default export is ESM-only. For CommonJS use dynamic import or bundler transform.
minify
✓ import { minify } from 'rollup-plugin-esbuild'
✗ const { minify } = require('rollup-plugin-esbuild')
Named export for standalone minify plugin. Also ESM-only.
type definition
✓ import type { Options } from 'rollup-plugin-esbuild'
✗ import { Options } from 'rollup-plugin-esbuild'
Use 'import type' for TypeScript type-only imports to avoid emitting at runtime.

Shows how to use the esbuild plugin in a Rollup config with TypeScript, minification, define, and custom loaders.

// rollup.config.js import esbuild from 'rollup-plugin-esbuild'; export default { input: 'src/index.ts', output: { file: 'dist/bundle.js', format: 'esm', }, plugins: [ esbuild({ target: 'es2020', minify: true, define: { __VERSION__: JSON.stringify('1.0.0'), }, loaders: { '.json': 'json', }, }), ], };
Debug
Known issues
breakingv6.0.0 removed tsconfig resolution and the 'types' field. tsconfig will not be automatically resolved; you must pass 'tsconfig' option explicitly if needed.
fix
Explicitly set tsconfig: 'tsconfig.json' in plugin options if you rely on tsconfig for JSX or target.
affects: >=6.0.0
breakingv5.0.0 dropped Node.js <14 support and upgraded to Rollup v3. Users on older Rollup must upgrade.
fix
Update Rollup to v3+ and Node.js to >=14.
affects: >=5.0.0
breakingv6.2.0 added default loaders for .mjs, .cjs, .mts, .cts, .tsx, .jsx. This may cause conflicts if you already had custom loaders for these extensions.
fix
Review loaders option to avoid duplicate mapping; set loaders explicitly if you want to override defaults.
affects: >=6.2.0
deprecatedThe 'optimizeDeps' option is experimental and may break across minor versions.
fix
Test thoroughly with each upgrade; consider alternative dep pre-bundling methods if stability is critical.
affects: >=6.0.0
gotchaPlugin is ESM-only via default export. In CommonJS environments, you must use dynamic import().
fix
Use async wrappers: const esbuild = (await import('rollup-plugin-esbuild')).default;
affects: >=4.0.0
gotchaWhen using 'minify' standalone, esbuild may remove TypeScript type imports that are used only for types, causing dead code elimination.
fix
Ensure type-only imports are side-effect-free; use 'import type' syntax.
affects: all
Errors
Common errors & fixes
Error: [plugin:esbuild] Transform failed with 1 error: <file>:<line>:<col>: ERROR: No loader is configured for ".vue" files
Plugin does not handle .vue files by default; custom loader needed.
fix
Add loaders: { '.vue': 'jsx' } or use a separate Vue plugin before esbuild.
Cannot find module 'rollup-plugin-esbuild'
Missing installation or wrong import path in ESM/CJS context.
fix
Install with 'yarn add rollup-plugin-esbuild --dev' and ensure you use the correct import syntax for your module system.
TypeError: esbuild is not a function
CommonJS require() on ESM-only package.
fix
Use dynamic import: const esbuild = (await import('rollup-plugin-esbuild')).default;
Error: [plugin:esbuild] You must set the 'target' option to use the 'jsx' loader
Missing or invalid target when using JSX loader.
fix
Set a valid target like 'es2020' in plugin options or tsconfig.
Error: [plugin:esbuild] 'define' must be an object with string values
define values must be string literals representing the replacement code.
fix
Use JSON.stringify for values: define: { __VERSION__: JSON.stringify('1.0.0') }
Upgrade
Version history
6.2.1latest on npm
Audit
Dependencies
esbuildrequiredRuntime peer dependency; used for all transformation and minification.
rolluprequiredPeer dependency; plugin hooks into Rollup's build process.
Agent activity
10 hits · last 30 days
node
8
Resources
rollup-plugin-esbuild — npm install rollup-plugin-esbuild · libregistry