Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Is eui tree-shakeable? #5377

Closed
lightwave opened this issue Nov 14, 2021 · 3 comments
Closed

Is eui tree-shakeable? #5377

lightwave opened this issue Nov 14, 2021 · 3 comments

Comments

@lightwave
Copy link

I couldn't find any documentation about whether eui is tree-shakeable or not. Is there somewhere that document things we can do to reduce bundle size?

@thompsongl
Copy link
Contributor

I did confirm a few months ago that a properly configured webpack project will tree shake unused modules (off the top of my head that is ensuring es imports are used, production mode, and minification), though this can be cumbersome and error prone. - (#3164 (comment))

@chandlerprall might have some more details. On a broader note, though, we are working towards making EUI modular, but that is definitely a long-term effort.

@chandlerprall
Copy link
Contributor

Confirmed again via create-react-app, started with new project & added EUI+dependencies, then imported & used just the EuiButton component. Dev experience (yarn start) loads 10.7mb of resources while the production build (yarn build) only loads 241kb.

There's nothing special about tree-shaking for EUI (or shouldn't be, and that appears to be true). The webpack docs have a tree shaking guide which has always worked for me with EUI on custom, non-create-react-app projects.

For completeness, I should mentioned that the CSS bundle we provide is never pruned.

@cchaos
Copy link
Contributor

cchaos commented Nov 16, 2021

@chandlerprall Should we convert this to a Q&A discussion marked with your answer?

@elastic elastic locked and limited conversation to collaborators Nov 17, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants