Bit Components are owned and managed in scopes. Every component has a scope assigned to it, which becomes part of the component's ID, and is where your component will be exported to and imported from.
Head over to bit.cloud's 'create-scope' page to create a scope to host your components. Alternatively, create a scope on a self-hosted server.
The defaultScope
for components in a workspace can be set either when creating the workspace by adding the --default-scope
flag to the bit new
command, or set/updated manually in an existing workspace.
Run the following to set the default scope in an existing workspace:
Your workspace.jsonc
file should be updated accordingly:
{ "teambit.workspace/workspace": { "defaultScope": "my-account.my-scope" } }
Components created in this workspace will be set with the my-account.my-scope
scope by default.
Use the --scope
flag to override the default scope when creating a component:
Run the following to change a component's scope:
To change the scope of multiple components, use a glob pattern that matches the components you wish to change:
note
A component's scope is part of its ID and can only be changed while it is still new
, i.e. unversioned.
Once a component is versioned, see renaming components for changing its scope.
You can replace a scope with another, for all new, unversioned components in your workspace assigned that specific scope, with the bit scope rename
command:
This command will change the scope of all new, unversioned workspace components currently on the my-current-account.my-current-scope
scope to my-new-account.my-new-scope
.
The --refactor
flag updates import statements in components that use the old package names (based on the old scope name) to the new package name.