# Behavior traces — web-infra-dev/rspack

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

# Behavior traces — web-infra-dev/rspack

Scanned commit 179a0934f3091463419827fc2767af07b2fd38ed (2026-10-01). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Four concrete source traces were followed: CLI startup and build, asset emission, watch rebuild, and experimental filesystem-cache persistence. Their order crosses JavaScript callbacks and asynchronous Rust execution. Several lifecycle hooks can suppress output, request another pass, or delay shutdown. The traces describe implemented control flow without asserting successful execution.
- Startup proceeds runCLI → new RspackCLI → run → registerCommands → each command.apply → CAC.parse; run then awaits the action promise captured by wrapAction. — [packages/rspack-cli/bin/rspack.js#L17-20](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack-cli/bin/rspack.js#L17-L20) [packages/rspack-cli/src/cli.ts#L83-92](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack-cli/src/cli.ts#L83-L92) [packages/rspack-cli/src/cli.ts#L181-201](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack-cli/src/cli.ts#L181-L201)
- Build startup proceeds runBuild → setDefaultNodeEnv/normalizeCommonOptions → buildCompilerConfig → loadConfig/buildConfig → createCompiler; a watch compiler returns immediately, while a one-shot compiler runs and closes before reporting stats. — [packages/rspack-cli/src/commands/build.ts#L23-25](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack-cli/src/commands/build.ts#L23-L25) [packages/rspack-cli/src/cli.ts#L95-121](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack-cli/src/cli.ts#L95-L121) [packages/rspack-cli/src/commands/build.ts#L103-117](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack-cli/src/commands/build.ts#L103-L117)
- Compiler.run rejects concurrent execution, invokes beforeRun → run → compile, and may repeat compile after needAdditionalPass and additionalPass before its final done callback. — [packages/rspack/src/Compiler.ts#L563-565](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack/src/Compiler.ts#L563-L565) [packages/rspack/src/Compiler.ts#L595-622](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack/src/Compiler.ts#L595-L622) [packages/rspack/src/Compiler.ts#L625-646](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack/src/Compiler.ts#L625-L646)
- Compiler.compile invokes beforeCompile → compile hook → #build; initial #build calls JsCompiler.build, whose callbackified future calls Rust Compiler.build → build_inner → compile → after_compile → compile_done. — [packages/rspack/src/Compiler.ts#L798-818](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack/src/Compiler.ts#L798-L818) [packages/rspack/src/Compiler.ts#L850-865](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack/src/Compiler.ts#L850-L865) [crates/rspack_binding_api/src/lib.rs#L440-463](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/crates/rspack_binding_api/src/lib.rs#L440-L463) [crates/rspack_core/src/compiler/mod.rs#L320-330](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/crates/rspack_core/src/compiler/mod.rs#L320-L330)
- Output proceeds compile_done → should_record → should_emit; unless should_emit returns false, emit_assets resolves output.path, runs cleaning, calls emit, writes selected assets, and calls after_emit. — [crates/rspack_core/src/compiler/mod.rs#L386-439](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/crates/rspack_core/src/compiler/mod.rs#L386-L439) [crates/rspack_core/src/compiler/mod.rs#L447-493](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/crates/rspack_core/src/compiler/mod.rs#L447-L493)
- A watch invalidation merges changed/removed paths and either queues invalidation during a running build or enters #go; #go pauses the watcher, assigns deltas, invokes watchRun → compile, and completed delivery watches current dependency sets again. — [packages/rspack/src/Watching.ts#L251-290](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack/src/Watching.ts#L251-L290) [packages/rspack/src/Watching.ts#L313-359](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack/src/Watching.ts#L313-L359) [packages/rspack/src/Watching.ts#L473-490](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack/src/Watching.ts#L473-L490)
- Subsequent #build calls JsCompiler.rebuild with file arrays; Rust rebuild_inner clears resolver/plugin caches, creates a hot Compilation, stores the previous compilation in IncrementalArtifacts, then compiles and emits through compile_done. — [packages/rspack/src/Compiler.ts#L850-864](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack/src/Compiler.ts#L850-L864) [crates/rspack_binding_api/src/lib.rs#L478-496](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/crates/rspack_binding_api/src/lib.rs#L478-L496) [crates/rspack_core/src/compiler/rebuild.rs#L73-134](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/crates/rspack_core/src/compiler/rebuild.rs#L73-L134)
- Experimental persistence proceeds create_cache → IdleFileCache background job → FileCacheStrategy.db_init/validation; build completion calls cache.beginIdle, while Compiler.close calls cache.shutdown, whose binding awaits native shutdown before native compiler close. — [crates/rspack_core/src/new_cache/mod.rs#L70-94](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/crates/rspack_core/src/new_cache/mod.rs#L70-L94) [crates/rspack_core/src/new_cache/idle_file_cache.rs#L54-88](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/crates/rspack_core/src/new_cache/idle_file_cache.rs#L54-L88) [packages/rspack/src/Compiler.ts#L572-575](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack/src/Compiler.ts#L572-L575) [packages/rspack/src/Compiler.ts#L832-847](https://github.com/web-infra-dev/rspack/blob/179a0934f3091463419827fc2767af07b2fd38ed/packages/rspack/src/Compiler.ts#L832-L847)

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)
