CodeVetter · Repo Unpack · Feature catalog
webpack/webpack
There are no routes or screens; the user-facing surface is the config schema, the CLI shim, and the exported plugin classes. `schemas/WebpackOptions.json` defines 36 top-level options and 12 `experiments` flags, each of which maps to plugins wired in `WebpackOptionsApply`/`defaults.js`. Language support is organized as parser+generator+printer triples per module type (javascript, css, html, json, asset, wasm, typescript), most of which webpack implements itself rather than delegating. Beyond bundling proper, the shipped features include Module Federation, HMR and lazy compilation, persistent caching, source maps, code splitting, library output formats, and a stats/reporting layer.
- The config API exposes 36 top-level options — `amd, bail, cache, context, dependencies, devServer, devtool, dotenv, entry, experiments, extends, externals, externalsPresets, externalsType, ignoreWarnings, infrastructureLogging, loader, mode, module, name, node, optimization, output, parallelism, performance, plugins, profile, recordsInputPath, recordsOutputPath, recordsPath, resolve, resolveLoader, snapshot, stats, target, validate, watch, watchOptions` — all validated against one schema.
- Twelve experiment flags gate unreleased surfaces: `asyncWebAssembly, backCompat, buildHttp, cacheUnaffected, css, deferImport, futureDefaults, html, lazyCompilation, sourceImport, syncWebAssembly, typescript`.
- Native CSS and HTML are full pipelines, not loaders: `lib/css/` ships `syntax-parser.js` (14,973 lines), `syntax-printer.js` (4,730) and a generated `data.js` (8,003) of MDN-derived tables; `lib/html/` ships `syntax-parser.js` (13,197, including §13.2 tree construction) and `HtmlGenerator.js`.
- JavaScript is parsed by webpack's own acorn-derived parser (`lib/javascript/syntax-parser.js`, 17,844 lines) feeding `JavascriptParser.js` (7,604 lines) which raises the hook surface every dependency plugin taps (`evaluateIdentifier`, `call`, `expression`, …).
- Minification defaults to one `minimizer-webpack-plugin` instance sharing a single worker-thread pool across up to three `minify` functions dispatched by extension — `jsMinify` (`[cm]?js`), `cssMinify` (`css`) and `htmlMinify` (`html`) — and steps aside entirely when `getClaimedAssetTypes` finds a user-configured minimizer for that type.
- `jsMinify` reaches terser through `webpack.javascript.syntax.printer.load()` rather than `require("terser")`, so phases webpack has reimplemented replace terser's own; it is re-required as `require("webpack")` inside the worker because the plugin ships the function to the pool as source.
- Module Federation ships as 18 files in `lib/container/` (`ModuleFederationPlugin`, `ContainerPlugin`, `ContainerReferencePlugin`, `RemoteModule`, `RemoteRuntimeModule`, `HoistContainerReferencesPlugin`) plus 15 in `lib/sharing/` (`SharePlugin`, `ConsumeSharedPlugin`, `ProvideSharedPlugin`, `ShareRuntimeModule`, and a bundled `semver.js`).
- HMR is `HotModuleReplacementPlugin` (1,000+ lines) taps on `compilation.hooks.record`, `fullHash`, `processAssets` and `additionalTreeRuntimeRequirements`, plus three generated runtime files and a `parserHooks.js` module that exposes the `module.hot` parser surface to other plugins.
- Lazy compilation runs a real HTTP(S) server in-process: `lazyCompilationBackend.js` creates a server (protocol from `options.protocol`, `https` when configured), tracks `activeModules` refcounts keyed by module, and destroys sockets on close.
- `experiments.buildHttp` turns on `HttpUriPlugin`, which fetches `http:`/`https:` modules, honours `options.proxy` or `http_proxy`/`HTTP_PROXY`, enforces an `allowedUris` policy on both the initial URL and every redirect, and records resolutions into a lockfile (`lockfileLocation`) with bodies cached under `<lockfile>.data`.
- Output-shaping plugins are grouped in `lib/output/`: `CopyPlugin` (the `output.copy` option), `CleanPlugin` (the `output.clean` option, which unlinks and rmdirs inside `output.path`), `BannerPlugin`, and `ManifestPlugin`.
- `DotenvPlugin` is a first-class option (`dotenv` at the top level) that vendors dotenv v17.4.2 parsing and dotenv-expand v13.0.0 expansion, reading `.env`, `.env.local`, `.env.[mode]`, `.env.[mode].local` and feeding the values through `DefinePlugin`.
- Progress reporting is auto-applied from `infrastructureLogging.progress`: `"auto"` enables it only when not `appendOnly` (i.e. a TTY), `true` forces it unless logging level is `none`, and a user-supplied `ProgressPlugin` suppresses the default one; a `MultiCompiler` gets one aggregated reporter rather than one per child.
- The CLI binary is a shim, not the CLI: `bin/webpack.js` enables Node's on-disk compile cache, checks whether `webpack-cli` is installed, and `cp.spawn`s the package manager to install it interactively if not.
- Stats are a separate reporting subsystem: `Stats`/`MultiStats` render through `DefaultStatsFactoryPlugin` (2,903 lines), `DefaultStatsPresetPlugin` and `DefaultStatsPrinterPlugin` (1,777 lines), all applied unconditionally by `WebpackOptionsApply`.