Run the following to rename a component:
bit rename COMPONENT_SOURCE_NAME COMPONENT_TARGET_NAME [--scope SCOPE_TARGET_NAME] [--refactor]
For example, the following command renames teambit.base-ui/loaders/skeleton
to teambit.base-ui/placeholders/skeleton
:
bit rename loaders/skeleton placeholders/skeleton
Versioned components, unlike new components, might already be used by other components outside your workspace. For that reason, Bit sets the renamed component as 'deprecated' and adds a pointer to the new component.
$ bit show teambit.base-ui/loaders/skeleton ┌───────────────────┬────────────────────────────────────────────────────────────┐ │ id │ teambit.base-ui/loaders/skeleton@0.0.1 │ ├───────────────────┼────────────────────────────────────────────────────────────┤ │ deprecated │ true (new-id: my-org.my-scope/inputs/button) │ ├───────────────────┼────────────────────────────────────────────────────────────┤ │ ... │ ... │ └───────────────────┴────────────────────────────────────────────────────────────┘
A pointer pointing to the deprecated component is added to the new component, as well.
$ bit show teambit.base-ui/placeholders/skeleton ┌───────────────────┬────────────────────────────────────────────────────────────┐ │ id │ teambit.base-ui/placeholders/skeleton │ ├───────────────────┼────────────────────────────────────────────────────────────┤ │ deprecated │ false │ ├───────────────────┼────────────────────────────────────────────────────────────┤ │ renaming │ origin: my-org.my-scope/ui/button@0.0.1 │ ├───────────────────┼────────────────────────────────────────────────────────────┤ │ ... │ ... │ └───────────────────┴────────────────────────────────────────────────────────────┘
Use the --refactor
option to update import statements across all dependent components in your workspace. For example:
bit rename loaders/skeleton placeholders/skeleton --refactor
All occurrences of import { Skeleton } from '@teambit/base-ui.loaders.skeleton'
are now replaced by import { Skeleton } from '@teambit/base-ui.placeholders.skeleton'
.