I'm trying to debug an application in a multi-root project structure ( the root folder containing multiple projects ) and I'm having trouble getting vscode's debugger to recognize the sourcemaps that babel generates.
I have this in my launch.json
{ "configurations": [ { "console": "integratedTerminal", "internalConsoleOptions": "neverOpen", "name": "nodemon", "program": "${workspaceFolder}/project/index.js", "request": "launch", "cwd": "${workspaceFolder}/project", "restart": true, "sourceMaps": true, "runtimeExecutable": "nodemon", "runtimeArgs": [ "--inspect", "--exec", "${workspaceFolder}/node_modules/.bin/babel-node --config-file ./.babelrc.js", ], "skipFiles": [ "<node_internals>/**", ], "type": "pwa-node" } ] } .babelrc.js
module.exports = { "sourceMaps": "both", "presets": [ [ "@babel/env", { "targets": { "node": "current" } }] ], "plugins": [ "@babel/plugin-proposal-class-properties", "source-map-support" ], } and my index.js file
require('source-map-support/register') require('@babel/register'); require('@babel/polyfill'); require('./app.js'); When I add a breakpoint, it adds it to another location, when I click on the breakpoint itself, it opens up the compiled file and I see that the breakpoint is at the wrong location. I also see that the sourcemaps have been inlined, but it appears that vscode does not parse them properly, or not parse them at all.
I tried to play around with the settings involving the word sourcemap in their name, none of them seemed to work.
If I open the project the same way in Webstorm and attach to the running process, it parses the sourcemaps properly and stops where necessary, but vscode is unable to do so, for some reason.
I tried to open just this one project in vscode and move the .vscode folder inside of the project folder, but it didn't yield any results whatsoever, so I think it is irrelevant, I just decided to mention it if it helps with the issue.