Skip to content

Debugging with babel-register + NodeJs does not work #5728

@mattflix

Description

@mattflix
  • VSCode Version: 1.0.0
  • OS Version: Mac OS 10.11.3

Setup Steps:

  1. Download and expand NodeJsWithBabelDebuggingExample.ZIP
    into a local folder.
  2. Open the Terminal and point it to the folder from Step 1.
  3. Run npm install (to install the Babel dependencies).
  4. Run npm start (to demonstrate that the project is working Node program) which should produce a few lines of output and no errors.

Steps to Reproduce (on Mac OS):

  1. In VS Code, open the folder created in the steps above.
  2. Press F5 to start debugging the program.
  3. Observe the debugger break at line 1 of ./index.js, which is a comment. (This is the first sign of trouble.)
  4. Repeatedly press F10 (to step) and observe the debugger break on various other lines of ./index.js that have nothing to do with the code being executed.

Apparently, the inline source map generated by Babel is either being missed, ignored, or misinterpreted. It is also possible that the source map may be faulty, but seeing as a similar setup using other tools (such as Chrome Dev Tools) results in accurate debugging (and only when the source map is supplied) suggests that this is not the case.

Btw, VS Code gives zero feedback (as far as I can see) as to whether a source map was found and/or is being used, making it almost impossible to diagnose this type of trouble.

A few questions:

  1. Have a done something wrong in this setup? Is there something wrong or missing in my launch.json or package.json (where the Babel settings are)?
  2. Are there some diagnostics that I can enable in VS Code to help determine what is going wrong?
  3. Should I even expect to be able to successfully perform source-level debugging of dynamically-transpiled code with VS Code like this, or not? (Other tools can do it, so I will be disappointed if this is not a supported use-case for VS Code.)

The VS Code web pages (https://code.visualstudio.com/docs/editor/debugging) certainly make this sound like I should reasonably expect debugging to work:

Source maps can be generated with two kinds of inlining:

  • Inlined source maps: the generated JavaScript file contains the source map as a data URI at the end (instead of referencing the source map through a file URI).
  • Inlined source: the source map contains the original source (instead of referencing the source through a path).

VS Code supports both the inlined source maps and the inlined source.

As far as I know, setting { "sourceMaps": "inline" } in the Babel configuration (which this project does via package.json) adheres to the first case ("inlined source maps") which the above quote from the VS Code web pages seems to suggest is supported.

Thanks.

Metadata

Metadata

Assignees

Labels

debugDebug viewlet, configurations, breakpoints, adapter issuesfeature-requestRequest for new features or functionalityjavascriptJavaScript support issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions