godaddy / svgs

svgs is a compatiblity layer between svg and react-native-svg
MIT License
191 stars 31 forks source link

Can't make it work with create-react-app #3

Closed 7ynk3r closed 7 years ago

7ynk3r commented 7 years ago

Hi there,

This is the missing piece of react-native-web. Thanks you so much for creating it!

Now, I'm facing the following problem. I'm trying to use the library with a fresh project generated with create-react-app but I'm getting the following error.

Error in ./~/svgs/index.js
Module parse failed: [...]/svgs/index.js Unexpected token (67:9)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (67:9)
 @ ./src/App.js 22:12-27

How can I fix this?

Thanks again, JM

3rd-Eden commented 7 years ago

I'm going to assume this is because the published version is in ES6 instead of ES5. I've created an PR to publish in ES5, and still have ES6 for React-Native.

7ynk3r commented 7 years ago

Hi @3rd-Eden, thanks for the response!

I come from react native and I'm fairly new to react web. Is there a way to consume es6 modules from a web app generated with create-react-app. With that, I can use SVGS as it's right now.

Cheers, JM

3rd-Eden commented 7 years ago

We published it as ES5 in 2.1.0, but it doesn't resolve the issue it seems because it probably still uses the browser field in the package.json for the code but we need that as ES6 and set to ./index so the react-native packager can find the index.native.js file and use the ES6 version of it.

3rd-Eden commented 7 years ago

Is this still the case with 3.0.0 now that #8 got merged and released?

taylor1791 commented 7 years ago

I can confirm that v3.0.0 works with create-react-app.

7ynk3r commented 7 years ago

yay! thanks everyone!

3rd-Eden commented 7 years ago

Thanks for the confirmation, closing the issue.