A capsule is a temporary directory Bit creates for each component for running build tasks. It plays an essential role in validating that a component is decoupled from the workspace, and will be able to function properly in other host projects.
For example, a component that does not have 'module-a' in its dependency graph, but needs it in order to function, may be able to function in its workspace (provided the module was installed in the workspace), but will fail to function in a Capsule, where packages are only installed for that specific component.
. ├── page └─── node_modules └── module-a # installed due to 'component-a' └── scope └── component-a # has module-a in its dependency graph └── component-b # does not have module-a in ist dependency graph although it does need it
Capsules are located in Bit's capsules
directory:
- macOS:
~/Library/Caches/Bit/capsules/
- Windows:
%LOCALAPPDATA%\Bit\capsules\
To change the location of that directory (globally):
bit config set capsules_root_base_dir "my-new-path"
Component capsules are generated for each build inside a common directory for the workspace. That common directory is named with a hash based on the absolute path of the workspace. It may also include assets shared by components of the same Env (for example, the preview bundles).
For example:
├── /Users/.../Library/Caches/Bit/capsules/f170673b3ef2c76c19d7c6ca9e37decddac38e6d ├── company.scope_envs └── my-react@0.0.1-preview # preview assets for Env 'envs/my-react' ├── company.scope_envs_my-react@0.0.1 # component capsule ├── company.scope_ui_heading@0.0.1 # component capsule └── company.scope_ui_text@0.0.1 # component capsule
Capsules are temporary
Each build starts by removing the capsule that was previously generated for the same workspace.
Bit creates a network of capsules. A network is a group of capsules that are linked according to their dependency relationships. The different capsules in the network are symlinked between each other, so that when a component requires another, it depends on the output found in the capsule.
- 'Seeders': Components that where explicitly built (e.g, bit build <components)>).
- 'Graph capsules' Seeders and their dependencies
Learn more about Network
here.