VSCode: How to debug node.js dependency packages in TypeScript

Viewed 284

Assuming we have two node.js projects with the following structure:
Projects Structure
Project Foo has Bar as a dependency by declaring the following in its package.json

{
    "scripts": {
        "start": "ts-node src/index.ts --transpile-only --no-lazy"
    },
    "dependencies": {
        "bar": "file:../Bar"
    }
}

And I configure VSCode's debugger with the following launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "start",
            "request": "launch",
            "runtimeArgs": [
                "start"
            ],
            "runtimeExecutable": "npm",
            "smartStep": true,
            "type": "node"
        }
    ]
}

And the problem is when I step into a function imported from Bar during debugging, it'll go into a temporary compiled js source instead of the original TypeScript source, no matter I define Bar's package main entry as src/index.ts or lib/index.js. Besides, if I add breakpoints in Bar's typescript sources, they won't even be loaded.
How can I make the debugger load Bar's breakpoints, and go directly into the TypeScript sources when debugging Foo? Should I modify some properties in launch.json, or pass some more options to ts-node in the start script?
To better illustrate this problem, I've uploaded the two demo projects to GitHub: StackOverflow-Demo

0 Answers
Related