istanbuljs / babel-plugin-istanbul

A babel plugin that adds istanbul instrumentation to ES6 code
BSD 3-Clause "New" or "Revised" License
616 stars 72 forks source link

Error creating html report due to invalid file name #247

Closed albertodeago closed 4 years ago

albertodeago commented 4 years ago

Hello, thank's for the plugin, it's great and I hope this is the right place to ask for this. I already use it in some projects with webpack and everything works great, I was now trying to integrate in a Vue library bundled with rollup (and thus rollup-plugin-vue) and I'm having an error. Basically it looks that while creating the html report it tries to create some files (for the vue components) with invalid names. I looked into the dist files and infact the path created is wrong because there are rollup-plugin-vue query params appended. Removing "?rollup-plugin-vue=script.js" parts in the compiled code make everything work as expected Am I missing something? Had no luck searching for this error

version 6.0.0

Error in console

> npx nyc report --reporter=html

ENOENT: no such file or directory, open 'C:\wamp64\www\my-library\coverage\src\components\contentDownload\ContentDownload.vue?rollup-plugin-vue=script.js.html'

Piece of bundle in dist

function cov_mv49kilt7() {
    var path = "C:\\wamp64\\www\\my-library\\src\\components\\contentGrid\\ContentGrid.vue?rollup-plugin-vue=script.js";
    var hash = "290b51fbcde826193096c3a4060eb87fe55542ae";
    var global = new Function("return this")();
    var gcv = "__coverage__";
    var coverageData = {
      path: "C:\\wamp64\\www\\my-library\\src\\components\\contentGrid\\ContentGrid.vue?rollup-plugin-vue=script.js",
      statementMap: {
        ...
      },
      fnMap: {
        ...
      },
      branchMap: {
        ...
      },
      s: {
        ...
      },
      f: {
        ...
      },
      b: {
        ...
      },
      _coverageSchema: "1a1c01bbd47fc00a2c39e90264f33305004495a9",
      hash: "290b51fbcde826193096c3a4060eb87fe55542ae"
    };
    var coverage = global[gcv] || (global[gcv] = {});

    if (!coverage[path] || coverage[path].hash !== hash) {
      coverage[path] = coverageData;
    }

    var actualCoverage = coverage[path];

    cov_mv49kilt7 = function () {
      return actualCoverage;
    };

    return actualCoverage;
  }
coreyfarrell commented 4 years ago

I think this is a bug in whatever is calling babel, it should not be including query arguments in the filename set to the options when babel.transform is called.

albertodeago commented 4 years ago

Oh I see, maybe it's coming from rollup vue plugin, going to investigate more and closing this then. Thanks for fast feedback