Prejsť na hlavný obsah
← ⚡ JavaScript & the browser·Modul C3 · Lekcia 8
ÚlohaPure-theory lesson — match the tool to the use case. No code change needed.

Bundleri v roku 2026: Vite, esbuild alebo nič

75 XP8 min
Teória

What a bundler actually does

Three jobs:

  1. Resolve bare specifiers — import React from "react" → actual file from node_modules.
  2. Concatenate + minify — one HTTP request instead of fifty, fewer bytes on the wire.
  3. Transform syntax — JSX → JS, TypeScript → JS, SCSS → CSS.

Pre-2020 we used Webpack with megabyte config files. In 2026 you almost never write a bundler config by hand.

The current shortlist

ToolBest for
ViteApp with HMR (React/Vue/Svelte/Lit). Zero-config dev server, rollup for prod build.
esbuildLibrary build, CLI tool. Single Go binary, ~100× faster than Webpack.
tscPure TypeScript lib. Output is JS, no bundling — just transpilation.
NothingTiny app + import maps (C3-06). Production-viable for <50KB apps.
WebpackLegacy app you inherited. Don't start new projects here.
Turbopack / RspackBleeding-edge experiments at scale (Vercel / Mozilla). Production-ready for some teams.

When to use which

  • You're building a Next.js / Remix / Astro app — they pick a bundler for you. Don't fight it.
  • You're building a SPA from scratch in 2026 — Vite. Default React/Vue/Svelte templates start here.
  • You're publishing an npm library — esbuild or tsup (wraps esbuild). Output ESM + types.
  • You're doing a personal project < 50KB — try no-bundler with import maps. It's surprisingly liveable.

The bundle-analysis habit

After every release: npm run build && open dist/stats.html (most bundlers ship a stats reporter). Look for surprise modules eating MB. Common culprits: moment (use date-fns), full lodash (use lodash-es + tree-shaking), polyfills you don't need on modern browsers.

🔒

Zaregistruj sa a začni programovať

Teória je otvorená pre každého. Editor, živý náhľad a kontrola sa odomknú so 7-dňovou bezplatnou skúškou — karta potrebná, zruš kedykoľvek.

Registrácia — bezplatná skúška →

Prvých 10 lekcií v každej trase je zdarma. Karta nie je potrebná.

← PredchádzajúcaĎalšia lekcia →

Jeden tip k Pythonu alebo webu denne — e-mailom

Krátke, ručne písané, žiadny spam. Odhlásiť jedným klikom.