CodeVetter · Repo Unpack · Feature catalog
vitejs/vite
Vite's user-facing surface is four CLI commands, a programmatic JS API, a Rollup-superset plugin hook system, and a browser-side HMR runtime with an error overlay. Around that sit optional subsystems: dependency pre-bundling, CSS preprocessing and modules, worker/WASM/asset handling, `import.meta.glob`, SSR module running, and the legacy-browser plugin. `create-vite` is an independent interactive scaffolder with eleven framework families. The most recently added features are the multi-environment builder (`--app` / `builder: {}`), console forwarding from browser to terminal, and `--experimentalBundle` bundled dev.
- `vite dev` accepts `--host`, `--port`, `--open [path]`, `--cors`, `--strictPort`, `--force` (bust the optimizer cache) and `--experimentalBundle`, then prints URLs and installs CLI shortcuts, adding a `p` shortcut to toggle the CPU profiler when launched under `--profile`.
- `vite build` exposes `--target`, `--outDir`, `--assetsDir`, `--assetsInlineLimit`, `--ssr [entry]`, `--sourcemap [inline|hidden]`, `--minify [oxc|terser|esbuild]` (default `oxc`), `--manifest`, `--ssrManifest`, `--emptyOutDir`, `-w/--watch`, and `--app` which is sugar for `builder: {}`.
- Interactive terminal shortcuts during dev are `r` restart server, `u` show server url, `o` open in browser, `c` clear console, `q` quit; preview mode registers only `o` and `q`.
- The dev server exposes built-in HTTP endpoints beyond module serving: `/__open-in-editor` (via `launch-editor-middleware`), a `viteHMRPingMiddleware` answering `accept: text/x-vite-ping` with 204, and `/@fs/` raw filesystem serving guarded by the allow-list.
- A dev proxy is available via `server.proxy`, backed by `http-proxy-3`, supporting `rewrite`, `configure`, webpack-dev-server-style `bypass`, WebSocket proxying, and `rewriteWsOrigin` to rewrite the Origin header on WS upgrades.
- The browser client ships an error overlay implemented as the custom element `vite-error-overlay` (`class ErrorOverlay extends HTMLElement`), gated by the injected `__HMR_ENABLE_OVERLAY__` define and creatable/clearable from `handleMessage`.
- Dependency pre-bundling is a full subsystem: `scanImports` computes entries and runs a Rolldown scanner, `runOptimizeDeps` writes a `_metadata.json` cache under `getDepsCacheDir(environment)`, and `loadCachedDepOptimizationMetadata` / `cleanupDepsCacheStaleDirs` manage reuse and GC across runs.
- The built-in plugin pipeline provides asset handling, CSS (`cssPlugin`/`cssPostPlugin`/`cssAnalysisPlugin`), HTML (`htmlInlineProxyPlugin`/`buildHtmlPlugin`), web workers (`webWorkerPlugin`, `workerImportMetaUrlPlugin`), WASM (`wasmHelperPlugin`), `define`, `import.meta.glob` (`importGlobPlugin`), dynamic-import variables, and module-preload polyfill.
- Browser console forwarding to the terminal is opt-in via `server.forwardConsole.enabled`, which conditionally inserts `forwardConsolePlugin({ environments: ['client'] })` into the pipeline and is picked up client-side through the `__SERVER_FORWARD_CONSOLE__` define.
- SSR is served by `fetchModule(environment, url, importer)`, which short-circuits `data:` URLs and Node builtins to `{externalize, type:'builtin'}`, external URLs to `type:'network'`, and otherwise resolves bare specifiers through `tryNodeResolve` with `externalConditions`.
- `vite/module-runner` is a separately published runtime: `class ModuleRunner` with `evaluatedModules`, a pluggable `transport` that `invoke('fetchModule', ...)`s the server, optional HMR via `createHMRHandlerForRunner`, and `cachedRequest`/`directRequest` for circular-dependency-aware evaluation.
- `create-vite` v9.2.1 is an interactive prompt-driven scaffolder over a `FRAMEWORKS` table covering vanilla, vue, react, preact, lit, svelte, solid and qwik, each with TS/JS variants plus links to external starters (Nuxt, Vike, Official Vue Starter), materialised from the sibling `template-*` directories.
- `@vitejs/plugin-legacy` v8.2.3 returns a plugin array (`legacyConfigPlugin`, `legacyGenerateBundlePlugin`, `legacyPostPlugin`) that runs `detectPolyfills`, transforms modern chunks to SystemJS via `@babel/plugin-transform-modules-systemjs`, injects `systemjs/dist/s.min.js`, and emits a `systemjs-importmap` script tag.
- Experimental full-bundle dev mode (`--experimentalBundle` → `config.experimental.bundledDev`) replaces the transform/static middlewares with `triggerLazyBundlingMiddleware` + `memoryFilesMiddleware` and is driven by the `BundledDev` class holding a `MemoryFiles` map and a Rolldown dev engine started with `experimental.devMode = { lazy: true }`.