go install github.com/go-delve/delve/cmd/dlv@latest@rspack/cli and napi binding by run pnpm install && pnpm -w build:cli:devRun and Debug tab, select Debug Rspack to start debugging the initial launch of @rspack/cli with a simple rspack project. This task can be configured in .vscode/launch.json.Simply set breakpoints in the specified Rust code and start Debug Rspack to begin debugging.
When starting Debug Rspack, select the --inspect or --inspect-brk option, then start Attach JavaScript and choose the PID of the corresponding 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.
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 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: