Course contentsShow
← JavaScript
Lesson 2459 of 2,72350. JavaScript Build ToolingFree lesson

Vite: Development server meets bundler

Understanding Vite's dual approach: native ESM dev server plus Rollup for production.

Vite: Development server meets bundler

You'll learn how Vite combines instant native ESM serving during development with Rollup's production bundling.

The Dual Nature of Vite

Vite takes a split-personality approach to building modern JavaScript applications. Unlike traditional bundlers that bundle everything upfront even during development, Vite does two very different things depending on your mode:

Development mode: Vite serves your source files as native ES modules directly to the browser. No bundling step at all! When you save a file, the browser requests only that changed module via ESM import statements. This is lightning-fast because there's no rebuild step—just a transform if needed (like TypeScript to JavaScript).

Production mode: Vite switches gears completely and uses Rollup under the hood to create optimized, bundled assets with code splitting, tree shaking, and minification.

Why This Hybrid Approach?

Think of it like a restaurant with two kitchens: a fast-casual counter for lunch rush (dev mode) where you get food immediately, and a fine-dining kitchen for evening service (production) where everything is carefully prepared and plated.

During development, you want speed and instant feedback. Native ESM gives you that. For production, you need optimized bundles that load efficiently in all browsers, which Rollup provides.

This dual strategy means you get sub-second Hot Module Replacement during development (because no bundling happens) while still shipping production-grade bundles to your users.

Key Takeaway: Vite separates concerns—native ESM dev server for development speed, Rollup bundler for production optimization—giving you the best of both worlds.