Indium
Indium copied to clipboard
breakpoint doesnt work in node.js with typescript
Hi,
It seems that when setting a breakpoint on a .ts
it doesnt work. adding debugger
manually on the same line works. Also, adding breakpoint with indium on the transpiled .js
file also works fine.
Is that expected?
Thanks
tsconfig:
{
"compilerOptions": {
"module": "commonjs",
"allowJs": true,
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"outDir": "build"
}
}
.indium.json
{
"configurations": [
{
"name": "typescript-project",
"type": "node",
"program": "node12",
"args": "build/main.js"
}
]
}
It's not expected at all. I do not use TypeScript, but sourcemaps should just work.
I'll investigate and will try to reproduce the issue.
Got into the same problem. I think it's related when we use the outDir
option in TypeScript compilation.
In my case, I have the following directory structure:
/home/wmartins/workspace/github.com/wmartins/ts-project
├── dist
│ ├── index.js
│ └── index.js.map
├── index.ts
├── package.json
├── package-lock.json
├── src
└── tsconfig.json
When I run M-x
indium-list-sourcemap-sources
, I get the following sources (all red ones):
/home/wmartins/workspace/github.com/wmartins/index.ts
In this case, it should be (note the ts-project
in the path):
/home/wmartins/workspace/github.com/wmartins/ts-project/index.ts
The funny thing is that when I compile my code without the outDir
option. The result of M-x
indium-list-sourcemap-sources
is correct.
If there's anything that I can help with this investigation, let me know @NicolasPetton!
I got it working fine for my case, however, I had to do some unusual configuration to make it work. I'll explain them here.
- Change
sourceRoot
compilation option.
My tsconfig.json
file:
{
// other options
"sourceRoot": "/"
}
- Run
M-x
indium-launch
in my project root folder (~/workspace/github.com/wmartins/ts-project
).
Now, when I run M-x
indium-list-sourcemap-sources
, the file (I have only index.ts
there) is shown correctly.
The funny thing is that, if I run M-x
indium-launch
in any other folder than the project root (specified in item 2
), my source map sources list turns out to be wrong. For example, when launching it inside dist
folder, I get the following result:
/home/wmartins/workspace/github.com/wmartins/ts-project/dist/index.ts
And, if my sourceRoot
is not /
, the source map list comes all messy, with some wrong folders. I can get some more info on that if necessary.
Also ran into the same issue.