istanbuljs / babel-plugin-istanbul

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

Compilation failing after upgrading to babel-plugin-istanbul 5.1.4 #211

Closed kepeterson closed 5 years ago

kepeterson commented 5 years ago

I've upgraded my project to use the latest version of babel-plugin-istanbul (commit change at bottom). However, the project no longer properly bundles after the upgrade. The only change was moving babel-plugin-instabul from 5.1.3 to 5.1.4

My modules all fail to build in the following way, throwing an error about a function not being iterable.

Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: /Users/kyle/Code/spoke/shared/helpers/users.js: function wrappedEntry(path, node) {
    this.onEnter(path);

    if (this.shouldIgnore(path)) {
      return;
    }

    enter.forEach(e => {
      e.call(this, path, node);
    });
  } is not iterable!
    at module.exports.require.getIterator (/Users/kyle/Code/spoke/node_modules/babel-runtime/node_modules/core-js/library/modules/core.get-iterator.js:5:42)
    at NodePath._call (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/path/context.js:57:135)
    at NodePath.call (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitMultiple (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/context.js:103:17)
    at TraversalContext.visit (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/context.js:190:19)
    at Function.traverse.node (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/index.js:114:17)
    at traverse (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/index.js:79:12)
    at NodePath.traverse (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/path/index.js:144:25)
    at Object.enter (/Users/kyle/Code/spoke/node_modules/babel-plugin-istanbul/node_modules/istanbul-lib-instrument/dist/visitor.js:611:12)
    at PluginPass.enter (/Users/kyle/Code/spoke/node_modules/babel-plugin-istanbul/lib/index.js:90:23)
    at newFn (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/visitors.js:276:21)
    at NodePath._call (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitSingle (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/context.js:108:19)
    at TraversalContext.visit (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/context.js:192:19)
    at Function.traverse.node (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/index.js:114:17)
    at traverse (/Users/kyle/Code/spoke/node_modules/babel-traverse/lib/index.js:79:12)
    at File.transform (/Users/kyle/Code/spoke/node_modules/babel-core/lib/transformation/file/index.js:516:35)
    at /Users/kyle/Code/spoke/node_modules/babel-core/lib/transformation/pipeline.js:50:19
    at File.wrap (/Users/kyle/Code/spoke/node_modules/babel-core/lib/transformation/file/index.js:532:16)
    at Pipeline.transform (/Users/kyle/Code/spoke/node_modules/babel-core/lib/transformation/pipeline.js:47:17)
    at transpile (/Users/kyle/Code/spoke/node_modules/babel-loader/lib/index.js:50:20)
    at Object.module.exports (/Users/kyle/Code/spoke/node_modules/babel-loader/lib/index.js:173:20)
 @ ./clients/app/components/super_panel/user_super_panel_controller_spec.js 9:13-56
 @ ./clients/app sync _spec\.js$
 @ ./clients/client_tests.webpack.js

Upgrading babel-plugin-istanbul introduces new versions of several babel dependencies as shown in the changes in the yarn.lock file. Could this plugin be incompatible with those versions? What could be causing such a drastic change from this minor version bump?

Author: Kyle Peterson <kylepeterson@askspoke.com>
Date:   Thu Jun 13 16:49:17 2019 -0700

    Bump babel-plugin-istanbul

diff --git a/package.json b/package.json
index 3cdb1087e..3f15f9521 100644
--- a/package.json
+++ b/package.json
@@ -181,7 +181,7 @@
     "babel": "^6.23.0",
     "babel-core": "^6.13.2",
     "babel-loader": "^7.1.2",
-    "babel-plugin-istanbul": "^5.1.3",
+    "babel-plugin-istanbul": "^5.1.4",
     "babel-polyfill": "^6.7.2",
     "babel-preset-env": "^1.7.0",
     "basic-auth": "^2.0.0",
diff --git a/yarn.lock b/yarn.lock
index 15f769c72..ac72740a1 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -20,6 +20,17 @@
     source-map "^0.5.0"
     trim-right "^1.0.1"

+"@babel/generator@^7.4.0", "@babel/generator@^7.4.4":
+  version "7.4.4"
+  resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.4.4.tgz#174a215eb843fc392c7edcaabeaa873de6e8f041"
+  integrity sha512-53UOLK6TVNqKxf7RUh8NE851EHRxOOeVXKbK2bivdb+iziMyk03Sr4eaE9OELCbyZAAafAKPDwF2TPUES5QbxQ==
+  dependencies:
+    "@babel/types" "^7.4.4"
+    jsesc "^2.5.1"
+    lodash "^4.17.11"
+    source-map "^0.5.0"
+    trim-right "^1.0.1"
+
 "@babel/helper-function-name@^7.1.0":
   version "7.1.0"
   resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz#a0ceb01685f73355d4360c1247f582bfafc8ff53"
@@ -43,6 +54,13 @@
   dependencies:
     "@babel/types" "^7.0.0"

+"@babel/helper-split-export-declaration@^7.4.4":
+  version "7.4.4"
+  resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz#ff94894a340be78f53f06af038b205c49d993677"
+  integrity sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==
+  dependencies:
+    "@babel/types" "^7.4.4"
+
 "@babel/highlight@^7.0.0":
   version "7.0.0"
   resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0.tgz#f710c38c8d458e6dd9a201afb637fcb781ce99e4"
@@ -57,6 +75,11 @@
   resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.2.3.tgz#32f5df65744b70888d17872ec106b02434ba1489"
   integrity sha512-0LyEcVlfCoFmci8mXx8A5oIkpkOgyo8dRHtxBnK9RRBwxO2+JZPNsqtVEZQ7mJFPxnXF9lfmU24mHOPI0qnlkA==

+"@babel/parser@^7.4.3", "@babel/parser@^7.4.4", "@babel/parser@^7.4.5":
+  version "7.4.5"
+  resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.4.5.tgz#04af8d5d5a2b044a2a1bffacc1e5e6673544e872"
+  integrity sha512-9mUqkL1FF5T7f0WDFfAoDdiMVPWsdD1gZYzSnaXsxUCUqzuch/8of9G3VUSNiZmMBoRxT3neyVsqeiL/ZPcjew==
+
 "@babel/template@^7.0.0", "@babel/template@^7.1.0":
   version "7.2.2"
   resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.2.2.tgz#005b3fdf0ed96e88041330379e0da9a708eb2907"
@@ -66,6 +89,15 @@
     "@babel/parser" "^7.2.2"
     "@babel/types" "^7.2.2"

+"@babel/template@^7.4.0":
+  version "7.4.4"
+  resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.4.4.tgz#f4b88d1225689a08f5bc3a17483545be9e4ed237"
+  integrity sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==
+  dependencies:
+    "@babel/code-frame" "^7.0.0"
+    "@babel/parser" "^7.4.4"
+    "@babel/types" "^7.4.4"
+
 "@babel/traverse@^7.0.0":
   version "7.2.3"
   resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.2.3.tgz#7ff50cefa9c7c0bd2d81231fdac122f3957748d8"
@@ -81,6 +113,21 @@
     globals "^11.1.0"
     lodash "^4.17.10"

+"@babel/traverse@^7.4.3":
+  version "7.4.5"
+  resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.4.5.tgz#4e92d1728fd2f1897dafdd321efbff92156c3216"
+  integrity sha512-Vc+qjynwkjRmIFGxy0KYoPj4FdVDxLej89kMHFsWScq999uX+pwcX4v9mWRjW0KcAYTPAuVQl2LKP1wEVLsp+A==
+  dependencies:
+    "@babel/code-frame" "^7.0.0"
+    "@babel/generator" "^7.4.4"
+    "@babel/helper-function-name" "^7.1.0"
+    "@babel/helper-split-export-declaration" "^7.4.4"
+    "@babel/parser" "^7.4.5"
+    "@babel/types" "^7.4.4"
+    debug "^4.1.0"
+    globals "^11.1.0"
+    lodash "^4.17.11"
+
 "@babel/types@^7.0.0", "@babel/types@^7.2.2":
   version "7.2.2"
   resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.2.2.tgz#44e10fc24e33af524488b716cdaee5360ea8ed1e"
@@ -90,6 +137,15 @@
     lodash "^4.17.10"
     to-fast-properties "^2.0.0"

+"@babel/types@^7.4.0", "@babel/types@^7.4.4":
+  version "7.4.4"
+  resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.4.4.tgz#8db9e9a629bb7c29370009b4b779ed93fe57d5f0"
+  integrity sha512-dOllgYdnEFOebhkKCjzSVFqw/PmmB8pH6RGOWkY4GsboQNd47b1fBThBSwlHAq9alF9vc1M3+6oqR47R50L0tQ==
+  dependencies:
+    esutils "^2.0.2"
+    lodash "^4.17.11"
+    to-fast-properties "^2.0.0"
+
 "@ciscospark/common-evented@1.48.0":
   version "1.48.0"
   resolved "https://registry.yarnpkg.com/@ciscospark/common-evented/-/common-evented-1.48.0.tgz#1deaf5978501a3537dff32a88a9712cc99363e2f"
@@ -2164,14 +2220,14 @@ babel-plugin-check-es2015-constants@^6.22.0:
   dependencies:
     babel-runtime "^6.22.0"

-babel-plugin-istanbul@^5.1.3:
-  version "5.1.3"
-  resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-5.1.3.tgz#202d20ffc96a821c68a3964412de75b9bdeb48c7"
-  integrity sha512-IFyehbvRRwdBlI1lDp+FaMsWNnEndEk7065IB8NhzBX+ZKLPwPodgk4I5Gobw/8SNUUzso2Dv3hbqRh88eiSCQ==
+babel-plugin-istanbul@^5.1.4:
+  version "5.1.4"
+  resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-5.1.4.tgz#841d16b9a58eeb407a0ddce622ba02fe87a752ba"
+  integrity sha512-dySz4VJMH+dpndj0wjJ8JPs/7i1TdSPb1nRrn56/92pKOF9VKC1FMFJmMXjzlGGusnCAqujP6PBCiKq0sVA+YQ==
   dependencies:
     find-up "^3.0.0"
-    istanbul-lib-instrument "^3.2.0"
-    test-exclude "^5.2.2"
+    istanbul-lib-instrument "^3.3.0"
+    test-exclude "^5.2.3"

 babel-plugin-syntax-async-functions@^6.8.0:
   version "6.13.0"
@@ -8636,6 +8692,11 @@ istanbul-lib-coverage@^2.0.4:
   resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#927a354005d99dd43a24607bb8b33fd4e9aca1ad"
   integrity sha512-LXTBICkMARVgo579kWDm8SqfB6nvSDKNqIOBEjmJRnL04JvoMHCYGWaMddQnseJYtkEuEvO/sIcOxPLk9gERug==

+istanbul-lib-coverage@^2.0.5:
+  version "2.0.5"
+  resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz#675f0ab69503fad4b1d849f736baaca803344f49"
+  integrity sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA==
+
 istanbul-lib-hook@^2.0.6:
   version "2.0.6"
   resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-2.0.6.tgz#5baa6067860a38290aef038b389068b225b01b7d"
@@ -8656,6 +8717,19 @@ istanbul-lib-instrument@^3.2.0:
     istanbul-lib-coverage "^2.0.4"
     semver "^6.0.0"

+istanbul-lib-instrument@^3.3.0:
+  version "3.3.0"
+  resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-3.3.0.tgz#a5f63d91f0bbc0c3e479ef4c5de027335ec6d630"
+  integrity sha512-5nnIN4vo5xQZHdXno/YDXJ0G+I3dAm4XgzfSVTPLQpj/zAV2dV6Juy0yaf10/zrJOJeHoN3fraFe+XRq2bFVZA==
+  dependencies:
+    "@babel/generator" "^7.4.0"
+    "@babel/parser" "^7.4.3"
+    "@babel/template" "^7.4.0"
+    "@babel/traverse" "^7.4.3"
+    "@babel/types" "^7.4.0"
+    istanbul-lib-coverage "^2.0.5"
+    semver "^6.0.0"
+
 istanbul-lib-report@^2.0.7:
   version "2.0.7"
   resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-2.0.7.tgz#370d80d433c4dbc7f58de63618f49599c74bd954"
@@ -15023,6 +15097,16 @@ test-exclude@^5.2.2:
     read-pkg-up "^4.0.0"
     require-main-filename "^2.0.0"

+test-exclude@^5.2.3:
+  version "5.2.3"
+  resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.2.3.tgz#c3d3e1e311eb7ee405e092dac10aefd09091eac0"
+  integrity sha512-M+oxtseCFO3EDtAaGH7iiej3CBkzXqFMbzqYAACdzKui4eZA+pq3tZEwChvOdNfa7xxy8BfbmgJSIr43cC/+2g==
+  dependencies:
+    glob "^7.1.3"
+    minimatch "^3.0.4"
+    read-pkg-up "^4.0.0"
+    require-main-filename "^2.0.0"
+
 test-value@^3.0.0:
   version "3.0.0"
   resolved "https://registry.yarnpkg.com/test-value/-/test-value-3.0.0.tgz#9168c062fab11a86b8d444dd968bb4b73851ce92"
coreyfarrell commented 5 years ago

The issue is that babel 6 was never supported by babel-plugin-istanbul@5. Initially it incorrectly worked but we're unable to support this setup. The problem is that istanbul-lib-instrument@2.3.0 introduced support for class private fields, but this causes babel 6 to fail. In theory you can pin to babel-plugin-istanbul@=5.1.3 and istanbul-lib-instrument@=2.2.0 though this is really not supported. My advice is to work on upgrading to babel 7 or downgrade to babel-plugin-istanbul@4 (the version which supports babel 6).

The next release of babel-plugin-istanbul will provide a clearer error for this case stating that babel 7 is required.