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.
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:

