Question presented to candidate: "Why does a React project need a bundler at all? What is Webpack β or Vite β actually doing between your source files and the browser?"
What a strong answer should cover:
- Two non-negotiable jobs: browsers cannot run JSX, and bare module specifiers like
import React from "react"are not resolvable by the browser. - Module resolution and dependency graphing β following imports from an entry point.
- Transformation β JSX and modern syntax through a compiler (Babel, SWC, esbuild, oxc).
- Bundling and code splitting β combining modules, then splitting them again at route or
import()boundaries. - Optimisation β minification, tree shaking (helped by the
/* @__PURE__ */annotations the JSX transform emits), and content hashing for cache busting. - Asset handling β CSS, images, fonts as importable modules.
- Dev server with HMR, which is what preserves component state across edits.
- The modern landscape: Webpack is the incumbent; Vite (Rollup/Rolldown + native ESM in dev) is the current default; Turbopack and Rspack are the Rust-based successors.
- The architectural point: Webpack bundles before serving; Vite serves native ES modules on demand β that is why dev startup differs so much.
Clarifying questions expected:
- "Are we talking about the development experience or the production build?" β the tools behave very differently in each.
Code / implementation expected: No. Being able to describe the pipeline and name what each stage produces is what is being tested.