CodeVetter · Repo Unpack · Behavior traces
web-infra-dev/rspack
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.
- 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.
- Compiler.run rejects concurrent execution, invokes beforeRun → run → compile, and may repeat compile after needAdditionalPass and additionalPass before its final done callback.
- 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.
- 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.
- 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.
- 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.
- 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.