microsoft / vscode-js-debug

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

[request] about file breakpoint limit out of project #2113

Closed wjx0912 closed 3 weeks ago

wjx0912 commented 3 weeks ago

in my project, the plugin is load dynamic(after kernel app start):

test1 (all in one repo):
/project/my_repo_kernel_app/.vscode/launch.json
/project/my_repo_kernel_app/src/mysource.ts         // source: pluginMod = require('/project/my_repo_kernel_app/plugin01/file.ts')
/project/my_repo_kernel_app/plugin01/file.ts        // ★★★ the breakpoint work normal.
/project/my_repo_kernel_app/plugin01/file.js
/project/my_repo_kernel_app/plugin01/file.js.map

test2 (two repo: kernel repo, and another plugin repo):
/project/my_repo_kernel_app/.vscode/launch.json
/project/my_repo_kernel_app/src/mysource.ts           // source: pluginMod = require('/project/my_repo_plugin01/file.ts')
/project/my_repo_plugin01/file.ts                     // ★★★ the breakpoint is invalid. (program work normal)
/project/my_repo_plugin01/file.js
/project/my_repo_plugin01/file.js.map

hello, when i debug a dynamic require source 'plugin01/file.ts', if the file in project dir, the breakpoint is normal. after i move to another repo, the breakpoint invalid.

i just modify vscode-js-debug and compile and install: https://github.com/microsoft/vscode-js-debug/blob/v1.95.0/src/targets/sourcePathResolver.ts#L141

    //return l.length > 0;
    return true;

the test2 breakpoint work normal now. it looks like the breakpoint in file(not in current project dir) will ignored. can remove the limit. (Is there such a option in settings or launch.json?)

thanks.

wjx0912 commented 3 weeks ago

in launch.json, i just add :

      "resolveSourceMapLocations": [
      ],

and the breakpoint work normal, does it's recommended resolution?

connor4312 commented 3 weeks ago

Yes, see https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_source-map-discovery