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

Source maps not working in Node 21.6 and above #478

Closed
4 of 6 tasks
bshoshany opened this issue Feb 17, 2024 · 8 comments · Fixed by #518
Closed
4 of 6 tasks

Source maps not working in Node 21.6 and above #478

bshoshany opened this issue Feb 17, 2024 · 8 comments · Fixed by #518
Labels
bug Something isn't working pr welcome

Comments

@bshoshany
Copy link

Acknowledgements

  • I searched existing issues before opening this one to avoid duplicates
  • I understand this is not a place for seek help, but to report a bug
  • I understand that the bug must be proven first with a minimal reproduction
  • I will be polite, respectful, and considerate of people's time and effort

Minimal reproduction URL

See below

Version

v4.7.1

Node.js version

v21.6.1

Package manager

npm

Operating system

Windows

Problem & Expected behavior

I'm having the same issue as #260, but I cannot reply there as the issue is locked. Breakpoints don't work because VS Code is putting a breakpoint on the compiled and minified JS code, instead of the original TS source. To reproduce:

  1. Use the launch.json file given in your documentation (either method).

  2. Create a simple TS file test.ts, for example:

let x: number = 1;
console.log(x);
  1. Put a breakpoint on the second line.

  2. Press F5.

Instead of breaking on the original test.ts, VS Code will open a new tab with the title test.ts, except that it will be the compiled and minified JS code, as in the following screenshot:

image

Note also that it will print out 1 to the terminal, because it's breaking on the second (empty) line of the compiled JS code, NOT on the second line of the original TS code.

Furthermore, if I add a third line and put a breakpoint on that, then it doesn't break at all, since the compiled code only has 2 lines ( the second one being empty).

As suggested in #260, I tried setting inlineSourceMap and/or inlineSources to true in tsconfig.json, but that does not resolve the problem. That issue originally seems to have been resolved by upgrading Node from v12 to v14, but I'm using Node v21, so that does not apply to me.

Is this a bug? Or am I doing something wrong? If it's a bug, then it should be fixed, since tsx is not so useful in development if debugging doesn't work. If I'm doing something wrong, please tell me what I should do instead (and ideally also add that to the documentation, since I followed your documentation very closely and it doesn't work).

Thanks!

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project
@bshoshany bshoshany added bug Something isn't working pending triage labels Feb 17, 2024
@privatenumber
Copy link
Owner

You're probably encountering this: https://github.com/privatenumber/tsx/discussions/464

Do you mind filing a bug report in Node.js?

@cowwoc
Copy link

cowwoc commented Feb 20, 2024

@privatenumber I'm using IntelliJ to debug but I can reproduce the same problem there. Reverting to node 21.5.0 as you recommended fixes the problem.

One thing that might help is that I noticed node --loader ts-node/esm works perfectly in node 21.6.x. You might want to check out their source-code to figure out what they did differently.

@bshoshany

This comment was marked as spam.

@huming2207

This comment was marked as spam.

@privatenumber
Copy link
Owner

privatenumber commented Mar 15, 2024

As per the contribution guide, please refrain from "also happening in ..." comments.

Try to add value by debugging the problem to find potential solutions.

Locking issue to direct further conversation to PRs.

@huming2207

This comment was marked as spam.

@huming2207

This comment was marked as off-topic.

@privatenumber

This comment was marked as off-topic.

Repository owner locked and limited conversation to collaborators Mar 15, 2024
@privatenumber privatenumber changed the title Debugging not working in VS Code Source maps not working in Node 21.6 and above Mar 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants