Open-source project
egoist/rollup-plugin-esbuild avatar
egoist/rollup-plugin-esbuild

rollup-plugin-esbuild replaces three Rollup plugins with one esbuild pass

Use ESBuild with Rollup to transform ESNext and TypeScript code.

640 stars40 forksTypeScriptMIT

At a glance

What is it?
rollup-plugin-esbuild is a Rollup plugin that runs esbuild to transform TypeScript and ESNext, minify, and optionally pre-bundle dependencies, so a project can drop rollup-plugin-typescript2, @rollup/plugin-typescript and rollup-plugin-terser at once. The trade is that declaration files are not its job, and the dependency pre-bundling is still marked experimental.
Who is it for?
rollup-plugin-esbuild suits a Rollup project that wants one fast transform pass for TypeScript and ESNext and is willing to generate declaration files with a separate tool, such as rollup-plugin-dts or tsc. It does not suit a library that needs bundled .d.ts output from the same build, since the plugin leaves that to another package, and the optimizeDeps option is documented as experimental with breaking changes possible across a minor version bump.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Activity is slowing. The repository last received commits 6 months ago.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

One plugin in place of three

The pitch is stated in one sentence in the README, and it is the reason the plugin exists. esbuild is described as by far one of the fastest TS and ESNext to ES6 compilers and minifier, and this plugin replaces rollup-plugin-typescript2, @rollup/plugin-typescript and rollup-plugin-terser for you. That is a concrete claim about configuration surface rather than a general one about speed: a typical Rollup config for a TypeScript project ends up with a transform plugin, a minifier plugin and sometimes a replace plugin, and each of them has its own options. The intended user is a maintainer of a Rollup-based library or app who has measured the TypeScript plugin as the slow part of the build and wants the same work done by a different engine. The plugin is written in TypeScript, the primary language in the repository, and it is published to npm under the name rollup-plugin-esbuild.

Installing is a dev dependency, and the config is one object

The install is a single command, and the README gives it as a yarn add with both packages marked as dev dependencies:

bash
yarn add esbuild rollup-plugin-esbuild --dev

@@C1@@The configuration is one call inside the plugins array of rollup.config.js, and the example in the README shows every option at once with the default values in comments. The include pattern is a regular expression matching js, jsx, ts and tsx extensions, inferred from the loaders option, and exclude defaults to node_modules. sourceMap defaults to true, minify is switched on by an environment check, target defaults to es2017 with es20XX and esnext also accepted, and jsx defaults to transform with preserve as the alternative. The jsxFactory and jsxFragment options set the factory functions, tsconfig points at the config file, and a define block lets you inject compile-time constants the way @rollup/plugin-replace would. The loaders object adds file extensions esbuild does not handle by default, with .json mapped to json in the example, and a comment notes that using .json this way also requires @rollup/plugin-commonjs.

tsconfig values become the defaults, which is the quiet part

Two rules decide what happens when you do not pass an option, and the second one is easy to miss. The first is that include and exclude can be a string, a regular expression or an array of either, and when supplied they override the default values entirely. The second is that the plugin reads the jsx, jsxDev, jsxFactory, jsxFragmentFactory and target options from your tsconfig.json and uses them as defaults. In practice that means the tsconfig file you already maintain for the editor and for tsc also drives the bundler, which is the point, since a project that sets jsx: preserve in tsconfig for a different tool will not get the transform behaviour it expected here. It also means the tsconfig option, which defaults to tsconfig.json in the project root, is a real input to the build rather than a formality.

Declaration files are explicitly not the plugin's job

The section on declaration files is where the plugin draws its boundary, and the README lists three routes with an honest assessment of each. The first is tsc with emitDeclarationOnly, described as the slowest way but one where you get type checking and the .d.ts files are not bundled. The second is rollup-plugin-dts, which generates and bundles the .d.ts files and also does type checking. The third is api-extractor from Microsoft, which the author describes as looking quite complex to me so I didn't try it, with a pull request welcome to update the section. That admission is worth reading as a signal about the project rather than as a footnote: the author tried the first two and left the third to someone else. If you ship a library with a single type entry point and want one .d.ts file for your users, you need the second route or a separate step, because this plugin will not produce it for you.

Standalone minify, for when the transform is not what you need

There is a second export that changes the use case, and it is easy to miss. If you only want to use this plugin to minify your bundle, the README shows importing minify directly and using it as the only plugin:

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

export default {
  plugins: [minify()],
}

@@C2@@That is a genuinely different shape from the main plugin, because it does not need to transform anything and so it can be dropped into a config whose other plugins already handle the source. The package metadata explains how the two builds are wired, with a main field pointing at dist/index.js, a module field at dist/index.mjs, types at dist/index.d.ts, and an exports map that routes import to the .mjs file and default to the .js file, so both module systems resolve without a bundler shim. The build is done with tsup, the test runner is vitest, and the version field is left to semantic-release as 0.0.0-semantic-release in the source.

optimizeDeps removes two plugins but is still experimental

The most interesting feature is also the one the README flags hardest. You can use the plugin to pre-bundle dependencies using esbuild and inline them in the Rollup-generated bundle, configured with an include list:

js
    esbuild({
      // All options are optional
      include: /\.[jt]sx?$/, // default, inferred from `loaders` option
      exclude: /node_modules/, // default
      sourceMap: true, // default
      minify: process.env.NODE_ENV === 'production',
      target: 'es2017', // default, or 'es20XX', 'esnext'
      jsx: 'transform', // default, or 'preserve'
      jsxFactory: 'React.createElement',
      jsxFragment: 'React.Fragment',
      // Like @rollup/plugin-replace
      define: {
        __VERSION__: '"x.y.z"',
      },
      tsconfig: 'tsconfig.json', // default

@@C3@@The claim is that this eliminates the need for @rollup/plugin-node-modules and @rollup/plugin-commonjs, which is a large simplification for a project that was carrying both. The cost is stated in the next paragraph: it is an experimental feature and breaking changes might happen across a minor version bump. There is also a TODO in the README about possibly scanning the Rollup input files to get the list of dependencies to optimize automatically, which tells you the list is currently yours to maintain by hand. The mechanism behind it is visible in the dependencies, with es-module-lexer, get-tsconfig and unplugin-utils listed alongside debug, and debug itself being the logging hook you can switch on.

MIT licensed, semantically versioned, and moving slowly

The licensing is MIT, credited to EGOIST (Kevin Titor), with the LICENSE file at the root of the repository. The peer dependency ranges are worth noting because they define the supported surface: esbuild at 0.18.0 or newer and rollup at 1.20.0 or 2, 3 or 4, so the plugin spans several major versions of the bundler, and the engines field requires Node 14.18.0 or newer. On releases, the tags are v6.2.1 from 2025-02-27, v6.2.0 from 2025-02-05 and v6.1.1 from 2024-01-23, and the release naming is handled by semantic-release through the .releaserc.json file, which is why the version in the source package.json is a placeholder. The default branch is dev rather than main, and the last push to the repository was on 2026-04-02. The repository carries a bench.sh script, an example/ directory with a Vue and TypeScript setup including a rollup.config.js and a tsconfig.base.json, a CONTRIBUTING.md and a pnpm-workspace.yaml alongside the pnpm lock file.

Editorial conclusion

rollup-plugin-esbuild suits a Rollup project that wants one fast transform pass for TypeScript and ESNext and is willing to generate declaration files with a separate tool, such as rollup-plugin-dts or tsc. It does not suit a library that needs bundled .d.ts output from the same build, since the plugin leaves that to another package, and the optimizeDeps option is documented as experimental with breaking changes possible across a minor version bump. Before adopting, check your esbuild version against the peer range of 0.18.0 or newer, and note that the last push to the repository was on 2026-04-02 with the newest tagged release v6.2.1 from 2025-02-27.

Frequently asked questions

How do I install rollup-plugin-esbuild?

Add it as a dev dependency with `yarn add esbuild rollup-plugin-esbuild --dev`, then add the plugin to the plugins array of your rollup.config.js. The peer dependency range requires esbuild 0.18.0 or newer and rollup 1.20.0 or newer, and Node 14.18.0 or newer.

Which Rollup plugins does rollup-plugin-esbuild replace?

The README says it replaces rollup-plugin-typescript2, @rollup/plugin-typescript and rollup-plugin-terser. The optimizeDeps option is also described as eliminating the need for @rollup/plugin-node-modules and @rollup/plugin-commonjs, though that one is marked experimental.

How do I generate declaration files with rollup-plugin-esbuild?

The plugin does not do it. The README lists three options: tsc with emitDeclarationOnly, which is the slowest but gives type checking and does not bundle the .d.ts files; rollup-plugin-dts, which generates and bundles them and also type checks; and api-extractor, which the author says looked too complex to try.

What does the optimizeDeps option do in rollup-plugin-esbuild?

It pre-bundles dependencies using esbuild and inlines them in the Rollup-generated bundle, configured with an include list of package names. The README states that it is an experimental feature and that breaking changes might happen across a minor version bump.

Which options does rollup-plugin-esbuild take from tsconfig.json?

The jsx, jsxDev, jsxFactory, jsxFragmentFactory and target options are read from your tsconfig.json and used as default values. The tsconfig option itself defaults to tsconfig.json in the project root.

Official sources

  1. egoist/rollup-plugin-esbuild on GitHub
  2. Issues
  3. License: MIT
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/egoist-rollup-plugin-esbuild.svg)](https://hysenlabs.com/projects/egoist-rollup-plugin-esbuild)

Was this useful?