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

babel-plugin-istanbul being run twice, when executed in conjunction with babel-plugin-rewire #187

Open
bcoe opened this issue Apr 16, 2017 · 1 comment

Comments

@bcoe
Copy link

bcoe commented Apr 16, 2017

I've had a couple issues opened on babel-plugin-istanbul related to incompatibility with babel-plugin-rewire; In a debugging session today, I finally figured out what was happening.

When both plugins are used together, an attempt is made to instrument source code files multiple times for test coverage; This results in a second line counter being added to each line in the file, but the source-code tracking object is not updated... tldr; we end up counting the wrong lines, and the counts are off by one; this results in some extremely strange behavior, see:

istanbuljs/istanbuljs#28

and

https://github.com/MartinDawson/istanbulBug

I could potentially use the following workaround:

// the plugin rewire, as a side-effect, seems to cause
// the program visitor to be run twice; in this
// scenario, we should avoid instrumentinga second time.
function alreadyInstrumented(path, visitState) {
    return path.scope.hasBinding(visitState.varName);
}

But it feels a bit weird to have to do this; any ideas as to what might be going on -- @hzoo I know you're super busy, but perhaps you could give some insight?

@speedskater
Copy link
Owner

@bcoe Thanks for bringing this up. We had the same problem and have therefore added a similar mechanism like the alreadyInstrumented operation in your case.
In our case it is the wasProcessed method in https://github.com/speedskater/babel-plugin-rewire/blob/master/src/RewireHelpers.js
@hzoo do you have a suggestion how to solve this in a more generic way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants