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

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 a new component (that has the new name).

$ 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 the import statements in all dependent components (in the same 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'.

on this page
Refactoring