fix: move babel named import into jsx visitor

This commit is contained in:
Mark Lawlor
2022-10-30 22:28:11 +10:00
parent 84528188ea
commit f78bbbabb4

View File

@@ -64,18 +64,13 @@ export function styledComponentTransform(
PluginPass & {
opts: StyledComponentTransformOptions;
isInContent?: boolean;
didTransform?: boolean;
addedNativeWindImport?: boolean;
}
> = {
Program: {
enter(_, state) {
state.blockList = new Set();
},
exit(path, state) {
if (state.didTransform) {
addNamed(path, "StyledComponent", "nativewind");
}
},
},
JSXElement(path, state) {
const filename = state.filename;
@@ -126,7 +121,11 @@ export function styledComponentTransform(
path.node.children
)
);
state.didTransform = true;
if (!state.addedNativeWindImport) {
state.addedNativeWindImport = true;
addNamed(path, "StyledComponent", "nativewind");
}
},
};