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

Create React App build fails to minify #3

Closed
thevisioner opened this issue Sep 15, 2017 · 5 comments · Fixed by #42
Closed

Create React App build fails to minify #3

thevisioner opened this issue Sep 15, 2017 · 5 comments · Fixed by #42

Comments

@thevisioner
Copy link

I have created one project with Pts and it works really great, but when I run build script, it fails at minifying. I tried to compile library from source code, but I really don't know what exactly I need to change in configuration to make it work. Issue description at Create React App docs: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify

@williamngan
Copy link
Owner

Yes, I think the problem is that "create-react-app" uses UglifyJS, which doesn't support es6 modules.

I guess there're two options:

  • Compile everything to es5 first and then minify. Probably will need the babel builtin-extend plugin or something similar for Array subclasses that were used in Pts

  • Option 2: Use a different minify tool such as babili or uglify-es. Note that Pts uses Babili to minify, but there seems to a mobile webkit bug that prevents the minified code to run in mobile browser. Not sure if it's now fixed. FYI.

I was hoping we won't need to investigate a es5 compile workflow, but it seems like we'll need to. These build processes are really a big headache :)

If you get it to work in es5 minify, please post your suggestions here. Thanks!

@tofuness
Copy link
Contributor

This will be fixed in create-react-app 2.x.

Roadmap: facebook/create-react-app#3618
Merge: facebook/create-react-app#3618

@williamngan
Copy link
Owner

Starting with v0.6.1, you should be able to make an es5 build in create-react-app by using:

import {Pt} from 'pts/dist/es5.js'; // use this for es5 build

Alternatively, you can use a newer companion tools such as neutrino.js instead of create-react-app. Take a look at the updated pts-react-example

@gaearon
Copy link

gaearon commented Oct 2, 2018

This is fixed in 2.0.
https://reactjs.org/blog/2018/10/01/create-react-app-v2.html

@williamngan
Copy link
Owner

Awesome! We'll test Pts using create-react-app 2.0 and update the docs soon. Thanks @gaearon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants