CodeVetter · Repo Unpack · Behavior traces
rolldown/rolldown
Three concrete flows were followed through their implementations: CLI config bundling, programmatic output generation/writing, and watch initialization/rebuild. The traces preserve meaningful branches such as native versus bundled config loading and generate versus write. Cleanup and recovery are part of the observed behavior, including worker/runtime release and watch registration after failed scans.
- CLI startup: bin/cli.mjs imports dist/cli.mjs → CLI checks Node compatibility → main calls parseCliArguments → applies environment assignments → selects help, version, config bundling, positional bundling, or help fallback.
- Config flow: bundleWithConfig sets watch environment flags when needed → loadConfig discovers/selects the loader → bundled TS configs pass through bundleTsConfig and dynamic import with unlink cleanup; native loading uses freshImport or a timestamped import.
- Config output flow: resolve the config function with rawArgs → bundleInner iterates configs → rolldown merges CLI input overrides → sequential build.write calls merge output overrides → finally build.close → output-size reporting.
- Programmatic flow: rolldown validates input and calls options hooks → constructs RolldownBuild/startAsyncRuntime → generate/write invokes #build → createBundlerOptions → BindingBundler.generate/write → ClassicBundler.create_bundle.
- Core output flow: Bundle.generate/write → scan_modules → ScanStage.scan/build_start/fetch_modules → build_end → bundle_up → LinkStage.link → GenerateStage.generate → additional files/generate_bundle → filename validation; write additionally performs filesystem writes/write_bundle.
- Build cleanup: RolldownBuild.close claims runtime release before awaiting → stops workers → awaits BindingBundler.close → releases the runtime in finally; asyncDispose delegates to close.
- Watch startup: watch returns WatcherEmitter while createWatcher asynchronously runs per-output options hooks/createBundlerOptions → constructs BindingWatcher → starts the runtime → schedules run on nextTick → coordinator emits START and builds each task.
- Watch rebuild: file messages enter debounce processing → run_build_sequence dispatches changes/watchChange/restart/START → affected tasks build; WatchTask clears resolution/tsconfig caches, scans, registers watches before checking scan errors, and selects bundle_generate when skipWrite is set.