Skip to content

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

@pbadenski

Description

@pbadenski

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions