You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 remove prop-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 in useInteractions, so we should re-create useInteractions to use our own version instead of importing it. There is also duplicated logic between our internal Composite component and useListNavigation. There's also a duplicated version of useId
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 since useFloating() brings it in. If FloatingFocusManager can accept floatingRootContext object, then that hook won’t need to be used. Importing only Tooltip needlessly includes the tabbable dependency and related focus guard logic since FloatingPortal brings it in. This matters less if you're using multiple components, however, since this logic will be brought in at some point anyway
The text was updated successfully, but these errors were encountered:
Inspecting the production bundle with
create-vite-app
using@base-ui-components/react
reveals some areas of improvement: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 documentationmergeReactProps
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
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 anywayThe text was updated successfully, but these errors were encountered: