Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check for type imports in transform-react-native-svg #907

Conversation

yashsriv
Copy link
Contributor

@yashsriv yashsriv commented Sep 25, 2023

Summary

I was trying to use the babel-plugin-transform-react-native-svg separately in babel without svgr and hit an issue where it wouldn't update the import declaration.

I managed to pin it down to the new check added in #894. As per the babel spec for imports, importKind will be null | 'type' | 'typeof' | 'value'. When using babel to parse an existing import, its being parsed as 'value'...

I think its null when working with svgr because when we add the import declaration to the AST, we don't specify the import kind parameter when calling getOrCreateImport.

Test plan

Add a new test to index.test.ts for babel-plugin-transform-react-native-svg:

$ pnpm run test babel-plugin-transform-react-native-svg

Before my changes:
image

After my changes:
image

@vercel
Copy link

vercel bot commented Sep 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
svgr ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2023 0:23am

@codecov
Copy link

codecov bot commented Sep 28, 2023

Codecov Report

Merging #907 (82b214f) into main (308672d) will increase coverage by 0.42%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #907      +/-   ##
==========================================
+ Coverage   92.89%   93.31%   +0.42%     
==========================================
  Files          32       32              
  Lines         760      763       +3     
  Branches      255      258       +3     
==========================================
+ Hits          706      712       +6     
+ Misses         53       50       -3     
  Partials        1        1              
Files Coverage Δ
...bel-plugin-transform-react-native-svg/src/index.ts 98.03% <100.00%> (+6.37%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@gregberge gregberge merged commit f73f14d into gregberge:main Sep 28, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants