Closed niftylettuce closed 6 years ago
I'm seeing a very similar error when using this plugin in conjunction with babel-plugin-espower
and babel-plugin-transform-es2015-spread
. I boiled this down to as minimal an example as I could:
I'm transpiling this code:
import _ from "lodash";
t.true(_.isEqual("foo", "bar"))
With this .babelrc
:
{
"plugins": [
"transform-es2015-spread",
["espower", {
"patterns": ["t.true(value, [message])"]
}],
"lodash"
]
}
TypeError: example.js: Cannot read property 'length' of undefined
at hasSpread (/path/to/project/node_modules/babel-plugin-transform-es2015-spread/lib/index.js:21:30)
at PluginPass.CallExpression (/path/to/project/node_modules/babel-plugin-transform-es2015-spread/lib/index.js:92:14)
at newFn (/usr/local/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/visitors.js:276:21)
at NodePath._call (/usr/local/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (/usr/local/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/context.js:48:17)
at NodePath.visit (/usr/local/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/context.js:105:12)
at TraversalContext.visitQueue (/usr/local/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/context.js:150:16)
at TraversalContext.visitSingle (/usr/local/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/context.js:108:19)
at TraversalContext.visit (/usr/local/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/context.js:192:19)
at Function.traverse.node (/usr/local/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/index.js:114:17)
It compiles fine if I remove any of the three plugins, or if I move the lodash
plugin before espower
. (Not a viable solution, however, for my real-use, as espower
plugin is added by the ava
testing library, and I don't think I can control the resulting ordering)
Versions:
I'm not sure if it's actually the same issue as @niftylettuce is seeing, but it's the exact same error message, so I thought I'd put it here first.
Thanks for the added info. I'll mark this as a dup of #168.
I believe this is related to #168.
Input:
src/config/utilities.js
:Output: