As we work on the new @wordpress/ui package, it is inevitable that there will be name collisions for components sharing the same name — as already experienced while introducing the Button component.
Especially as we will start consuming components from the package in Gutenberg, we may want to establish a renaming pattern, for example adding a prefix to each import:
import { Button as WCButton } from '@wordpress/components';
import { Button } from '@wordpress/ui';
Avoiding naming collisions will be a great DevX improvement for a few reasons:
- it will allow code maintainers to better grasp at a glance if the component comes from the legacy componetns package, or the UI package;
- it will improve code searches across the codebase, both for humans and AI agents;
- it will allow for an easier refactor and a generally better code hygiene.
We should also consider adding ESLint rules to both enforce the pattern consistently, and help with auto-fixing the code at once.
cc @WordPress/gutenberg-components