# Behavior traces — rolldown/rolldown

> Canonical page: https://codevetter.com/unpack/rolldown/behavior-traces

# Behavior traces — rolldown/rolldown

Scanned commit 37d60ff510b4b326f4b587c27f28c606d76373e8 (2026-10-02). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

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. — [packages/rolldown/bin/cli.mjs#L1-11](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/bin/cli.mjs#L1-L11) [packages/rolldown/src/cli/index.ts#L9-54](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/src/cli/index.ts#L9-L54)
- 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. — [packages/rolldown/src/cli/commands/bundle.ts#L15-29](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/src/cli/commands/bundle.ts#L15-L29) [packages/rolldown/src/utils/load-config.ts#L77-84](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/src/utils/load-config.ts#L77-L84) [packages/rolldown/src/utils/load-config.ts#L143-185](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/src/utils/load-config.ts#L143-L185)
- 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. — [packages/rolldown/src/cli/commands/bundle.ts#L25-42](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/src/cli/commands/bundle.ts#L25-L42) [packages/rolldown/src/cli/commands/bundle.ts#L152-186](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/src/cli/commands/bundle.ts#L152-L186)
- Programmatic flow: rolldown validates input and calls options hooks → constructs RolldownBuild/startAsyncRuntime → generate/write invokes #build → createBundlerOptions → BindingBundler.generate/write → ClassicBundler.create_bundle. — [packages/rolldown/src/api/rolldown/index.ts#L39-42](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/src/api/rolldown/index.ts#L39-L42) [packages/rolldown/src/api/rolldown/rolldown-build.ts#L29-34](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/src/api/rolldown/rolldown-build.ts#L29-L34) [packages/rolldown/src/api/rolldown/rolldown-build.ts#L124-142](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/src/api/rolldown/rolldown-build.ts#L124-L142) [crates/rolldown_binding/src/binding_bundler.rs#L39-66](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/crates/rolldown_binding/src/binding_bundler.rs#L39-L66)
- 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. — [crates/rolldown/src/bundle/bundle.rs#L45-79](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/crates/rolldown/src/bundle/bundle.rs#L45-L79) [crates/rolldown/src/stages/scan_stage.rs#L182-205](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/crates/rolldown/src/stages/scan_stage.rs#L182-L205) [crates/rolldown/src/bundle/bundle.rs#L139-147](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/crates/rolldown/src/bundle/bundle.rs#L139-L147) [crates/rolldown/src/bundle/bundle.rs#L274-338](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/crates/rolldown/src/bundle/bundle.rs#L274-L338)
- Build cleanup: RolldownBuild.close claims runtime release before awaiting → stops workers → awaits BindingBundler.close → releases the runtime in finally; asyncDispose delegates to close. — [packages/rolldown/src/api/rolldown/rolldown-build.ts#L92-110](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/src/api/rolldown/rolldown-build.ts#L92-L110) [crates/rolldown_binding/src/binding_bundler.rs#L181-195](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/crates/rolldown_binding/src/binding_bundler.rs#L181-L195)
- 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. — [packages/rolldown/src/api/watch/index.ts#L37-40](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/src/api/watch/index.ts#L37-L40) [packages/rolldown/src/api/watch/watcher.ts#L69-88](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/src/api/watch/watcher.ts#L69-L88) [packages/rolldown/src/api/watch/watcher.ts#L111-136](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/packages/rolldown/src/api/watch/watcher.ts#L111-L136) [crates/rolldown_watcher/src/watch_coordinator.rs#L108-142](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/crates/rolldown_watcher/src/watch_coordinator.rs#L108-L142)
- 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. — [crates/rolldown_watcher/src/watch_coordinator.rs#L57-99](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/crates/rolldown_watcher/src/watch_coordinator.rs#L57-L99) [crates/rolldown_watcher/src/watch_coordinator.rs#L145-180](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/crates/rolldown_watcher/src/watch_coordinator.rs#L145-L180) [crates/rolldown_watcher/src/watch_task.rs#L87-125](https://github.com/rolldown/rolldown/blob/37d60ff510b4b326f4b587c27f28c606d76373e8/crates/rolldown_watcher/src/watch_task.rs#L87-L125)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
