microsoft / vscode-js-debug

A DAP-compatible JavaScript debugger. Used in VS Code, VS, + more
MIT License
1.65k stars 274 forks source link

Can't make sourceMapPathOverrides to work #2032

Closed DamienCassou closed 1 month ago

DamienCassou commented 2 months ago

I'm trying to use dapDebugServer with this configuration:

{
  "sourceMapPathOverrides" : {
    "?:*/webpack:/@foretagsplatsen/country/*" : "/home/cassou/myproject/*"
  }
}

But paths are not rewritten:

{
  "seq": 294,
  "type": "event",
  "event": "loadedSource",
  "body": {
    "reason": "new",
    "source": {
      "name": "/home/cassou/myproject/src/app/webpack:/@foretagsplatsen/country/src/app/page.jsx",
      "path": "/home/cassou/myproject/src/app/webpack:/@foretagsplatsen/country/src/app/page.jsx",
      "sourceReference": 734626073
    }
  }
}
connor4312 commented 2 months ago

Please share your log file using the instructions in the issue template. Thanks!

DamienCassou commented 2 months ago

Thank you for your answer @connor4312. I had a look at the log file and saw that what I thought I had to rewrite was already the result of a previous rewrite. I changed the value of sourceMapPathOverrides and things work fine now:

{
  "webpack://@foretagsplatsen/country/*" : "/home/cassou/myproject/*"
}

Given that the following rewrite is part of the defaults and that it seems it should apply to my case, why do I have to setup my own sourceMapPathOverrides?

{
  'webpack://@?:*/?:*/*': "${workspaceFolder}/*",
}

Could it be that workspaceFolder is undefined for me as I'm not using VSCode but dapDebugServer.js directly?

vscode-debugadapter-921cb9ee.json.gz

connor4312 commented 2 months ago

In those logs I see the source getting parsed successfully, to a path that matches where you set the breakpoint.

{
  "name": "/home/cassou/Documents/projects/ftgp/finsit/frontend/apps/country/src/app/page.jsx",
  "path": "/home/cassou/Documents/projects/ftgp/finsit/frontend/apps/country/src/app/page.jsx",
  "sourceReference": 0
}
DamienCassou commented 1 month ago

I will close the issue as the initial problem is solved and will open a clearer one when I come back to this. Thank you for your constant help.