-
Notifications
You must be signed in to change notification settings - Fork 157
Don't set inputSourceMap on babel-jest transform #492
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
Don't set inputSourceMap on babel-jest transform #492
Conversation
When babel-jest merges the inputSourceMap and the outputSourceMap it appears to remove names from the resulting sourceMap that are still referenced by elements of the source map. Not passing the inputSourceMap appears to solve vuejs#474 and still provide source coverage, but someone who knows how this is supposed to work should look more closely.
Pretty sure this isn't want we want to do as we'll lose the mapping chain from vue -> ts -> jest, but here's what I'm seeing: typescript.transpileModule gives a sourceMap that looks like:
doing babel-jest.transform() without this source map results in:
which is consumable by a SourceMapConsumer as per doing babel-jest.transform({inputSourceMap: mapFromFirstStep}) results in:
which has fewer entries in |
Will try get some 👀 on this - we've got a lot of weird incompatible stuff around source maps, the core issue(s) are not super clear. |
another option that potentially works is to assume that babel is set up to handle typescript, and just do a single transform instead of transpiling the typescript and then passing to babel-jest: so transformers/typescript.js becomes:
or to just do the typescript transpilation and assume it outputs something ok:
I'm not sure if either assumption is safe to make in general for vue/typescript projects, but both approaches appear to avoid the sourceMap mismatch problem. The coverage report in the typescript-only case looks ok at first glance. The coverage report in the babel-only case appears to miss out on the <template> block in the rendered source, but the code coverage on the <script> looks ok at first glance. |
Hi, I don't have time to prioritise this - I normally can just merge + release things that have a test, do we not need one for this? I wonder if we even have some tests around source maps? You might need to rebase - we released v29 just now: https://github.com/vuejs/vue-jest/releases/tag/v29.0.0 |
Hi thanks for the update -- I'll look at rebasing and adding a test if I can. Opened this more as an ask for guidance than an actual suggested fix, but I'll spend some more time trying to narrow this down to something I'd actually recommend as a fix (probably one of the single-transform solutions?). |
hmm everything seems to work ok in my project now with 29.x... not sure what fixed it but 🤷 |
When babel-jest merges the inputSourceMap and the outputSourceMap
it appears to remove names from the resulting sourceMap that are
still referenced by elements of the source map. Not passing the
inputSourceMap appears to solve #474 and still provide source
coverage, but someone who knows how this is supposed to work
should look more closely.