Open
Description
Inspecting the production bundle with create-vite-app
using @base-ui-components/react
reveals some areas of improvement:
- Extra
prop-types
logic is included in the final bundle: Even though.propTypes
assignments are removed in prod, there's some extra code related to it when inspecting the bundle. We should removeprop-types
entirely if possible in the final build, and only use it for documentation - Minified errors: Context error messages aren’t minified for production, we can use a simple short/reusable message for production instead
- Duplicated logic between Floating UI and Base UI: Another version of
mergeReactProps
is used inuseInteractions
, so we should re-createuseInteractions
to use our own version instead of importing it. There is also duplicated logic between our internalComposite
component anduseListNavigation
. There's also a duplicated version ofuseId
- Needless destructuring and re-passing of variables: we can pass the whole object in most cases, reducing unnecessary variable assignments. This is done for some components but not others
- Avoid unnecessary dependencies: importing only
Dialog
needlessly includes all anchor positioning logic sinceuseFloating()
brings it in. IfFloatingFocusManager
can acceptfloatingRootContext
object, then that hook won’t need to be used. Importing onlyTooltip
needlessly includes thetabbable
dependency and related focus guard logic sinceFloatingPortal
brings it in. This matters less if you're using multiple components, however, since this logic will be brought in at some point anyway
Metadata
Metadata
Assignees
Labels
Projects
Status
In progress