Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breakpoint doesnt work in node.js with typescript #238

Open
bobrowadam opened this issue Feb 22, 2020 · 4 comments
Open

breakpoint doesnt work in node.js with typescript #238

bobrowadam opened this issue Feb 22, 2020 · 4 comments

Comments

@bobrowadam
Copy link

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"
    }
  ]
}
@NicolasPetton
Copy link
Owner

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.

@wmartins
Copy link

wmartins commented Jun 3, 2020

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
Copy link

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.

@AeroNotix
Copy link

Also ran into the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants