istanbuljs / istanbuljs

monorepo containing the various nuts and bolts that facilitate istanbul.js test instrumentation
https://istanbul.js.org/
1.01k stars 235 forks source link

[istanbul-lib-instrument] "don't know how to turn this value into a node" exception during instrumentation #672

Open wkeese opened 2 years ago

wkeese commented 2 years ago

I'm getting the

don't know how to turn this value into a node

exception during instrumentation and I traced it down to this:

Visitor.js' exit() method calls babel/@type's valueToNode(coverageData) method. The coverageData.inputSourceMap property used to be a plain object, but (I think because of a newer version of babel?), inputSourceMap is now an instance of the SourceMap class, causing valueToNode() to throw that exception.

I know this is similar to #646 but we aren't using Angular. I am using https://github.com/JS-DevTools/coverage-istanbul-loader, perhaps I should be using https://github.com/istanbuljs/babel-plugin-istanbul instead. I am wondering though how or if this is working for other configurations, and if istanbul-lib-instrument needs an update to handle coverageData.inputSourceMap being a SourceMap?

andrevmatos commented 2 years ago

Also getting this with vue-cli

andrevmatos commented 2 years ago

May have been fixed by https://github.com/babel/babel/pull/14283

thebanjomatic commented 2 years ago

It looks like the sourcemap is being grabbed from file.inputMap.sourcemap in babel-plugin-istanbul here: https://github.com/istanbuljs/babel-plugin-istanbul/blob/99bd2a27493b7552ae75877496c3b2ad93f5fc46/src/index.js#L114-L116

That seems like an ideal place to convert to a plain javascript object. It sounds like the babel team would like to not make a copy of the sourcemap every time they are generated.

JamesCatt commented 2 years ago

Also seeing this with vue-cli, although it only seems to happen with components using script setup.