-
-
Notifications
You must be signed in to change notification settings - Fork 39
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: initial support for source-maps (only supports one to one mapping) #19
Conversation
see: #20, we need a more methodical way to build out tests. |
lib/v8-to-istanbul.js
Outdated
// the backflips we perform to remap absolute to relative positions. | ||
const rawSourceMap = convertSourceMap.fromSource(rawSource) || convertSourceMap.fromMapFileSource(rawSource, dirname(this.path)) | ||
if (rawSourceMap) { | ||
this.path = resolve(dirname(this.path), rawSourceMap.sourcemap.sources[0]) |
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.
This only accounts for the first source file when there can be many. For example I'm working with a file that has 259 sources in it.
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.
@Friss it also doesn't account for relative vs., absolute paths.
I think it might be worth pulling in this module from Istanbuljs:
And this logic:
This is the use-case of using a tool that combines JavaScript files?
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.
Yeah we build our apps with webpack and has the babel toolchain etc.
(Posting on the main thread so it doesn't get lost) The main idea I'm trying to solve is have puppeteer visit all the routes in our apps and record code coverage and then report that out to istanbul. My first attempt (before this PR was opened) was to pull together the internals of istanbul to do it and I got pretty close. The files were all mapped out but the coverage was off. https://gist.github.com/Friss/8121c0462544d7515c498b512dbe9303#file-franken-code-coverage-js Once I saw this PR I started looking into using this to do the same thing https://gist.github.com/Friss/8121c0462544d7515c498b512dbe9303#file-custom-code-coverage-js which is where I hit the roadblock of this only mapping back to 1 file. (I had solved the relative file problem) |
@Friss in what ways was the coverage off? I've ran into some issue myself, which seem to have been somewhat addressed with changes to the underlying source-map library -- wondering if we're hitting the same thing. My issue was that the entire header of TypeScript files was marked as uncovered, even though it was covered. |
@bcoe For me the branches were accounted for but still marked as 0% used. And then as far as statements and functions it was |
@Friss having thought a bit about what it would take to make toIstanbul () {
const istanbulInner = Object.assign(
{ path: this.path },
this._statementsToIstanbul(),
this._branchesToIstanbul(),
this._functionsToIstanbul()
)
const istanbulOuter = {}
istanbulOuter[this.path] = istanbulInner
return istanbulOuter
} This PR is a step in the right direction, because we've added the a I'm going to work on getting this work over the finish line supporting the |
BREAKING CHANGE: v8-to-istanbul is now async, making it possible to use the latest source-map library
@bcoe Sounds good 👍 its definitely a step in the right direction. |
What is this?
This PR adds support for source-maps, using an algorithm similar to that implemented in istanbul-lib-sourcemaps (which @loganfsmyth helped with some of the edge-cases around).
Why this is this important
This will allow V8's built in coverage to be more easily used with projects that use TypeScript, Babel, etc.
Extra eyeballs very much appreciated
☝️ these two facts combine to make this a fairly gnarly algorithm:
tldr; I've probably screwed some things up, and would love an extra set of eyes
CC: @fitzgen, @hashseed, @schuay, @isaacs.
BREAKING CHANGE: v8-to-istanbul is now async, due to source-map dependency.