kristerkari / react-native-svg-transformer

Import SVG files in your React Native project the same way that you would in a Web application.
MIT License
1.54k stars 116 forks source link

Support both versions of React Native Metro Babel Transformer #312

Closed gvarandas closed 7 months ago

gvarandas commented 8 months ago

The metro-react-native-babel-transformer package has been recently migrated to the React Native monorepo and published/required under the @react-native/metro-babel-transformer alias.

Starting with react-native@0.73.0, the new package is loaded by default, which makes the current implementation break when starting the metro bundler.

To solve this, a simple try/catch block that loads the new package and fallbacks to the previous one in case it doesn't exist should suffice.

chriszs commented 7 months ago

Can confirm this issue causes a failure on the latest set of React Native packages and this seems like a reasonable solution (have not tested).

bitcrumb commented 7 months ago

Could this be merged now that RN 0.73 has officialy been released?

bitcrumb commented 7 months ago

In the meantime here's a patch you can apply using patch-package: react-native-svg-transformer+1.1.0.patch

kristerkari commented 7 months ago

Oh, I wasn't aware of this. Thanks for contributing the fix!