swc-node icon indicating copy to clipboard operation
swc-node copied to clipboard

Incorrect stack traces with inline sourceMaps

Open maxfliri opened this issue 1 year ago • 1 comments

With swc-node v1.10.9, stack traces report incorrect line numbers when swc is configured to generate inline sourceMaps.

This happens with SWCRC=true when .swcrc has "sourceMaps": "inline". It also happens always when running without SWCRC=true, because this always results in inline sourceMaps, as reported in #848.

I get correct stack traces only when I use SWCRC=true and .swcrc has "sourceMaps": true.

maxfliri avatar Oct 24 '24 15:10 maxfliri

I think the reason might be that sourcemaps are not added to SourcemapMap when inline.

Sourcemaps are added to SourcemapMap in the function below, which handles non-inline sourcemaps. As far as I can this is not happening for inline sourcemaps.

https://github.com/swc-project/swc-node/blob/fca85bd1ba1705455ca8c7adb345690cb029b4d3/packages/register/register.ts#L21-L37

maxfliri avatar Oct 24 '24 15:10 maxfliri