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

WIP - convert public React core properties to strings so uglify/gcc can mangle #9293

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Mar 30, 2017

Ideally, we want to be able to leverage stronger minifcations/optimizations in our tooling so we can provide even smaller bundles. Tools such as Uglify and Google Closure Compiler can do this when set to mangle internal properties. However, this can break things when properties are expected to be consumed in the wild/public or by contract from another module.

The simplest way to deal with this limitation is to manually specify that the property shouldn't be altered when it's a string literal. Whitelisting is also an option, however that has some limitations and can result in properties that aren't public not being mangled simply because of them being a common name.

This PR is a WIP.

@sophiebits
Copy link
Collaborator

Does this mean we need to change every single native method call? Ex: .map(), .indexOf(), etc.

@trueadm
Copy link
Contributor Author

trueadm commented Mar 30, 2017

@spicyj No, we shouldn't have to. They should all be natively supported. Well, they definitely are in gcc.

var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
Symbol.for &&
Symbol.for('react.element')) ||
const SymbolFor = Symbol.for;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will throw in environments without Symbol

@gaearon
Copy link
Collaborator

gaearon commented Oct 4, 2017

Tracking in #11092.

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

Successfully merging this pull request may close these issues.

6 participants