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

Tree shaking is broken #1238

Closed
grefrit opened this issue Mar 14, 2022 · 2 comments · Fixed by #1247
Closed

Tree shaking is broken #1238

grefrit opened this issue Mar 14, 2022 · 2 comments · Fixed by #1247

Comments

@grefrit
Copy link

grefrit commented Mar 14, 2022

What package within Headless UI are you using?
@headlessui/react

What version of that package are you using?
v1.5.0

What browser are you using?
Chrome

Reproduction URL

  1. Clone https://github.com/GrefriT/headlessui-bug
  2. yarn
  3. yarn build
    It will generate bundle map

Describe your issue
Hello. It seems that version 1.5.0 broke tree shaking. I'm using headlessui in NextJS project
image
Also I see that bundlephobia can't build this package
image

@RobinMalfait
Copy link
Member

This should be fixed by #1247, and will be available in the next release.

You can already try it using:

  • npm install @headlessui/react@insiders or yarn add @headlessui/react@insiders.
  • npm install @headlessui/vue@insiders or yarn add @headlessui/vue@insiders.

Before:
image

After:
image

@grefrit
Copy link
Author

grefrit commented Mar 17, 2022

Amazing, butt... I can't confirm it's working or not, because of this Type error:

Type '(<TTag extends ElementType<any> = "button">(props: Props<TTag, SwitchRenderPropArg, "name" | "value" | "onChange" | "checked" | SwitchPropsWeControl> & { ...; }, ref: Ref<...>) => Element | null) & { 
...; } & { ...; }' does not satisfy the constraint 'JSXElementConstructor<any> | keyof IntrinsicElements'.
  Type '(<TTag extends ElementType<any> = "button">(props: Props<TTag, SwitchRenderPropArg, "name" | "value" | "onChange" | "checked" | SwitchPropsWeControl> & { ...; }, ref: Ref<...>) => Element | null) & { ...; } & { ...; }' is not assignable to type '(props: any) => ReactElement<any, any> | null'.

I'm using ComponentProps<typeof Switch> to extract types (ComponentProps imported from 'react'). Probably, headlessui should export component props, because for example, I'm building my own components on top of headlessui component for UI consistency

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.

2 participants