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

Convert clsx import to clsx/lite #22

Open
oliviertassinari opened this issue Dec 30, 2023 · 4 comments · May be fixed by #23
Open

Convert clsx import to clsx/lite #22

oliviertassinari opened this issue Dec 30, 2023 · 4 comments · May be fixed by #23

Comments

@oliviertassinari
Copy link

oliviertassinari commented Dec 30, 2023

See for why https://twitter.com/lukeed05/status/1740841680364773646

It would help reduce the bundle size on Material UI's side: mui/material-ui#40366.

cc @lukeed

@lukeed
Copy link

lukeed commented Dec 30, 2023

+1 here. I meant to link to this plugin in the tweet but forgot to 🤦‍♂️ this plugin is a perfect match & furthers why clsx/lite was good to have

@lukeed
Copy link

lukeed commented Dec 30, 2023

Altho the way (I think) this plugin works, “clsx/lite” just needs to be defined in options.libraries — either the users or default options

@merceyz
Copy link
Owner

merceyz commented Dec 30, 2023

Convert clsx import to clsx/lite

The plugin could only do that when it knows the value is a string but when it knows that it just removes the function call:
https://github.com/merceyz/babel-plugin-optimize-clsx/tree/bdd548fd2d4314385d62564dcfe124d9d461db0e#unnecessary-function-calls

In the example from the clsx release, from the plugins perspective, props.className could be anything.

@lukeed
Copy link

lukeed commented Dec 30, 2023

props.className could be anything

true, altho 99% safe bet is string

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

Successfully merging a pull request may close this issue.

3 participants