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

Sourcemap support for preprocessors? #1474

Closed
kulshekhar opened this issue Aug 22, 2016 · 9 comments
Closed

Sourcemap support for preprocessors? #1474

kulshekhar opened this issue Aug 22, 2016 · 9 comments

Comments

@kulshekhar
Copy link

When used with typescript, the output displays line numbers from transpiled javascript and not from the actual typescript code.

I've modified this sample typescript preprocessor to set sourceMap, inlineSourceMap and inlineSources to true in typescript's options but it didn't help.

Is there anything else that I can do to get jest to display the mapped line numbers?

@cpojer
Copy link
Member

cpojer commented Aug 29, 2016

Can you try to modify the sample preprocessor again and run Jest with --no-cache while working on the preprocessor?

Unfortunately we don't currently have an official typescript preprocessor (besides the example). If you'd like to work on this and send a pull request for adding typescript-jest, that would be awesome!

I'm closing this for now because we can't really do much if it isn't part of Jest.

@cpojer cpojer closed this as completed Aug 29, 2016
@kulshekhar
Copy link
Author

I tried this with --no-cache but it didn't work.

I tested the sample preprocessor and it seems to be working well with the added flags. The transpiled code contains the sourcemap inline.

This leads me to assume that whatever work needs to be done to display the correct (mapped) line numbers will probably need to be done in the Jest code that uses the preprocessor.

Is this assumption right? If so, can you point to the part of the codebase (a quick, rough indication would be helpful too) that I can look at to see if I can submit a usable PR?

@cpojer
Copy link
Member

cpojer commented Aug 29, 2016

Are inline sourcemaps supposed to work automatically when using node and when using the vm module? Because Jest uses vm to run tests.

All of this code is in packages/jest-runtime – transform.js creates vm.Script instances.

If you are willing to help out, please join our discord channel (see https://facebook.github.io/jest/support.html ) – I'm usually there and happy to help. Creating typescript-jest would be awesome and should be fairly straightforward.

@kulshekhar
Copy link
Author

Upon looking into this, I've discovered that node doesn't have any native support for sourcemaps. Without sourcemap support, creating typescript-jest would most likely be meaningless.

I've been trying to see if I can get https://github.com/evanw/node-source-map-support to work with the typescript preprocessor. If I can, I'll create typescript-jest using it and send a PR.

@cpojer
Copy link
Member

cpojer commented Aug 29, 2016

Can typescript somehow retain lines, just like babel can?

@kulshekhar
Copy link
Author

There's no such option in the typescript compiler

@cpojer
Copy link
Member

cpojer commented Aug 29, 2016

ah that sucks :(

@kulshekhar
Copy link
Author

kulshekhar commented Aug 30, 2016

Just in case there's someone else with this problem, I've created a repo with information about the setup that's working for me - https://github.com/kulshekhar/typescript-jest

Edit: the repo is at https://github.com/kulshekhar/ts-jest and the npm package is ts-jest

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants