I can't say for sure if the fault lies with the babel core packages or babel-plugin-istanbul...@babel/preset-env with forceAllTransforms: true by itself doesn't choke on the code below, and neither does babel-plugin-istanbul by itself. But when they're run together, an error gets thrown.
for (let f; ; ) {
f = "0";
() => (0 ? 1 : parseInt(f));
}
The parseInt(f) gets transformed into cov_1c743zp148().b[0][1]++, parseInt(f). But for some reason that expression is orphaned by the time @babel/plugin-transform-block-scoping tries to rename f to _f, causing an error to be thrown.
$ npm test
> babel-plugin-istanbul-issue@1.0.0 test
> babel index.js
ReferenceError: /Users/andy/gh/babel-plugin-istanbul-issue/index.js: Container is falsy
at NodePath._replaceWith (/Users/andy/gh/babel-plugin-istanbul-issue/node_modules/@babel/traverse/lib/path/replacement.js:135:11)
at NodePath.replaceWith (/Users/andy/gh/babel-plugin-istanbul-issue/node_modules/@babel/traverse/lib/path/replacement.js:126:8)
at wrapLoopBody (/Users/andy/gh/babel-plugin-istanbul-issue/node_modules/@babel/plugin-transform-block-scoping/lib/loop.js:162:43)
at PluginPass.Loop (/Users/andy/gh/babel-plugin-istanbul-issue/node_modules/@babel/plugin-transform-block-scoping/lib/index.js:82:50)
at newFn (/Users/andy/gh/babel-plugin-istanbul-issue/node_modules/@babel/traverse/lib/visitors.js:160:14)
at NodePath._call (/Users/andy/gh/babel-plugin-istanbul-issue/node_modules/@babel/traverse/lib/path/context.js:46:20)
at NodePath.call (/Users/andy/gh/babel-plugin-istanbul-issue/node_modules/@babel/traverse/lib/path/context.js:36:17)
at NodePath.visit (/Users/andy/gh/babel-plugin-istanbul-issue/node_modules/@babel/traverse/lib/path/context.js:82:31)
at TraversalContext.visitQueue (/Users/andy/gh/babel-plugin-istanbul-issue/node_modules/@babel/traverse/lib/context.js:89:16)
at TraversalContext.visitMultiple (/Users/andy/gh/babel-plugin-istanbul-issue/node_modules/@babel/traverse/lib/context.js:61:17) {
code: 'BABEL_TRANSFORM_ERROR'
}
I can't say for sure if the fault lies with the babel core packages or
babel-plugin-istanbul
...@babel/preset-env
withforceAllTransforms: true
by itself doesn't choke on the code below, and neither doesbabel-plugin-istanbul
by itself. But when they're run together, an error gets thrown.Issue repository
https://github.com/jedwards1211/babel-plugin-istanbul-issue
Code
The
parseInt(f)
gets transformed intocov_1c743zp148().b[0][1]++, parseInt(f)
. But for some reason that expression is orphaned by the time@babel/plugin-transform-block-scoping
tries to renamef
to_f
, causing an error to be thrown.Babel config
Package versions
Error message