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 aren't loaded correctly in Chrome Node DevTools #2362

Closed
pbadenski opened this issue Oct 6, 2021 · 18 comments · Fixed by #3003 or #6086
Closed

Source maps aren't loaded correctly in Chrome Node DevTools #2362

pbadenski opened this issue Oct 6, 2021 · 18 comments · Fixed by #3003 or #6086
Assignees
Labels
Milestone

Comments

@pbadenski
Copy link

pbadenski commented Oct 6, 2021

I ran node --inspect-brk -r @swc/register some_script.ts and then opened chrome://inspect - DevTools for Node. Source maps weren't loaded properly (was showing a transpiled JS content under a TS filename). I checked with babel and it works fine. There seems to be a difference between babel and swc that makes it break - I used debugger to dynamically modify swc source maps and managed to see it working.

It looks like embedding full filename path in sources doesn't work in Chrome DevTools for Node. What babel does, and seems to make it work - is encodes directory path in sourceRoot and just filename in sources.

This works (babel):

{
  "version": 3,
  "sourceRoot": "/Users/pbadenski/workspace/project/",
  "sources": [
    "test.ts"
  ],
  ...
}

This doesn't (swc):

{
  "version": 3,
  "sources": [
    "/Users/pbadenski/workspace/project/test.ts"
  ],
  ...
}
@pbadenski pbadenski added the C-bug label Oct 6, 2021
@kdy1 kdy1 modified the milestones: v1.2.94, v1.2.95, v1.2.96 Oct 7, 2021
@kdy1
Copy link
Member

kdy1 commented Oct 9, 2021

@pbadenski
Copy link
Author

I tried, doesn't help unfortunately.

@kdy1 kdy1 modified the milestones: v1.2.106, v1.2.107 Oct 30, 2021
@egilsster
Copy link

egilsster commented Dec 13, 2021

Tried (a variation of options with inlineSourcesContent and sourceMaps) with 118 and 119 just now in VSCode and neither is working correctly at the moment while babel-loader is working. Running Jest in a debugging terminal in VSCode and none of my breakpoints are hitting. Simply reporting back but don't have the bandwidth to investigate that issue right now. Will create an issue if I manage to get a repro up.

NOTE: I am using a project with swc packages only (not the swc-node variant):

"@swc/core": "1.2.119",
"@swc/jest": "0.2.14",
"swc-loader": "0.1.15",

@kdy1 kdy1 reopened this Dec 14, 2021
@kwonoj
Copy link
Member

kwonoj commented Dec 14, 2021

It looks like there are multiple different roots to investigate (from @swc/register to something else). Anyone experiencing this issue mind share exact repro steps for each? It's hard to do guesswork with currently known information.

nicholasxjy pushed a commit to nicholasxjy/swc that referenced this issue Dec 18, 2021
swc_ecma_codegen:
 - Handle source map of multi-line template literals. (Closes swc-project#2185, Closes swc-project#2362, Closes swc-project#2900)
@pbadenski
Copy link
Author

Just FYI looks, I'm extremely happy. I haven't had any problems since recently - I will keep this thread updated. Thank you!! ⭐

@kdy1 kdy1 modified the milestones: v1.2.119, v1.2.156 Mar 14, 2022
@kdy1
Copy link
Member

kdy1 commented Mar 14, 2022

Can you try the latest version of @swc/core? (v1.2.155)

Patches in #4007 are very likely to fix this issue.

@kdy1 kdy1 modified the milestones: v1.2.156, Planned Mar 14, 2022
@kdy1
Copy link
Member

kdy1 commented Mar 16, 2022

Can anyone make an executable repro case?
node.js seems to consume sourcemap of swc without any problem.

See https://github.com/kdy1/swc/tree/6cea544afa481e063cff6d8d493d8d12dadb280a/crates/swc/tests/stacktrace for exmaple repro case.

@kdy1
Copy link
Member

kdy1 commented Mar 16, 2022

Can you try the latest version? (v1.2.156)
There was a bug fix for a module that only contains export * from './foo' and such module is super common, so I think it can be the cause of this.

@daviduzumeri
Copy link

If it helps, I'm still having the same issue and was able to create a quick repo to reproduce it: https://github.com/daviduzumeri/swctest

Any help would be appreciated, as we're pretty much back to console.log debugging over here.

@kdy1
Copy link
Member

kdy1 commented Aug 30, 2022

I found that sourcemap crate does not support sourceRoot.
https://docs.rs/sourcemap/6.1.0/sourcemap/struct.SourceMapBuilder.html

@kdy1
Copy link
Member

kdy1 commented Aug 30, 2022

Ref: getsentry/rust-sourcemap#50

kdy1 added a commit that referenced this issue Jan 24, 2024
@kdy1 kdy1 modified the milestones: Planned, v1.3.106 Jan 24, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Feb 23, 2024

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

6 participants