base-ui icon indicating copy to clipboard operation
base-ui copied to clipboard

Clean up exports

Open vladmoroz opened this issue 1 year ago • 1 comments

The DX of importing Base UI components should be cleaned up to avoid unnecessary noise:

  • Each component should be exported once, and not its parts
  • Types should be namespaces under component name
  • Hooks should not be exported

For example, typing Dialog in VSC should not suggest anything but the Dialog component.

Expected import styles:

import { Dialog } from '@base_ui/react';
import * as Dialog from '@base_ui/react/Dialog';

Shouldn't be a thing:

import { DialogRoot } from '@base_ui/react';
import type { DialogRootProps } from '@base_ui/react/Dialog/...'

vladmoroz avatar Sep 27 '24 07:09 vladmoroz

Based on our discussions, we agreed to drop the import * as Foo pattern and replace it with import { Foo }, so it's easier to type and VSCode suggestions include it.

import { Dialog } from '@base_ui/react';
import { Dialog } from '@base_ui/react/Dialog';

michaldudak avatar Oct 02 '24 11:10 michaldudak

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

github-actions[bot] avatar Oct 14 '24 07:10 github-actions[bot]