From e612b6a1a4e822178f1e15b82bd2991bf1e84cec Mon Sep 17 00:00:00 2001 From: Mohammad Kurjieh <71401788+MohammadKurjieh@users.noreply.github.com> Date: Tue, 15 Aug 2023 09:28:47 +0300 Subject: [PATCH] fix(react-native): fix duplicate import (#894) When updating the imports of react-native-svg there is no check on the importKind. This would cause a wrong update import and a crash in the cli. --- .../babel-plugin-transform-react-native-svg/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/babel-plugin-transform-react-native-svg/src/index.ts b/packages/babel-plugin-transform-react-native-svg/src/index.ts index 6c217b88..41cd4301 100644 --- a/packages/babel-plugin-transform-react-native-svg/src/index.ts +++ b/packages/babel-plugin-transform-react-native-svg/src/index.ts @@ -79,7 +79,10 @@ const plugin = () => { const importDeclarationVisitor = { ImportDeclaration(path: NodePath, state: State) { - if (path.get('source').isStringLiteral({ value: 'react-native-svg' })) { + if ( + path.get('source').isStringLiteral({ value: 'react-native-svg' }) && + !path.get('importKind').hasNode() + ) { state.replacedComponents.forEach((component) => { if ( path