Skip to content
Tutorials Center
My learning

Topics

Lesson 33 of 38 ยท Migration and Alternatives

Webpack vs Vite, Rollup, esbuild and Rspack

Compare webpack with Vite, Rollup, esbuild, Rspack, Parcel and Turbopack: how each works, where each is strongest, and a practical decision guide for new and existing projects.

Webpack was the default bundler for most of the 2010s, and it is still used by an enormous number of production apps. Today you have real alternatives, and the right choice depends on your project. This lesson explains how the main tools differ in design, not just speed, and gives a decision guide.

Webpack and the other bundlers are not runnable on this site. Config snippets are read-only. The TryIt blocks are Node.js stand-ins: one models the difference between bundling up front and serving modules on demand, and one scores tools against your own priorities. Treat the numbers as teaching data, not benchmarks.

What a bundler does, and why the landscape moved

All these tools solve the same core problem: turn many source files and npm packages into files a browser can load efficiently. They differ in how they achieve it.

  • Webpack builds a full dependency graph, runs loaders on every module, and emits chunks. It is written in JavaScript and extremely configurable.
  • Rollup focuses on ES modules and produces clean, tree-shaken output. It is the favourite for libraries.
  • esbuild is written in Go, extremely fast, and covers transpiling TypeScript/JSX, bundling and minification, with a smaller plugin model.
  • Vite is a development server plus a build tool. In development it serves your source as native ES modules, transforming files on demand with esbuild; for production it bundles with Rollup (Rolldown in newer versions).
  • Rspack is a Rust reimplementation of webpack's architecture, compatible with most webpack config, loaders and plugins, and much faster.
  • Parcel is a zero-configuration bundler that detects what to do from file types.
  • Turbopack is a Rust bundler from the Next.js team, mostly used through Next.js.

Bundle-first versus serve-on-demand

Webpack's dev server must build the whole graph before the first page loads, so start-up time grows with the project. Vite's dev server starts immediately and processes only the modules the browser actually requests. The stand-in compares the work for a project with 800 modules where the first page needs 40.

Node.js Stand-in: work done before the first page appears

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

The trade-off is that unbundled development does not match production exactly, and a page that needs thousands of modules makes many requests. Production builds still bundle in both worlds.

How they compare

Webpack Vite Rollup esbuild Rspack Parcel
Written in JavaScript JS + native tools JavaScript Go Rust JS + Rust
Dev server Yes (bundled) Yes (native ESM) No (plugin) Basic Yes Yes
Config effort High Low Medium Low High (webpack-like) Almost none
Plugin ecosystem Largest Large (Rollup-compatible) Large Small Reuses webpack's Medium
Code splitting Excellent Good Good Basic Excellent Good
Module Federation Native Plugin No No Native No
Best for Complex apps, legacy, custom pipelines New apps Libraries Tools, fast transforms Large webpack projects Quick projects

Real-world numbers vary with project size, plugins and hardware, so measure your own build rather than trusting a table.

Config in each tool

The same idea (an alias and a React setup) in two styles. Webpack:

JavaScript
// webpack.config.js
module.exports = {
  entry: './src/index.jsx',
  resolve: { alias: { '@': path.resolve(__dirname, 'src') } },
  module: { rules: [{ test: /\.jsx?$/, loader: 'babel-loader' }] },
};

Vite:

JavaScript
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'node:path';

export default defineConfig({
  plugins: [react()],
  resolve: { alias: { '@': path.resolve(__dirname, 'src') } },
});

Rspack keeps webpack's shape, so most of the webpack config works by changing the package name, with builtin:swc-loader replacing babel-loader for speed. esbuild is typically used through its API:

JavaScript
import { build } from 'esbuild';

await build({
  entryPoints: ['src/index.jsx'],
  bundle: true,
  minify: true,
  sourcemap: true,
  outdir: 'dist',
});

When webpack is still the right choice

  • You have a working large webpack app. A migration costs real time; do it only for a clear benefit.
  • Complex custom pipelines: unusual loaders, many plugins, multiple targets or Module Federation hosts.
  • Fine control over chunking and caching beyond what simpler tools expose.
  • Enterprise frameworks that integrate with webpack deeply.

If the main complaint is speed, try Rspack or persistent caching first; they keep your config.

When something else is better

  • New single-page app or website: Vite is the common default.
  • A library for npm: Rollup (or a tool built on it such as tsup, which uses esbuild) gives clean ES and CommonJS builds.
  • A build script, CLI tool or server code: esbuild.
  • A prototype with no config time: Parcel.

A decision helper

The stand-in below scores each tool against weights you choose. It is intentionally simple: it demonstrates how to turn priorities into a decision, and you should supply your own scores from your own trials.

Node.js Stand-in: weigh your priorities

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

In the first scenario webpack and Rspack lead because compatibility and flexibility are weighted heavily; in the second, Vite leads because speed and simplicity matter most. Your weights decide.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How does Vite's dev server differ from webpack's?

    Vite avoids bundling in development, so start-up does not grow with total project size.
  2. 2. Which tool is a Rust implementation designed to be compatible with webpack's config and loaders?

    Rspack mirrors webpack's architecture, so many webpack configs, loaders and plugins work with little change.
  3. 3. You are publishing an npm library with ES and CommonJS builds. Which is a natural fit?

    Rollup produces clean tree-shakeable output and is the usual choice for libraries.
  4. 4. You want faster builds but have a large, working webpack config. What is a low-risk first step?

    Persistent caching and webpack-compatible tools improve speed without a full migration.

Summary

  • Bundlers differ in architecture: bundle-first (webpack, Rspack, Parcel) versus on-demand in development (Vite).
  • Rollup suits libraries, esbuild suits scripts and fast transforms, Rspack suits big webpack projects wanting speed.
  • Keep webpack for complex or legacy needs; pick Vite for most new apps.
  • Decide with your own measurements and priorities.

Next: Migrating from Webpack to Vite