Answers to frequently asked questions (FAQs) about Bit
What is a Bit component?
A Bit component is a set of tracked files in a project. For each component Bit calculates a dependency graph and creates an isolated component environment.
What is a good candidate to be a Bit component?
A code component is an encapsulated piece of code which should handle a single responsibility, representing a well-defined functionality and composable with other components to build larger things. These components can be files or sets of files handled by Bit.
You can learn more in this post by Addy Osmani.
What is an isolated component environment?
Bit wraps every component with an isolated component environment that enables you to use and develop it from other projects regardless of their setup. This environment also lets Bit build and test your components independently, isolated from your project.
Bit creates a component isolated environment by tracking each individual component dependency graph (including dependencies, devDependencies, component dependencies and configurations), and recreates it inside a Scope.
How does Bit isolates components?
To eliminate the overhead of splitting or refactoring your repository, Bit lets you define files or sets of files in your project as components, which it can virtually isolate from the project.
Component dependency resolution - When tracking a set of files as a component, Bit reads through the source code of the tracked components to build a dependency graph. Bit uses it as part of the isolated component environment.
Isolated component environment - Bit creates an isolated component environment for each component, containing all dependencies and configuration to be recreated in other projects.
Component versioning and tracking - Bit tracks component changes and enables code component synchronization between Git repositories. You can import components into other repositories, make changes, update versions and merge changes between different projects.
Once isolated, components can be tagged with a version and then shared to a Scope without having to change a single codeline in your repository.
What is a Bit Scope?
Bit stores information in a data structure called a Scope. The Bit Scope is stored in the same directory as the project itself. Scopes are built in a distributed architecture, which makes them lightweight and easy to create for any level of abstraction, to host components relevant to a specific project, team or idea. You can create Scopes on the cloud or on any local server.
- Bit local Scopes stores all components for the project locally.
- Bit remote Scope is where components are stored, organized, made discoverable and available to consume by different projects. The remote Scope is stored on the cloud.
Local Scope will connect to a remote Scope to sync components in all the related project.
The remote Scope also functions as a source of truth for components imported into different repositories, through which versions can be updated and changes can be synced.
Advantages in organizing components in Scopes:
- Dynamic - Components can be dynamically added, modified or removed from Scopes.
- Discoverable - Each component becomes individually discoverable and available.
- Curateble - You can curate components on your Scopes, control the shared code quality and standards.
- Predictable and available - Component dependencies are being locked and cached in your Scope. Even if a component will be removed from its original Scope, your version of the component will keep on working.
Learn more about Scopes.
Does Bit requires me to refactor or restructure my project?
No. You do not need to change OR restructure your project in any way.
Bit creates a virtualize layer of component representation based on source files in your project. This means that Bit manages components as virtual entities pointing to files in your project.
What are common use cases for Bit?
Popular use cases for Bit are syncing UI components between apps, sharing common Node.js code between microservices, working with GraphQL APIs, turning shared libraries into component “playlists” and even syncing utility functions. You can also use Bit to more easily open-source parts of existing private projects.
Bit is also valuable for the following project structures:
Multi-Repo - When using a multi-repo or a microservices architecture, Bit is useful for sharing and syncing code between projects and services with 2-way development and change syncing.
Single Repository with Multi-Package Publishing - When using this kind of repository, also known as a “monorepo”, Bit is useful for organizing its components and making them discoverable, syncing them in other projects etc.
Shared Libraries - Bit can make all the components within these libraries available to discover, test, monitor, use and develop from any other project.
Bit can also be used to turn any existing repository into a virtual multi-package repository, without having to refactor or restructure it. Instead, you can make different parts of its existing structure available for installation with NPM and Yarn or to be consume with Bit from other repositories.
Which programming languages are supported by Bit?
Bit’s is language agnostic and uses language-specific drivers for features and operations. Still, as of today it requires language-specific drivers for language-sensitive features (binding, dependency graph resolution, component isolation, etc).
Which technologies are supported by Bit?
Does Bit integrate with package managers?
Can I use Bit with Git?
Yes. Bit knows how to work with Git configuration and grabs the necessary values from Git to your workspace. In addition, Bit recognizes a repositories’
.gitignore file. This streamline your Bit workflow according to your Git.
Can Bit be extended?
Bit’s rich API and extension mechanism let you extend Bit and integrate it with your development tools and environments. For example, Bit extensions can be used to install components with NPM, test and build components in isolation using your environments of choice, render UI components in a live playground and more.
Can I host my private code on bitsrc.io?
Who owns the code I host on bitsrc.io?
You. If you choose to open-source your code, it’s up to you to decide on its license.
Can I use bitsrc.io on my own servers (on-premise)?
You can also set up your own remote Bit Scope on any local server.
What about vendor-locking?
Bit is an open source project. A remote Bit Scope can be set up on any server.
So, you are not locked to Bit’s cloud hosting solution. However, we do recommend using bitsrc.io for its advanced discoverability features, component CI, team management platform and the ability to install components using NPM / Yarn from Bit’s Node.js package registry.