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

swc-node cannot triggered breakpoints correctly. #697

Closed
hua03 opened this issue Feb 23, 2023 · 3 comments · Fixed by #708
Closed

swc-node cannot triggered breakpoints correctly. #697

hua03 opened this issue Feb 23, 2023 · 3 comments · Fixed by #708

Comments

@hua03
Copy link

hua03 commented Feb 23, 2023

This is my demo swc-node-debug-demo.

I used two ways to start the debugger, launch and attach. These ways is useless in Webstorm and VSCode.

There are two ways to set breakpoint, click on editor gutter (side area of line number) or use debugger grammar.


Test in Webstorm

Start Debugger by launch

repoduce:

  1. open package.json in the project
  2. click editor gutter same row as debug:swc-node, Then select debug 'debug:swc-node'
  3. visit http://localhost:3000 on browser.
  4. Then the program into the breakpoint, but it didn't stop at the right place. If you operate the debugger, it won't jump correctly.

If you delete debugger in the line six on app.ts, repeat the above steps, you will find the debugger does not stop at breakpoints.

Start Debugger by attach

repoduce:

  1. run command npm run attach:swc-node on Terminal, it will print debugger listening address
  2. click the address, webstorm will auto start debugger to attach to the program.
  3. then the terminal will print Debugger attached.
  4. visit http://localhost:3000 on browser. The debugger do not stop at breakpoints.

Test in VSCode

Start Debugger by launch

repoduce:

  1. open Run and Debug panel
  2. select the config debug:swc-node, and run it
  3. visit http://localhost:3000 on browser.
  4. vscode will open another compiled app.ts file in editor.

Start Debugger by attach

repoduce:

  1. run command npm run attach:swc-node on Terminal, it will print debugger listening address
  2. change the debug config attach:swc-node, update the field remoteRoot
  3. visit http://localhost:3000 on browser.
  4. vscode will open another compiled app.ts file in editor.


If start debugger with the script debug:ts-node, the debugger will trigger breakpoints correctly.

@Brooooooklyn
Copy link
Member

Brooooooklyn commented Feb 23, 2023

Have you tried to set inlineSourceMap: true: https://github.com/hua03/swc-node-debug-demo/blob/main/tsconfig.json#L8

@hua03
Copy link
Author

hua03 commented Feb 27, 2023

If set inlineSourceMap: true, start the command debug:swc-node, it will report an error failed to open input source map file. debug:ts-node can start the app normally.

image

@robbiespeed
Copy link
Contributor

@Brooooooklyn I noticed there was a bug where "inline" didn't get passed to swc when inlineSourceMap: true is set in tsconfig. Submitted a PR with simple fix that seemed to work for me when using @swc-node/register

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

Successfully merging a pull request may close this issue.

3 participants