-
Notifications
You must be signed in to change notification settings - Fork 247
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
feat(preprocessor): Add sourcemap support #146
feat(preprocessor): Add sourcemap support #146
Conversation
To give more context on this change, when you want to debug transpiled code (e.g. TypeScript) that has been preprocessed to add coverage, it is very difficult to debug it in the browser. As a workaround, one can disable coverage when debugging. The behavior added by this PR checks to see if the file has a sourceMap property specified (source maps can be loaded by https://github.com/demerzel3/karma-sourcemap-loader). If it is there, source map generation is enabled in Istanbul and afterwards, the lines from the original source map are mapped onto the transformed code. This allows you to set break points in the browser using source maps and you can then step through the code. |
I would like to get this in, could you add some documentation and rebase onto the latest master please |
The PR on istanbul gotwarlost/istanbul#349 hasn't been released yet, so this is still blocked. |
Ah okay thanks for the info, I thought it was released as the PR seemed to be merged |
Cleaned up the code base a bit, can you please rebase onto those changes? |
@nmalaguti new version was just published including the linked fix |
instrumenter.instrument(content, jsPath, function(err, instrumentedCode) { | ||
|
||
if (err) { | ||
log.error('%s\n at %s', err.message, file.originalPath); | ||
} | ||
|
||
if (file.sourceMap) { | ||
var consumer = new SourceMapConsumer(file.sourceMap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the consumer never used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
4956e19
to
d6234b8
Compare
Adds sourcemap support to the preprocessor. If the file being processed has a sourcemap property, it is merged with the output from the coverage instrumentation. This enables better debugging on instrumented code. Closes karma-runner#109
d6234b8
to
de3b738
Compare
Rebased and updated with the latest version of istanbul. |
feat(preprocessor): Add sourcemap support
did docs ever get added for this feature? I'm trying to use it and having trouble at the moment. |
Pending gotwarlost/istanbul#349, which is needed to fix istanbul sourcemap outputs to have the correct offset.
Adds sourcemap support to the preprocessor. If the file being
processed has a sourcemap property, it is merged with the output
from the coverage instrumentation. This enables better debugging
on instrumented code.
Closes #109