Closed rehandalal closed 3 years ago
Making this change does appear to fix things but this definitely feels like a bug:
import React from "react";
import * as rsuite from "rsuite";
const Tester = ({ withIcon }) => {
let Component = rsuite.Button;
if (withIcon) {
Component = rsuite.IconButton;
}
return <Component>Test</Component>;
}
export default Tester;
I use destructuring imports with many projects without issue. Likely there is a conflict between babel-plugin-istanbul and another babel plugin you are using, though I'm unsure what we (istanbul) would do to remedy this. We don't actually manipulate import statements at all (no coverage counters are added to them).
Looking at the Yarn lockfile there are two potential plugins: babel-plugin-import
and babel-plugin-dynamic-import-node
which seem like they may be culprits. I do notice that #161 is filed for babel-plugin-import
and seems to describe a similar issue.
Thanks for the update, closing this as I believe you are experiencing the babel-plugin-import issue.
I created a little sample repo to outline the problem: https://github.com/rehandalal/bugxample
The example file looks like this:
It compiles to:
This results in a
ReferenceError
asButton
does not seem to get imported or defined at all: