-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Tree shaking #303
Comments
It seems like some parts are not optimized or can't be optimized. Just installed headlessui and used only one definition: import { Transition } from '@headlessui/react' Now it's second biggest dep:
Looking at the original file:
it's a reduction, but, well, still too big. |
Hey! Thank you for your bug report! This PR that was already merged improves tree shaking a lot: #602 |
@RobinMalfait do i need to enable anything to make it work? i'm using next.js & only |
Hey all, I'm just re-visiting this package as the lack of tree shaking made me opt for another approach a few months ago. Looking to add this to a new project (also Next.js like @deadcoder0904) but want to make sure tree shaking is being fully handled first? Thanks for all your hard work! |
hey guys, maybe something changed and tree shaking got broken along the way. |
Yeah well first things first... 😂 Best of luck! |
yeah, @TheRusskiy this can wait, take care :) |
Hate to be that guy, but did anyone figure out how to tree shake here? I'm getting 65kb from just from Combobox. |
😢still no treeshaking. I just want to use |
has treeshaking been implemented?👀 |
Seems to be working with vite swc, 11KB when only switch is used. |
@BasicallyMe there is not a lot to implement here (sure we can make sure that we don't include everything in every file, or that we don't mess with globals), but typically you don't implement tree shaking in the library. We are the tree, you have to shake it. |
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
v0.2.0
What browser are you using?
Chrome
Reproduction repository
https://github.com/tailwindlabs/tailwindcss.com
(As mentioned in Discord)
I don't think Tree Shaking is working / fully optimized. You can see this even in the bundle on tailwindcss.com – the only Component in use is
<Switch />
and yet inspecting the (impressive!) coverage of the website's Next.js bundle contains references toheadlessui-menu
,headlessui-listbox
, etc.This is more problematic using Components from the dev branch where even more Components are bundled – whether they're in use or not.
(I could be misunderstanding something about the nature/purpose/design of tree shaking in this context I just thought to mention it)
The text was updated successfully, but these errors were encountered: