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

[Bug]: Produced source maps seem to have mismatch with file paths #4250

Open
sobanieca opened this issue Jan 8, 2024 · 0 comments
Open

[Bug]: Produced source maps seem to have mismatch with file paths #4250

sobanieca opened this issue Jan 8, 2024 · 0 comments

Comments

@sobanieca
Copy link

sobanieca commented Jan 8, 2024

Version

29.1.1

Steps to reproduce

git clone https://github.com/sobanieca/ts-jest-sourcemaps-issue
npm i
npm run debug

Open in chrome chrome://inspect and connect debugger. There will be first initial breakpoint, click continue and proceed to the actual breakpoint from test.ts file.

Expected behavior

I would like to see proper source code (Typescript file), not some compiled version of it.

Actual behavior

In debugger I can see compiled JS code, which makes debugging harder.

Debug log

https://github.com/sobanieca/ts-jest-sourcemaps-issue/blob/main/ts-jest.log

Additional context

I believe this is related to source maps file path mismatch. In sample repository, I've created ts-node project which properly displays code when debugging in Chrome. Comparing produced source maps we can see mismatch between file path and sources. For instance:
image
and in source map:
image

While for sample ts-express it's:
image
and in source map:
image

I've seen in sourcemap v3 specification (https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1) that it's not very accurate about how to specify paths, especially for files. But I believe ts-jest should not put full path in sources part. There are some related open issues in sourcemaps rfc: tc39/source-map#44.

Ideally, I would love ts-jest to produce similar source maps as ts-node as in ts-express example in https://github.com/sobanieca/ts-jest-sourcemaps-issue. So instead of full path in sources like /home/... just produce test.ts.

Environment

System:
    OS: Windows 11 10.0.22631
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.3 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.14.0 - C:\Program Files\nodejs\pnpm.CMD

But I've tried on Android (proot-distro Debian 12) and Linux (Debian 12 under WSL in Windows). Attached jest-ts log is from Android.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant