ganezdragon
ganezdragon

Reputation: 189

VS code debugger not working with babel on async code

Versions used:

VS code: 1.35.1
Babel cli: 7.2.3
node: 10

While using breakpoints on async code, with babel transpiling the original source code, the VS code debugger or any other debugger doesn't work because there is something wrong with the --source-maps that the babel provides.

I faced this problem, and now answering my own question,

Upvotes: 1

Views: 312

Answers (1)

ganezdragon
ganezdragon

Reputation: 189

This is kind of a workaround solution, since I don't know what actually is wrong with the source-maps of babel.

Use targets in babel to define which node version should the output of babel should be. I'm using node 10, and using babel to transpile into node 10 solved my issue. This is my .babelrc file:

{
  "presets": [
    [
      "@babel/preset-env",
      {
        "targets": {
          "node": "10"
        }
      }
    ]
  ],
}

Hope this helps. :)

Upvotes: 1

Related Questions