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

Investigate babel-plugin-optimize-react #15238

Closed
eps1lon opened this issue Apr 7, 2019 · 2 comments
Closed

Investigate babel-plugin-optimize-react #15238

eps1lon opened this issue Apr 7, 2019 · 2 comments

Comments

@eps1lon
Copy link
Member

eps1lon commented Apr 7, 2019

We try to stick to the namespace import of react via import React from 'react'; and then always use member access when using hooks i.e. const [labelWidth, setLabelWidth] = React.useState(0);.
This has poor minifaction potential (usually member access can't get mangled) and combined with array destructuring this blows up quite a bit:

var _React$useState = _react.default.useState(0),
    _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
    labelWidth = _React$useState2[0],
    setLabelWidth = _React$useState2[1];

Facebook recently released babel-plugin-optimize-react which addresses these issues. The PR that would include this into react-scripts is still open.

Did some earlier testing (eps1lon#6) and reductions seemed promising. Since we have now a bigger sample size of hooks usage patterns it would be nice if someone investigates the build changes introduced by this plugin. A branch that includes the build in version control and a diff that shows all the build changes would be nice.

@siriwatknp
Copy link
Member

I believe that the plugin is outdated, so I'm closing this.

Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

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.

3 participants