This content originally appeared on Bits and Pieces - Medium and was authored by Eden Ella
Learn how Bit versions individual independent components using its own set of object types.
This article assumes basic prior knowledge of git’s internals and Bit.
Independent components are developed, versioned, and collaborated on in a Bit workspace. Each component starts its way as multiple source files which are then mapped to a single component id, configured, built, and finally tagged (along with the generated artifacts) with a new release version.
To learn more about the process an independent component goes through prior to it being tagged, see here:
Independent Components: The Web's New Building Blocks
Component versioning: Generating Bit objects
$ bit tag <component-id> <version> --message "message"
Once a component has gone through its build process it is ready to be tagged with a new version. This is where Bit objects are generated from the component files, configurations, and artifacts. These objects are stored in Bit’s content-addressable storage, the ‘local scope’, which is placed in the workspace .bit or .git/bit directory.
Run the bit cat-scope command, in your workspace directory, to see all objects in your local scope.
Just like git objects, Bit objects are named with a SHA-1 hash. The output table shows the mapping between each component ID, registered in the .bitmap file, and its component-object hash.
Object types
Component
A component object stores general information about a component. That includes its component id, scope name, references to its version objects, and more. The component’s hash is not based on its content since it is not immutable. It is updated whenever a component gets tagged with a new release version.
Run bit cat-object -p <component-hash> to see the component object content.
Version/Snap
The Version/Snap object contains the following information:
- The component file structure, with references to snapshots (blobs) of the component’s source files (this section resembles Git’s ‘tree’ objects).
- References to snapshots (blobs) of the component’s artifacts (distributable code, package, etc.)
- Metadata regarding the component’s dependencies and development environment setup (including various Bit extensions that are used by that component).
- More information relating to other aspects of an independent component.
A version object (a “commit”) can be created without creating a reference to it, the version number, in the ‘component’ object. This is done by using bit snap <component-id> .
Run bit cat-object -p <version-hash> to see the content of a component version object.
Source
Source objects are snapshots of the component’s source code, compiled code, and other generated artifacts.
Let’s have a look at the content of the following file:
$ bit cat-object -p df4f3cf88950c744a22d9f5423d360c7346b8021
Putting it all together
The below diagram shows the .bitmap file referencing to specific component versions to be used by the working directory.
Learn More
- Independent Components: The Web's New Building Blocks
- Raising Productivity: Distributed Autonomous Web Development Teams
- How we Build a Design System
- How We Build Micro Frontends
How Bit Versions Independent Components was originally published in Bits and Pieces on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Bits and Pieces - Medium and was authored by Eden Ella
Eden Ella | Sciencx (2021-04-21T14:28:32+00:00) How Bit Versions Independent Components. Retrieved from https://www.scien.cx/2021/04/21/how-bit-versions-independent-components/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.