-
-
Notifications
You must be signed in to change notification settings - Fork 424
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
Add a mode to create react-native svg using expo #289
Add a mode to create react-native svg using expo #289
Conversation
Using an ejected ExpoKit after version 32 prevents `import Svg from 'react-native-svg';` from working, and also prevents the developer from adding 'react-native-svg' as a direct dependency since ExpoKit already provides the library just behind the ExpoKit svg namespace. See kristerkari/react-native-svg-transformer#13 This handles that case by allowing a `expo: true` flag to be passed instead of the `native` option and will create the correct import statement to use Expo's SVG library as well as prefix all non `<Svg />` components with `Svg.`.
This pull request is automatically deployed with Now. |
Codecov Report
@@ Coverage Diff @@
## master #289 +/- ##
==========================================
+ Coverage 85.3% 85.37% +0.07%
==========================================
Files 30 30
Lines 449 458 +9
Branches 125 129 +4
==========================================
+ Hits 383 391 +8
- Misses 55 56 +1
Partials 11 11
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #289 +/- ##
==========================================
+ Coverage 85.3% 85.37% +0.07%
==========================================
Files 30 30
Lines 449 458 +9
Branches 125 129 +4
==========================================
+ Hits 383 391 +8
- Misses 55 56 +1
Partials 11 11
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @edpaget, thanks for this PR! Just a small change in the preset API. Also please check if readmes have to be updated.
packages/babel-preset/src/index.js
Outdated
if (opts.native) { | ||
plugins.push(transformReactNativeSVG) | ||
if (opts.native || opts.expo) { | ||
plugins.push([transformReactNativeSVG, { expo: !!opts.expo }]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think we should use native: { expo: true }
instead of a direct expo
option.
Codecov Report
@@ Coverage Diff @@
## master #289 +/- ##
==========================================
+ Coverage 85.3% 85.37% +0.07%
==========================================
Files 30 30
Lines 449 458 +9
Branches 125 129 +4
==========================================
+ Hits 383 391 +8
- Misses 55 56 +1
Partials 11 11
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #289 +/- ##
==========================================
+ Coverage 85.3% 85.86% +0.56%
==========================================
Files 30 30
Lines 449 460 +11
Branches 125 130 +5
==========================================
+ Hits 383 395 +12
+ Misses 55 54 -1
Partials 11 11
Continue to review full report at Codecov.
|
e86ae78
to
31849a6
Compare
Thanks for the review @neoziro (and for the library!). I've change the option to expect the |
31849a6
to
dd8fd78
Compare
Thanks @edpaget, could you fix tests please? Also please run |
Run yarn format
Thanks! |
Summary
Using an ejected ExpoKit after version 32 prevents
import Svg from 'react-native-svg';
from working, and also prevents the developer from adding'react-native-svg' as a direct dependency since ExpoKit already provides the
library just behind the ExpoKit svg namespace. See
kristerkari/react-native-svg-transformer#13
This handles that case by allowing a
expo: true
flag to be passed instead ofthe
native
option and will create the correct import statement to use Expo'sSVG library as well as prefix all non
<Svg />
components withSvg.
.Test plan
Added an additional test case to show the import statement and the component name prefixing.