Debugging Typescript files opens a new window
Hello,
I'm pretty new to js/ts and I tried to setup a standard project with a mocha/chai test but when the debugger reaches my breakpoint it opens a new window for debugging that is different from my original source file which essentially makes the whole process pretty painful to debug.
Below are some captures:
This is before I hit the "debug" button:
And this is after I hit it:
As you can see it opens a second ts file that is a bit different from my original file instead of just stopping on my original file.
This is my `tsconfig.json`:
{
// https://github.com/TypeStrong/ts-node/issues/138#issuecomment-926322588
"ts-node": {
"transpileOnly": true,
"require": [
"typescript-transform-paths/register",
"tsconfig-paths/register"
]
},
"compilerOptions": {
"target": "es2020",
"inlineSourceMap": true,
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"outDir": "dist",
"declaration": true,
"baseUrl": ".",
"paths": {
"@app/*": ["src/*"]
},
"plugins": [
{ "transform": "typescript-transform-paths" }
]
},
"include": ["./scripts", "./test", "./typechain", "./src"],
"files": ["./hardhat.config.ts"]
}
Doing the same thing but with JS files is working perfectly. Any idea how I can fix this? Thanks.
Please sign in to leave a comment.
Here is a test project, you can execute this test directly from Webstorm with the same configuration as above to reproduce the issue.
My version of Webstorm is 2021.3.1 but the same issue happened in previous versions.
Thanks!
I've found out that this is the typescript-transform-paths plugin that breaks the sourcemaps
Debugging works fine if the line
"typescript-transform-paths/register",
is commented out:
Awesome! Indeed it's working now! I removed this dependency from my non-test project and everything is working as expected, I don't even remember what I needed this plugin for. Thanks!
The debugger can't map your original sources to the generated files, looks like a problem with sourcemaps
Could you check if changing
to
makes things any better?
Also, what does your run configuration look like?
It didn't change anything, unfortunately.
Here is my `package.json` configuration:
And my configuration to run the test:
No clues unfortunately, I need a project to play with
Note that you don't need passing
--require ts-node/register
in Node options, having it in Extra mocha options: is enough