CodeVetter · Repo Unpack · Data flow
rolldown/rolldown
Options pass through JavaScript validation and hook processing before becoming binding inputs. Sources arrive through plugin load hooks or filesystem reads and become module, AST, symbol, and statement tables. Linking determines retained behavior, and generation turns that state into chunks and assets. State lifetime and error handling differ between independent builds and retained watch sessions.
- rolldown() validates input before options hooks; each output operation validates output before createBundlerOptions combines the retained input and current output settings.
- createBundlerOptions normalizes input/output plugins, runs outputOptions hooks, builds PluginContextData, and returns binding input/output options, a parallel-plugin registry, and worker cleanup.
- load_source prioritizes plugin output, appends load sourcemaps and side-effect metadata, and uses asserted module types only when the plugin supplied no type.
- Without plugin source, load_source reads resolved paths as text or bytes according to module type; native reads use spawn_blocking, while wasm branches read directly through FileSystem.
- NormalizedScanStageOutput carries module and AST tables, per-module statement information, entry points, symbols, dynamic-import usage, and top-level-await metadata; snapshots clone ASTs into another arena and omit symbol scoping.
- LinkStage sorts modules and computes TLA/export kinds before wrapping, side-effect analysis, import/export binding, reference analysis, cross-module optimization, statement inclusion, and dependency patching.
- GenerateStage finalizes the chunk plan before sealing symbol liveness; it derives and commits cross-chunk links, then resolves file URLs, finalizes modules, and renders assets.
- After generation, additional emitted files and generateBundle mutations enter output; filenames are validated before writing, and writeBundle runs after filesystem writes. Binding build errors become BindingErrors, while successful results become RolldownOutputImpl.