webpack vs rollup vs vite vs esbuild vs @swc/core
JavaScript Build Tools and Bundlers for Modern Frontend Development
webpackrollupviteesbuild@swc/coreSimilar Packages:

JavaScript Build Tools and Bundlers for Modern Frontend Development

@swc/core, esbuild, rollup, vite, and webpack are foundational tools in the JavaScript ecosystem that handle compilation, bundling, and development server functionality. While they share overlapping responsibilities — such as transforming modern JavaScript, managing dependencies, and optimizing assets for production — each takes a distinct architectural approach. @swc/core and esbuild are primarily high-speed compilers written in lower-level languages (Rust and Go, respectively), optimized for raw transformation speed. rollup specializes in producing clean, minimal bundles ideal for libraries, using an ES module-first design. webpack is a highly configurable module bundler capable of handling complex applications with diverse asset types through its plugin and loader system. vite leverages native ES modules in development for near-instant startup and uses either esbuild or @swc/core for production builds, offering a modern developer experience built around speed and simplicity.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
webpack065,9335.8 MB207a month agoMIT
rollup026,2662.83 MB6017 days agoMIT
vite079,5792.18 MB71311 days agoMIT
esbuild039,803147 kB6063 days agoMIT
@swc/core033,340124 kB4212 days agoApache-2.0

JavaScript Build Tools Compared: @swc/core, esbuild, rollup, vite, and webpack

Choosing the right build tool can make or break your frontend architecture. These five tools — @swc/core, esbuild, rollup, vite, and webpack — all solve parts of the same problem but with different philosophies. Let’s cut through the noise and compare them on real engineering concerns.

⚙️ Core Purpose: What Each Tool Actually Does

@swc/core is a Rust-based JavaScript/TypeScript compiler. It transforms code (e.g., JSX → JS, TS → JS, modern syntax → older syntax) but does not bundle modules by itself. Think of it as Babel’s faster cousin.

// @swc/core: Transform code only
import * as swc from '@swc/core';

const { code } = await swc.transformFile('src/index.ts', {
  jsc: {
    parser: { syntax: 'typescript' },
    target: 'es2015'
  }
});
// Returns transformed string — no bundling, no file I/O beyond input

esbuild is a Go-based bundler and compiler that does both transformation and bundling extremely fast. It supports basic code splitting, minification, and CSS handling out of the box.

// esbuild: Bundle and transform in one step
require('esbuild').build({
  entryPoints: ['src/index.js'],
  outfile: 'dist/bundle.js',
  bundle: true,
  minify: true,
  target: 'es2015'
});

rollup is a module bundler focused on producing clean, efficient bundles, especially for libraries. It uses ES modules natively and has best-in-class tree-shaking.

// rollup.config.js
export default {
  input: 'src/index.js',
  output: {
    file: 'dist/bundle.cjs',
    format: 'cjs'
  }
};
// Run via CLI: rollup -c

vite is a development server and build tool that uses native ES modules in dev for instant startup and delegates production builds to rollup (with optional esbuild or @swc/core for transpilation).

// vite.config.js
export default {
  build: {
    // Uses rollup under the hood
  }
};
// Dev server: vite
// Build: vite build

webpack is a feature-rich module bundler that treats everything as a module (JS, CSS, images, etc.) and uses loaders/plugins for transformation and optimization.

// webpack.config.js
module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist')
  },
  module: {
    rules: [
      { test: /\.ts$/, use: 'ts-loader' }
    ]
  }
};

🧪 Developer Experience: Startup Time and HMR

In development, speed matters. Here’s how they compare:

  • vite wins for near-instant startup because it serves source files directly over native ES modules — no bundling needed during dev.
  • esbuild can serve as a dev server too, but it still bundles on startup, so it’s slower than Vite for large projects.
  • webpack’s dev server is mature but slow to start on big apps due to full initial bundling.
  • rollup and @swc/core don’t include dev servers — you’d need to add rollup-plugin-serve or integrate with another tool.
// Vite: Instant HMR with native ESM
// No config needed for basic React/Vue/Svelte
// Edit a file → browser updates in <50ms

// Webpack: HMR works but requires plugin setup
// module.hot.accept() calls often needed for full reload avoidance

📦 Production Builds: Bundle Quality and Optimization

For final output, consider these trade-offs:

  • rollup produces the cleanest, smallest bundles for libraries thanks to precise tree-shaking and no runtime overhead.
  • webpack offers the most control over chunking, caching strategies, and runtime behavior — essential for complex apps.
  • esbuild is fast but lacks advanced optimizations like scope hoisting; its minifier is good but not as thorough as Terser.
  • vite uses rollup for production, so you get Rollup-quality output with Vite’s DX.
  • @swc/core doesn’t bundle, so you’d pair it with another tool (e.g., swc-loader + webpack).
// esbuild minification (fast but less aggressive)
esbuild.build({ minify: true });

// webpack with Terser (slower but smaller output)
optimization: {
  minimizer: [new TerserPlugin()]
}

// rollup with terser plugin
import terser from '@rollup/plugin-terser';
plugins: [terser()]

🔌 Ecosystem and Extensibility

  • webpack has the largest ecosystem — thousands of loaders and plugins for every imaginable use case (e.g., css-loader, file-loader, mini-css-extract-plugin).
  • rollup has a solid plugin system but fewer options; best for standard workflows.
  • vite reuses Rollup plugins in production and has its own plugin API for dev server hooks.
  • esbuild has limited plugin support (only for loading/transforming files, not for bundling logic).
  • @swc/core supports custom Rust or JavaScript plugins for AST manipulation but isn’t designed for asset handling.
// webpack: Chain multiple loaders
{ test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader'] }

// vite: Pre-configured CSS handling
// Just import .scss files — no config needed

// esbuild: Basic CSS support only
// No built-in Sass or PostCSS — must preprocess externally

🛠️ Configuration Complexity

  • vite: Minimal config for common stacks. Zero config for React, Vue, etc.
  • esbuild: Simple API but limited knobs to turn.
  • rollup: Moderate config — straightforward for libraries, trickier for apps.
  • webpack: High complexity. Requires understanding of entries, outputs, loaders, plugins, resolve rules, etc.
  • @swc/core: Low config for transformation, but you must build the rest of the pipeline yourself.

🧩 Real-World Scenarios

Scenario 1: Publishing an npm Library

  • Best choice: rollup
  • Why? Clean output, multiple format support (ESM/CJS), excellent tree-shaking.
// rollup.config.js for library
export default {
  input: 'src/index.js',
  output: [
    { file: 'dist/index.es.js', format: 'es' },
    { file: 'dist/index.cjs.js', format: 'cjs' }
  ],
  external: ['lodash'] // keep deps external
};

Scenario 2: Building a Large Enterprise Application

  • Best choice: webpack
  • Why? Full control over code splitting, lazy loading, asset management, and legacy browser support.
// webpack: Dynamic imports with named chunks
import(/* webpackChunkName: "dashboard" */ './Dashboard');

Scenario 3: Starting a New React or Vue App in 2024

  • Best choice: vite
  • Why? Blazing-fast dev server, sensible defaults, easy TypeScript/JSX support.
npm create vite@latest my-app -- --template react

Scenario 4: Need Raw Transpilation Speed (e.g., in Jest or Next.js)

  • Best choice: @swc/core
  • Why? Drop-in replacement for Babel with 10–100x speedup.
// jest.config.js
transform: {
  '^.+\\.tsx?$': ['@swc/jest']
}

Scenario 5: Simple App with Fast Builds and No Fancy Optimizations

  • Best choice: esbuild
  • Why? One-command build, small footprint, great for prototypes or internal tools.
// Build script
esbuild src/index.js --bundle --minify --outfile=public/app.js

🔄 Migration Considerations

  • Moving from webpack to vite requires replacing loader logic with Vite plugins or pre-processing steps.
  • Using @swc/core inside webpack is possible via swc-loader — a common performance upgrade path.
  • esbuild can replace Babel + Terser in many cases, but verify bundle size and compatibility.
  • rollup and webpack are not interchangeable for apps — Rollup lacks webpack’s runtime and async chunk loading model.

📊 Summary Table

ToolLanguageBundles?Dev Server?Best ForWeaknesses
@swc/coreRustFast transpilation, Jest, Next.jsNo bundling or asset handling
esbuildGo✅ (basic)Speed-focused apps, prototypingLimited optimizations/plugins
rollupJS❌ (needs plugin)Libraries, clean ESM outputPoor for complex app code splitting
viteJS✅ (via Rollup)Modern apps, DX-focused projectsLess control than webpack
webpackJSLarge apps, full customizationSlow builds, complex config

💡 Final Guidance

  • Need speed above all?esbuild or @swc/core
  • Building a library?rollup
  • Starting fresh in 2024?vite
  • Maintaining a complex legacy app? → Stick with webpack or incrementally adopt SWC

These tools aren’t competitors — they’re complementary. Many projects combine them (e.g., Vite + SWC, Webpack + SWC). Choose based on your team’s needs, not hype.

How to Choose: webpack vs rollup vs vite vs esbuild vs @swc/core

  • webpack:

    Choose webpack when you need maximum flexibility to handle complex, large-scale applications with diverse asset types, custom resolution logic, or intricate optimization requirements. Its mature plugin and loader ecosystem supports virtually any workflow, making it suitable for enterprise projects with long-term maintenance needs. Avoid it for simple projects or library authoring where its configuration overhead and slower build times aren’t justified.

  • rollup:

    Choose rollup when building libraries or applications where output bundle size and purity matter more than development server features. Its tree-shaking is among the best in the ecosystem, and its plugin model works well for publishing npm packages with multiple output formats (ESM, CJS, IIFE). Avoid it for large applications requiring code splitting, dynamic imports with complex routing, or built-in dev servers — you’ll need to add those yourself.

  • vite:

    Choose vite when you want a batteries-included, fast modern development environment with zero-config support for TypeScript, JSX, CSS, and more, while still allowing deep customization. It’s perfect for new applications (especially React, Vue, or Svelte) where developer experience and instant HMR are priorities. Avoid it if you’re maintaining a legacy Webpack-based app with heavy custom loader logic that’s hard to migrate.

  • esbuild:

    Choose esbuild when raw build speed is critical and your project can work within its intentionally limited feature set. It excels at rapid development builds and simple production bundling for apps that don’t require advanced optimizations like scope hoisting or fine-grained chunk control. Avoid it if you depend on ecosystem-specific loaders (e.g., CSS modules with complex post-processing) or need deep customization beyond its current API.

  • @swc/core:

    Choose @swc/core when you need a Rust-based JavaScript/TypeScript compiler that integrates into existing toolchains (like Jest or Next.js) for fast transpilation without full bundling. It’s ideal if you’re already using SWC-compatible frameworks or require custom AST transformations via plugins, but avoid it if you need built-in code splitting, HMR, or asset handling — those must be layered on top.

README for webpack



npm

node builds1 dependency-review coverage pkg.pr.new PR's welcome compatibility-score downloads install-size backers sponsors contributors discussions discord LFX Health Score

webpack

Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.

Table of Contents

Install

Install with npm:

npm install --save-dev webpack

Install with yarn:

yarn add webpack --dev

Introduction

Webpack is a bundler for modules. The main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.

TL;DR

  • Bundles ES Modules, CommonJS, and AMD modules (even combined).
  • Can create a single bundle or multiple chunks that are asynchronously loaded at runtime (to reduce initial loading time).
  • Dependencies are resolved during compilation, reducing the runtime size.
  • Loaders can preprocess files while compiling, e.g. TypeScript to JavaScript, Handlebars strings to compiled functions, images to Base64, etc.
  • Highly modular plugin system to do whatever else your application requires.

Learn about webpack through videos!

Get Started

Check out webpack's quick Get Started guide and the other guides.

Browser Compatibility

Webpack supports all browsers that are ES5-compliant (IE8 and below are not supported). Webpack also needs Promise for import() and require.ensure(). If you want to support older browsers, you will need to load a polyfill before using these expressions.

Concepts

Plugins

Webpack has a rich plugin interface. Most of the features within webpack itself use this plugin interface. This makes webpack very flexible.

NameStatusInstall SizeDescription
mini-css-extract-pluginmini-css-npmmini-css-sizeExtracts CSS into separate files. It creates a CSS file per JS file which contains CSS.
compression-webpack-plugincompression-npmcompression-sizePrepares compressed versions of assets to serve them with Content-Encoding
html-bundler-webpack-pluginbundler-npmbundler-sizeRenders a template (EJS, Handlebars, Pug) with referenced source asset files into HTML.
html-webpack-pluginhtml-plugin-npmhtml-plugin-sizeSimplifies creation of HTML files (index.html) to serve your bundles
pug-pluginpug-plugin-npmpug-plugin-sizeRenders Pug files to HTML, extracts JS and CSS from sources specified directly in Pug.

Loaders

Webpack enables the use of loaders to preprocess files. This allows you to bundle any static resource way beyond JavaScript. You can easily write your own loaders using Node.js.

Loaders are activated by using loadername! prefixes in require() statements, or are automatically applied via regex from your webpack configuration.

JSON

NameStatusInstall SizeDescription
cson-npmcson-sizeLoads and transpiles a CSON file

Transpiling

NameStatusInstall SizeDescription
babel-npmbabel-sizeLoads ES2015+ code and transpiles to ES5 using Babel
type-npmtype-sizeLoads TypeScript like JavaScript
coffee-npmcoffee-sizeLoads CoffeeScript like JavaScript

Templating

NameStatusInstall SizeDescription
html-npmhtml-sizeExports HTML as string, requires references to static resources
pug-npmpug-sizeLoads Pug templates and returns a function
pug3-npmpug3-sizeCompiles Pug to a function or HTML string, useful for use with Vue, React, Angular
md-npmmd-sizeCompiles Markdown to HTML
posthtml-npmposthtml-sizeLoads and transforms a HTML file using PostHTML
hbs-npmhbs-sizeCompiles Handlebars to HTML

Styling

NameStatusInstall SizeDescription
<style>style-npmstyle-sizeAdd exports of a module as style to DOM
css-npmcss-sizeLoads CSS file with resolved imports and returns CSS code
less-npmless-sizeLoads and compiles a LESS file
sass-npmsass-sizeLoads and compiles a Sass/SCSS file
stylus-npmstylus-sizeLoads and compiles a Stylus file
postcss-npmpostcss-sizeLoads and transforms a CSS/SSS file using PostCSS

Frameworks

NameStatusInstall SizeDescription
vue-npmvue-sizeLoads and compiles Vue Components
polymer-npmpolymer-sizeProcess HTML & CSS with preprocessor of choice and require() Web Components like first-class modules
angular-npmangular-sizeLoads and compiles Angular 2 Components
riot-npmriot-sizeRiot official webpack loader
svelte-npmsvelte-sizeOfficial Svelte loader

Performance

Webpack uses async I/O and has multiple caching levels. This makes webpack fast and incredibly fast on incremental compilations.

Module Formats

Webpack supports ES2015+, CommonJS and AMD modules out of the box. It performs clever static analysis on the AST of your code. It even has an evaluation engine to evaluate simple expressions. This allows you to support most existing libraries out of the box.

Code Splitting

Webpack allows you to split your codebase into multiple chunks. Chunks are loaded asynchronously at runtime. This reduces the initial loading time.

Optimizations

Webpack can do many optimizations to reduce the output size of your JavaScript by deduplicating frequently used modules, minifying, and giving you full control of what is loaded initially and what is loaded at runtime through code splitting. It can also make your code chunks cache friendly by using hashes.

Developer Tools

If you're working on webpack itself, or building advanced plugins or integrations, the tools below can help you explore internal mechanics, debug plugin life-cycles, and build custom tooling.

Instrumentation

NameStatusDescription
tapable-tracertapable-tracer-npmTraces tapable hook execution in real-time and collects structured stack frames. Can export to UML for generating visualizations.

Contributing

We want contributing to webpack to be fun, enjoyable, and educational for anyone, and everyone. We have a vibrant ecosystem that spans beyond this single repo. We welcome you to check out any of the repositories in our organization or webpack-contrib organization which houses all of our loaders and plugins.

Contributions go far beyond pull requests and commits. Although we love giving you the opportunity to put your stamp on webpack, we also are thrilled to receive a variety of other contributions including:

To get started have a look at our documentation on contributing.

Creating your own plugins and loaders

If you create a loader or plugin, we would <3 for you to open source it, and put it on npm. We follow the x-loader, x-webpack-plugin naming convention.

Support

We consider webpack to be a low-level tool used not only individually but also layered beneath other awesome tools. Because of its flexibility, webpack isn't always the easiest entry-level solution, however we do believe it is the most powerful. That said, we're always looking for ways to improve and simplify the tool without compromising functionality. If you have any ideas on ways to accomplish this, we're all ears!

If you're just getting started, take a look at our new docs and concepts page. This has a high level overview that is great for beginners!!

If you have discovered a 🐜 or have a feature suggestion, feel free to create an issue on GitHub.

Current project members

For information about the governance of the webpack project, see GOVERNANCE.md.

TSC (Technical Steering Committee)

Maintenance

This webpack repository is maintained by the Core Working Group.

Sponsoring

Most of the core team members, webpack contributors and contributors in the ecosystem do this open source work in their free time. If you use webpack for a serious task, and you'd like us to invest more time on it, please donate. This project increases your income/productivity too. It makes development and applications faster and it reduces the required bandwidth.

This is how we use the donations:

  • Allow the core team to work on webpack
  • Thank contributors if they invested a large amount of time in contributing
  • Support projects in the ecosystem that are of great value for users
  • Support projects that are voted most (work in progress)
  • Infrastructure cost
  • Fees for money handling

Premium Partners

Other Backers and Sponsors

Before we started using OpenCollective, donations were made anonymously. Now that we have made the switch, we would like to acknowledge these sponsors (and the ones who continue to donate using OpenCollective). If we've missed someone, please send us a PR, and we'll add you to this list.

Gold Sponsors

Become a gold sponsor and get your logo on our README on GitHub with a link to your site.

Silver Sponsors

Become a silver sponsor and get your logo on our README on GitHub with a link to your site.

Bronze Sponsors

Become a bronze sponsor and get your logo on our README on GitHub with a link to your site.

Backers

Become a backer and get your image on our README on GitHub with a link to your site.

Special Thanks to

(In chronological order)

  • @google for Google Web Toolkit (GWT), which aims to compile Java to JavaScript. It features a similar Code Splitting as webpack.
  • @medikoo for modules-webmake, which is a similar project. webpack was born because of the desire for code splitting for modules such as Webmake. Interestingly, the Code Splitting issue is still open (thanks also to @Phoscur for the discussion).
  • @substack for browserify, which is a similar project and source for many ideas.
  • @jrburke for require.js, which is a similar project and source for many ideas.
  • @defunctzombie for the browser-field spec, which makes modules available for node.js, browserify and webpack.
  • @sokra for creating webpack.
  • Every early webpack user, which contributed to webpack by writing issues or PRs. You influenced the direction.
  • All past and current webpack maintainers and collaborators.
  • Everyone who has written a loader for webpack. You are the ecosystem...
  • Everyone not mentioned here but that has also influenced webpack.