Indium icon indicating copy to clipboard operation
Indium copied to clipboard

breakpoint doesnt work in node.js with typescript

Open bobrowadam opened this issue 5 years ago • 4 comments

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"
    }
  ]
}

bobrowadam avatar Feb 22 '20 11:02 bobrowadam

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.

NicolasPetton avatar Mar 10 '20 10:03 NicolasPetton

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!

wmartins avatar Jun 03 '20 13:06 wmartins

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.

  1. Change sourceRoot compilation option.

My tsconfig.json file:

{
  // other options
  "sourceRoot": "/"
}
  1. 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.

wmartins avatar Jul 27 '20 15:07 wmartins

Also ran into the same issue.

AeroNotix avatar Sep 21 '22 12:09 AeroNotix