{"id":22009,"library":"rollup-plugin-esbuild","title":"rollup-plugin-esbuild","description":"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.","status":"active","version":"6.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/egoist/rollup-plugin-esbuild","tags":["javascript","typescript"],"install":[{"cmd":"npm install rollup-plugin-esbuild","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-esbuild","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-esbuild","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime peer dependency; used for all transformation and minification.","package":"esbuild","optional":false},{"reason":"Peer dependency; plugin hooks into Rollup's build process.","package":"rollup","optional":false}],"imports":[{"note":"Default export is ESM-only. For CommonJS use dynamic import or bundler transform.","wrong":"const esbuild = require('rollup-plugin-esbuild')","symbol":"default export","correct":"import esbuild from 'rollup-plugin-esbuild'"},{"note":"Named export for standalone minify plugin. Also ESM-only.","wrong":"const { minify } = require('rollup-plugin-esbuild')","symbol":"minify","correct":"import { minify } from 'rollup-plugin-esbuild'"},{"note":"Use 'import type' for TypeScript type-only imports to avoid emitting at runtime.","wrong":"import { Options } from 'rollup-plugin-esbuild'","symbol":"type definition","correct":"import type { Options } from 'rollup-plugin-esbuild'"}],"quickstart":{"code":"// rollup.config.js\nimport esbuild from 'rollup-plugin-esbuild';\n\nexport default {\n  input: 'src/index.ts',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'esm',\n  },\n  plugins: [\n    esbuild({\n      target: 'es2020',\n      minify: true,\n      define: {\n        __VERSION__: JSON.stringify('1.0.0'),\n      },\n      loaders: {\n        '.json': 'json',\n      },\n    }),\n  ],\n};","lang":"javascript","description":"Shows how to use the esbuild plugin in a Rollup config with TypeScript, minification, define, and custom loaders."},"warnings":[{"fix":"Explicitly set tsconfig: 'tsconfig.json' in plugin options if you rely on tsconfig for JSX or target.","message":"v6.0.0 removed tsconfig resolution and the 'types' field. tsconfig will not be automatically resolved; you must pass 'tsconfig' option explicitly if needed.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Update Rollup to v3+ and Node.js to >=14.","message":"v5.0.0 dropped Node.js <14 support and upgraded to Rollup v3. Users on older Rollup must upgrade.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Review loaders option to avoid duplicate mapping; set loaders explicitly if you want to override defaults.","message":"v6.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.","severity":"breaking","affected_versions":">=6.2.0"},{"fix":"Test thoroughly with each upgrade; consider alternative dep pre-bundling methods if stability is critical.","message":"The 'optimizeDeps' option is experimental and may break across minor versions.","severity":"deprecated","affected_versions":">=6.0.0"},{"fix":"Use async wrappers: const esbuild = (await import('rollup-plugin-esbuild')).default;","message":"Plugin is ESM-only via default export. In CommonJS environments, you must use dynamic import().","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Ensure type-only imports are side-effect-free; use 'import type' syntax.","message":"When using 'minify' standalone, esbuild may remove TypeScript type imports that are used only for types, causing dead code elimination.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add loaders: { '.vue': 'jsx' } or use a separate Vue plugin before esbuild.","cause":"Plugin does not handle .vue files by default; custom loader needed.","error":"Error: [plugin:esbuild] Transform failed with 1 error: <file>:<line>:<col>: ERROR: No loader is configured for \".vue\" files"},{"fix":"Install with 'yarn add rollup-plugin-esbuild --dev' and ensure you use the correct import syntax for your module system.","cause":"Missing installation or wrong import path in ESM/CJS context.","error":"Cannot find module 'rollup-plugin-esbuild'"},{"fix":"Use dynamic import: const esbuild = (await import('rollup-plugin-esbuild')).default;","cause":"CommonJS require() on ESM-only package.","error":"TypeError: esbuild is not a function"},{"fix":"Set a valid target like 'es2020' in plugin options or tsconfig.","cause":"Missing or invalid target when using JSX loader.","error":"Error: [plugin:esbuild] You must set the 'target' option to use the 'jsx' loader"},{"fix":"Use JSON.stringify for values: define: { __VERSION__: JSON.stringify('1.0.0') }","cause":"define values must be string literals representing the replacement code.","error":"Error: [plugin:esbuild] 'define' must be an object with string values"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}