Debugging
Debugging with VS Code
- Install
go install github.com/go-delve/delve/cmd/dlv@latest - Install VS Code extension rust-analyzer and CodeLLDB
- build
@rspack/cliand napi binding by runpnpm install && pnpm -w build:cli:dev - In VS Code's
Run and Debugtab, selectDebug Rspackto start debugging the initial launch of@rspack/cliwith a simple rspack project. This task can be configured in.vscode/launch.json.
Using @rspack-debug/core
Frameworks and tools that integrate Rspack usually depend on the release build of @rspack/core. The release package is suitable for normal builds, but it does not include some debug-only capabilities. When you need these capabilities for local investigation, override @rspack/core with @rspack-debug/core in the project that runs the build.
For example, with pnpm:
Then reinstall dependencies and run the original build command again. For example, if the project builds through Rsbuild:
@rspack-debug/core should only be used for local debugging and diagnostics. Prefer pinning it to the same version as the original @rspack/core dependency when investigating a version-specific issue, and remove the override after the investigation.
Common debugging scenarios guide
Debugging Rust
Simply set breakpoints in the specified Rust code and start Debug Rspack to begin debugging.
Debugging JavaScript
When starting Debug Rspack, select the --inspect or --inspect-brk option, then start Attach JavaScript and choose the PID of the corresponding process.
Debugging a running Rspack process
When Rspack is integrated into other frameworks or tools (such as Nx), it may be difficult to independently start Rspack in Launch mode. In this case, you can debug the code through attach mode. Start Attach Rust and select the PID of the Rspack process, and start Attach JavaScript to debug JavaScript.
Debugging a Rspack process with a deadlock
When using Attach Rust to attach the debugger to the Rspack process, click the Pause button on the Debugger to set breakpoints at the deadlock scene.
rust-lldb
rust-lldb can be used to get panic information from debug builds
Once it launches, press r for running the program.
For example, examples/arco-pro crashes without any information before this fix:
Using rust-lldb
Press r and it prints:

