Renaming Components

Run the following to rename a component:

bit rename COMPONENT_SOURCE_NAME COMPONENT_TARGET_NAME [--scope SCOPE_TARGET_NAME] [--refactor]
CopiedCopy

For example, the following command renames teambit.base-ui/loaders/skeleton to teambit.base-ui/placeholders/skeleton:

bit rename loaders/skeleton placeholders/skeleton
CopiedCopy

Deprecate and rename

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)├───────────────────┼────────────────────────────────────────────────────────────┤
......└───────────────────┴────────────────────────────────────────────────────────────┘
CopiedCopy

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├───────────────────┼────────────────────────────────────────────────────────────┤
......└───────────────────┴────────────────────────────────────────────────────────────┘
CopiedCopy

Refactoring

Use the --refactor option to update import statements across all dependent components in your workspace. For example:

bit rename loaders/skeleton placeholders/skeleton --refactor
CopiedCopy

All occurrences of import { Skeleton } from '@teambit/base-ui.loaders.skeleton' are now replaced by import { Skeleton } from '@teambit/base-ui.placeholders.skeleton'.