wclr / ts-node-dev

Compiles your TS app and restarts when files are modified.
MIT License
3.42k stars 123 forks source link

Inspect through Docker, wrong sourcemap? #125

Open imsergiobernal opened 4 years ago

imsergiobernal commented 4 years ago

When inspecting throught a docker container, breakpoint behavior looks weird. I think this behavior is done by a wrong source-mapping. image

vscode launch

        {
          "type": "node",
          "request": "attach",
          "name": "Docker: Attach to Node",
          "port": 9229,
          "skipFiles": [
            "<node_internals>/**"
          ],
          "localRoot": "${workspaceRoot}",
          "remoteRoot": "/usr/local/app",
          "sourceMaps": false,
        },

tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": false,
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es6",
    "noImplicitAny": true,
    "moduleResolution": "node",
    "inlineSourceMap": true,
    "inlineSources": true,
    "outDir": "dist",
    "baseUrl": ".",
    "paths": {
      "*": ["node_modules/*", "src/types/*"]
    }
  },
  "include": ["src/**/*"]
}

package.json script (what docker runs) ts-node-dev --files --transpileOnly --watch src/ --inspect=0.0.0.0:9229 -- src/index.ts

dschuessler commented 4 years ago

I second this. If you set a breakpoint at say line 80, the debugger breaks at the code that corresponds to line 80 in the transpiled code, not the source code.

Beleren commented 4 years ago

@imsergiobernal I didn't get it, how does it work if sourceMaps option is not set in tsconfig.json and vscode launch sourceMaps is set to false?

Nevertheless I have the same issue when using debugger attached to docker and it also doesn't generate the .maps inside the container. Breakpoints also doesn't work for some files.

Seqi commented 3 years ago

I had this issue and figured out a solution just now. I fixed this by using the javascript debugger preview. You can achieve this by 2 ways:

StrictLine commented 2 years ago

@imsergiobernal I didn't get it, how does it work if sourceMaps option is not set in tsconfig.json and vscode launch sourceMaps is set to false?

Nevertheless I have the same issue when using debugger attached to docker and it also doesn't generate the .maps inside the container. Breakpoints also doesn't work for some files.

Any progress on this? For me the type is defaulted to pwa-node, so it cannot be the solution.

I've made some research in other threads:

My test scenario

Attach to a running docker container on my QNAP NAS, where ts-node-dev is running and listening on the port 9229 (by --inspect) on every IP. I manage to attach to the debugger, but the breakpoints seem not to work, I guess, because of the reason mentioned in the previous references above.

@delfinof: I'm sorry to mention you so often, but did you open a new issue back then? https://github.com/microsoft/vscode/issues/20355#issuecomment-281843426