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

[RFC] babel-plugin-optimize-material-ui #16280

Open
eps1lon opened this issue Jun 18, 2019 · 0 comments
Open

[RFC] babel-plugin-optimize-material-ui #16280

eps1lon opened this issue Jun 18, 2019 · 0 comments
Labels

Comments

@eps1lon
Copy link
Member

eps1lon commented Jun 18, 2019

Just drafting some ideas. Any input welcome.

prop tree-shaking

Now that we have full module tree-shaking support for our components it's only logical to go the next step and enable prop tree-shaking.

Consider the following component:
<TextField variant="outlined" />

With this component you will not only get all three variants of the TextField but also the Select component. It would be better for bundle size and perf if only the OutlinedInput is included in the bundle.

We could create an OutlinedTextField component and replace the above usage with <OutlinedTextField />. Either by rewriting <TextField /> to only consist of pattern matching that delegates the props to these new components or with the help of some compiler (do they exists?) that can analyze code paths and strip out unused ones (sounds like a job for code coverage analysis).

Possible candidates:

  • TextField
  • Button
  • ListItem (button prop)

other ideas?

There may be more optimizations possible. In general build time flags and rollup sounds like a good fit. This might already be good enough to auto-generate more focused components.

Prior art

This is similar to facebook/react#7323 but instead of inlining we could split up a component into 3 and use that. This could then be further optimized by inlining.

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

No branches or pull requests

2 participants