Transformation issue with es2015See original GitHub issue
I noticed that my
commonjs build included the incorrectly transformed
This is incorrect as the
import is being transformed to
var _invariant and
invariant isn’t defined.
The issue can be reproduced in babel repl.
Not sure if
invariant(false) can be converted to
(0, _invariant.default)(false) or whatever.
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
The plugin reuses
node.callee in the transformed AST. Babel can not tell they are actually different AST nodes, so only one of them is replaced by commonjs transform. Use
prodInvariant will fix this issue: In my local repo I can not reproduce this issue with the suggested fix.
It might be that it just messes with the scope/binding info enough that it doesn’t connect them anymore. Or maybe it tracks through the callExpression, not the callee? Seems like just swapping out the arguments instead of the whole expression might fix it