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

v4 not compatible with create-react-app #261

Closed
barbalex opened this issue Feb 26, 2018 · 3 comments · Fixed by #266
Closed

v4 not compatible with create-react-app #261

barbalex opened this issue Feb 26, 2018 · 3 comments · Fixed by #266

Comments

@barbalex
Copy link

barbalex commented Feb 26, 2018

I am using create-react-app (https://github.com/facebook/create-react-app).

After updating to v4 (which worked fine in dev mode) production build fails:

alexa@DESKTOP-6C4V66Q C:\Users\alexa\ae2
> yarn build
yarn run v1.3.2
$ react-scripts build
Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file:

        ./node_modules/json2csv/lib/JSON2CSVBase.js:9

Read more here: http://bit.ly/2tRViJ9

create-react-app explains the issue here: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify

It seems like the breaking part is uglify, see here: facebook/create-react-app#984 (comment)

So the reason for my (and likely lots of other people's) build breaking is that json2csv does not compile to es5.

I do realize that it is nice to code using es6 - I do it myself. But can you please compile it to es5 as long as this prevents usage in most browser use cases?

@knownasilya
Copy link
Collaborator

The code is already bundled using webpack, see the dist folder.

@barbalex
Copy link
Author

barbalex commented Feb 26, 2018

I don't know if I understand you correctly.

The issue is not that the code is bundled using webpack. The issue is that the code is using es6. And that create-react-app uglifies all imported code. And that this only works with es5 code, causing above error if the code is es6.

The issue is also that older browsers will fail to understand es6 code. That is the reason why create-react-app expects libraries to use es5.

It should not be too hard to compile this library es6 code back to es5 as you seem to be using webpack.

@juanjoDiaz
Copy link
Collaborator

I'm currently working on this.

This was referenced Feb 27, 2018
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 a pull request may close this issue.

3 participants