nvim-dap
nvim-dap copied to clipboard
[Typescript] Cannot debug projects with ES Modules (works with CommonJS)
Debug adapter definition and debug configuration
dap.adapters["pwa-node"] = {
type = "server",
host = "localhost",
port = "${port}",
executable = {
command = js_debug_bin,
args = { "${port}" },
},
options = {
detached = false,
},
enrich_config = function(config, on_config)
-- Under the hood, always use the main adapter
config.type = "pwa-node"
on_config(config)
end,
}
Launch.json config:
{
"name": "Attach to node Process",
"type": "node",
"request": "attach",
"port": 9229,
"skipFiles": [
"<node_internals>/**"
],
"sourceMaps": true
},
Debug adapter version
v1.104.0
Steps to Reproduce
- In a Node ESM TypeScript project where stack frames reference sources as relative paths (e.g., “../src/foo.ts”).
- Set breakpoints in a “src/*” file before attaching.
- Attach to the running process with the config above, continue to a point that should hit the breakpoint.
Expected Result
- Breakpoints bind immediately and the editor shows the local workspace file content.
Actual Result
- Breakpoints works
- The launch.json config works in VS code
I vibe coded a fix for this, but not comfortable enough (yet) with the DAP protocol to open a PR .
In short, it seems like registering breakpoints with ESM project requires a different flow than the normal one and relies on source reference instead of just source.path.
The impl. is accessible here.
Can you post logs and a complete but minimal reproduction?
Closing due to lack of feedback and given that I suspect this is either a debug adapter problem or configuration issue, not a client bug.