Feature request: Provide more diagnostics information for source mapping
We've seen several users run into issues while trying to use a Debugger in VS Code with source mapping for JavaScript projects (From TypeScript, React-Native, etc...). It's not trivial to configure your build project to generate the correct source maps, and it's difficult to understand if, and when they are wrong.
I'd be amazing if you could add better diagnostic tools so it'd be easier for the users to debug these kind of issues. For example, you could add a new feature that when you put a breakpoint on TypeScript, if you hover over it you'll see a tooltip that shows you a snippet from the mapped JavaScript code, and where was the breakpoint put exactly on the JavaScript code. You could also have a "More info" button on that tooltip, that would decode the values that are included in the source map, and show you exactly how the source map says the characters around the breakpoint should be mapped to the source code.
We've also noticed that sometimes if you put breakpoints and the source map is not completely valid, the breakpoints might disappear completely, or appear at the end of the file. It'd be nice if you could also have more validations around this (for example check that the breakpoint line should be less than the total lines of the file where you are putting that breakpoint), and show a nice error message with diagnostic information when something doesn't appear to be right, instead of just "ignoring" that breakpoint or error silently.
For more information you can see an issue that was created against our extension: https://github.com/Microsoft/vscode-react-native/issues/206#issuecomment-209109389
@digeff thanks for these great suggestions. Two comments:
- source maps are a JavaScript specific concept and as such are an implementation detail of the node debug adapter. VS Code is not aware of their existence: there is not a single line of source map code in VS Code. This limits what we can do in the UI because debug extensions cannot extend the UI on their own (without involving VS Code). Showing anything in the UI would involve UI extensions, debug protocol changes. We will consider this, but not in the April sprint (because I'm no vacation).
- You can turn on source map diagnostic by adding a
"trace": "sm"to the launch config. This will send source map diagnostics information to the debug console.
/cc @egamma
@weinand The trace option is very useful for debugging! Thanks! :)
@weinand does the trace no longer work? I tried it in my launch config and the tool tip said no worky and i got not output. trying to debug some weirness with breakpoint in transpiled code....
@acinader the "trace" option only works for "type": "node" not for "type": "node2".
This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.
If you wonder what we are up to, please see our roadmap and issue reporting guidelines.
Thanks for your understanding and happy coding!