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

Provide unminified production distribution #5242

Closed
jochenberger opened this issue Oct 22, 2015 · 7 comments
Closed

Provide unminified production distribution #5242

jochenberger opened this issue Oct 22, 2015 · 7 comments

Comments

@jochenberger
Copy link

It would be nice if there was an unminified react-production.js in the release distributions. For example, this is useful for web application frameworks that do their own minification during runtime.

@iamdustan
Copy link
Contributor

Running your project with NODE_ENV=production should achieve your desired effect.

@jochenberger
Copy link
Author

I'm not talking about a node project. ;-) I use the dist/react.js file as an AMD module in a Java webapp.

@gaearon
Copy link
Collaborator

gaearon commented Oct 22, 2015

I think @iamdustan doesn't mean Node, he means using envifying (with something like loose-envify or webpack's DefinePlugin). After you envify the development build, it's going to replace process.env.NODE_ENV checks inside React with false, and then UglifyJS will eliminate these as dead branches. That's how React works when used from NPM, for example.

@zpao
Copy link
Member

zpao commented Oct 22, 2015

@gaearon yea, but that still means integrating node into your workflow. I think the ask is more about separating the minification part from the prod/dev split. And honesty I've thought about doing this for a while, making it clearer that react.min.js is not simply react.js minified (which is a different pattern than a lot of libs).

react.dev.js
react.dev.min.js
react.prod.js
react.prod.min.js

But apart from making it clearer for people who are inadvertently using the dev build in prod, I'm not sure what the real wins are. Minifiying an already minified lib isn't ideal but it should be harmless.

@jochenberger could you explain why this would be helpful?

@jochenberger
Copy link
Author

@zpao Separating minification from the split is exactly my point. I use React in a Java web application framework. Users of the framework can enable or disable minification and toggle between development and production mode. Those settings are orthogonal (though the default settings are dev=>no minification, prod=> minification)
If a user chooses to disable minification in production, I'd like to be able to serve an unminified production version.

@jochenberger
Copy link
Author

See also #7242

@gaearon
Copy link
Collaborator

gaearon commented Oct 3, 2017

We've actually gone into the opposite direction, and now minify even the CommonJS version ourselves in production mode. Doing this lets us apply optimizations that wouldn't otherwise be easy, consistently regardless of the bundler on the consuming side.

We don't expect people to need to debug React code itself so we don't plan to provide an unminified production mode. But if you feel strongly about it, you can build React from source and disable minification.

@gaearon gaearon closed this as completed Oct 3, 2017
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

4 participants