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

Compile to ES5 before publish to npm #5

Closed
walmink opened this issue Jun 19, 2018 · 4 comments
Closed

Compile to ES5 before publish to npm #5

walmink opened this issue Jun 19, 2018 · 4 comments

Comments

@walmink
Copy link
Collaborator

walmink commented Jun 19, 2018

React cannot minify this repository during build, because it hasn't been compiled to ES5. The React team recommends compiling packages to ES5 before publishing to ES5.

Of course, you may have your own needs and reasons for not having it compiled to ES5. I just wanted to inform you that compiling it will make this repository more relevant for React developers. The alternative for React developers is forking it or copying it to project code (both not ideal).

@alexbol99
Copy link
Owner

alexbol99 commented Jun 19, 2018

Yes, I know about this recommendation.
When I built my applications, I went to webpack.config.prod.js in node_modules/react-scripts/config/
and commented out Uglify plugin.
Till now I am running non-minified and waiting for the better plugin that will support ES6.
Is this workaround acceptable for your project (assuming you also use create-react-app)?

@walmink
Copy link
Collaborator Author

walmink commented Jun 19, 2018

Thanks for sharing your approach. I considered copying the code into my source code, but that's just too messy. Your suggestion is better and is fine for now: I'm still in development and file size is not my main concern, as I'm planning to release it as a React app wrapped into a native mobile app.

Fingers crossed a better or updated plugin will be available in the near future!

@alexbol99
Copy link
Owner

Since v0.6.2 I will add the package precompiled to es5 (not minified)
It uses commonjs2 format, so the import of the package have to be like following:

import Flatten from "flatten-js/dist/flatten.commonjs2"

Then you can build you app in production.
No need to switch off Uglify plugin anymore.
See this demo project and here it is live.

@alexbol99 alexbol99 reopened this Aug 17, 2018
@alexbol99
Copy link
Owner

This request is outdated

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

No branches or pull requests

2 participants