A scope is a set of components, usually they are semantically related. Exporting components to remote scopes makes them available for other developers to consume. You can create remote scopes on your own server or manage components' collections the bit.dev components hub.
In bit.dev remotes scopes are called collections. Log into an account on
bit.dev to create private or public collections.
To define your own remote scopes follow these steps.
Only components that are tagged can be exported. The tagged version is exported and resides on the remote scope. Use the bit export command to export components.
You can store components in any number of remote scopes.
bit export with no arguments, Bit attempts exporting to the original scope (the one you imported the component ). So, if you imported a component from a collection where you have no write access on, it will throw authentication error.
To export all staged components to a single scope or collection, specify a remote collection as a destination:
$ bit export user.my-collection 2 components were exported to Collection owner/my-collection
Bit exports all staged components to the
To export specific components to a collection add the component ID to the export command:
$ bit export bit.movie-app hello/world component hello/world was exported to Collection bit/movie-app
You can also use wildcards to export multiple components:
bit export owner.my-collection owner.my-collection/* # depending on your OS, you may need to wrap the component path with quotes
Components exported to Bit are consumable with package managers. Bit allows ejecting components and replaces them with its node module. The name of this process is 'ejecting'. This is sugar syntax for both deleting the local component and running
To eject a component on export, use bit export with the
$ bit export bit.movie-app --eject 2 components were exported to Collection bit/movie-app
To eject a component after export, use bit eject command:
bit eject hello/world
Multiple Remote Scopes
When a component is exported, you specify the remote scope to export:
bit export owner.my-scope my-component
For a component that is exported for the first time, Bit uses the defaultScope configuration, if exists, to export to that scope.
This scope is considered as the primary scope of the component.
If you specify a different scope on the initial export, this scope is set as the primary scope.
You can see the scope of the component when running
bit list. The scope is shown with the component name.
Export to Additional Scopes
You can export the same component to additional scopes which are different from the primary scope by specifying:
bit export owner.other-scope my-component
When component is exported to a scope which is different from the primary scope, the component remains in staging mode. Only when exported to the primary scope, it will become exported.
You can change the component primary scope when exporting to another scope by using the
--set-current-scope during the import.
When exporting to another scope, you can also export with it all the components that are dependencies of this components with a single command:
bit export owner.other-scope my-component --include-dependencies
All the components that are dependencies, are also exported to the other scope. However, the component still points to the components on their original scope as the dependencies. E.g.
scope1.compA depends on
If you run
bit export scope2.compA --include-dependencies, 2 components are created in scope2:
scope2.compA still has
scope1.compB as its dependency. To change scope2.compA to have
scope2.compB as its dependency run:
bit export owner.other-scope my-component --include-dependencies --rewire
Now in scope2 you have
scope2.compA that depends on