Where Vite Fits
You've now used the three engines directly. Vite isn't a fourth engine so much as a development experience built on top of them, and it's what most new web applications start with. The Vite course teaches it in full (32 lessons, from the dev server to SSR); this lesson only places it next to the tools in this course, so you know which to reach for.
Two different jobs: developing and building
Development (vite) |
Production (vite build) |
|
|---|---|---|
| Your source files | served unbundled as native ES modules, transformed one file at a time on request | bundled, tree-shaken, split, minified |
node_modules dependencies |
pre-bundled once into node_modules/.vite/deps, so lodash-es is one request instead of 600 (esbuild did this before Vite 8) |
bundled with your code |
| Engine | its own dev server + plugin pipeline | Rolldown in Vite 8 (a Rust bundler with Rollup's API); Rollup in Vite 5–7 |
| Updates | hot module replacement: only the edited module is re-sent | n/a |
A bundle-first dev server (Webpack's webpack serve, esbuild's --serve) rebuilds a bundle on every change; with HMR, Webpack patches the changed modules, but it still has to build the whole graph at startup. Vite's dev server starts before it has seen most of your files and transforms each file only when the browser first asks for it.
A model of the difference
// 2,000 source modules; the page you open imports 150 of them.
const totalModules = 2000, modulesOnPage = 150;
const costPerTransform = 1; // arbitrary units
const bundleFirst = { start: totalModules * costPerTransform, edit: 1 + 40 /* re-link + re-emit affected chunk */ };
const onDemand = { start: modulesOnPage * costPerTransform, edit: 1 };
for (const [name, c] of Object.entries({ 'bundle-first dev server': bundleFirst, 'on-demand ESM (Vite)': onDemand })) {
console.log(`${name.padEnd(24)} start: ${String(c.start).padStart(4)} units per edit: ${String(c.edit).padStart(2)} units`);
}
console.log(`startup ratio: ${(bundleFirst.start / onDemand.start).toFixed(1)}x`);bundle-first dev server start: 2000 units per edit: 41 units
on-demand ESM (Vite) start: 150 units per edit: 1 units
startup ratio: 13.3x
The numbers are made up, but the shape is real: Vite's startup cost grows with what you open, a bundle-first server's with what you have. The trade-off appears on very large pages, where hundreds of separate module requests in development can be slower than one bundle, which is why the Vite team is experimenting with a bundled dev mode on top of Rolldown.
Choosing a tool
| You are building | Reach for | Why |
|---|---|---|
| a web application (React, Vue, Svelte, plain TS) | Vite | fast dev server, HMR, sensible production defaults, huge plugin ecosystem |
| a library for npm | Rollup (or tsup/tsdown, or Vite library mode) | clean ESM/CJS output, externals, precise control |
| a Node CLI, a server, a Lambda function | esbuild | one fast bundle, --platform=node, no dev server needed |
| a build step inside another tool (tests, scripts) | esbuild API (transform) |
speed, tiny API |
| an existing app with a big Webpack config | Webpack (or Rspack, a Rust port with Webpack's API) | migration cost is real; upgrade within the ecosystem first |
| module federation / micro-frontends | Webpack / Rspack | the most mature implementation |
What carries over
Everything from this course applies inside Vite:
- dependencies, lockfiles and workspaces are the package manager's job, exactly as before;
import()creates chunks (Code Splitting, and the Vite version);sideEffects, tree shaking and CommonJS limits are the same rules;- Vite plugins use the Rollup plugin interface (which Rolldown implements) plus a few Vite-only hooks, so Rollup's plugin model is the foundation;
define, aliases andbuild.libmap directly onto what you configured by hand in esbuild, Webpack and Rollup.
// vite.config.js: the familiar pieces under different names
import { defineConfig } from 'vite';
export default defineConfig({
define: { __VERSION__: JSON.stringify('1.0.0') }, // esbuild --define / DefinePlugin
resolve: { alias: { '@': '/src' } }, // webpack resolve.alias
build: {
sourcemap: true,
rolldownOptions: { // Vite 8; rollupOptions in Vite 5-7
output: { codeSplitting: { groups: [{ name: 'vendor', test: /node_modules/ }] } }, // splitChunks
},
},
});Note: Vite isn't in this course's offline registry, so this lesson has no real sessions; the Vite course has full build walkthroughs.
Test yourself
How does Vite's dev server handle your source files?
- Bundles them all at startup
- Serves them as native ES modules, transforming each on request
- Uses Webpack
- Compiles them to CommonJS
Which tool would you pick to build a small npm library with ESM and CJS outputs?
- Webpack with splitChunks
- Rollup (or a wrapper like tsup)
- Vite's dev server
- npm pack
What does Vite pre-bundle in development, and why?
- Your source code, for speed
- node_modules dependencies, so a package with hundreds of internal modules becomes one request
- CSS only
- Nothing