vscode debug typescript compiled in docker container unbound breakpoint

Viewed 540

Most of the debugging recipes for VSCode + Typescript + Docker that I've seen assume that one is mounting the dist/ folder as a container volume. I'm mounting the src/ folder only and compiling the Typescript inside the container, and I'm not quite sure how that would affect my launch.json configuration. Am I missing something from my config given that I only compile inside the container? Can VSCode even support this? The docs aren't super clear about it.

My npm start script:

{
  "scripts": {
    "start": "tsc --build tsconfig.json && tsc-watch --onSuccess \"node --inspect=0.0.0.0:9229 ./dist/index.js\""
  } 
}

My tsconfig.json:

{
  "compilerOptions": {
    "outDir": "./dist",
    "allowJs": true,
    "esModuleInterop": true,
    "incremental": true,
    "sourceMap": true,
    "target": "es5"
  },
  "include": [ "./src/**/*" ],
  "exclude": [ "node_modules" ]
}

My launch.json debugger config:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Docker: Attach to Node",
      "type": "pwa-node",
      "request": "attach",
      "port": 9229,
      "address": "localhost",
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "/path/in/container",
      "restart": true,
      "resolveSourceMapLocations": [
        "${workspaceFolder}/**",
        "!**/node_modules/**"
      ],
      "skipFiles": [
        "<node_internals>/**/*.js"
      ]
    }
  ]
}

When I start the debugger, it appears to attach (I get container logs in the debug console), but then my breakpoints are always unbound, so I'm not sure if it's a problem related to my mount/compile setup, or if that's fine but VSCode is just not able to bind the breakpoints.

Any help greatly appreciated!

0 Answers
Related