📝Bit.dev decouples components and packages to lower the barrier to create a new component

When working on a monorepo, package setup can become quite tedious very quickly. For every package, you want to setup the build, test, linting, code formatter, etc. Even if that's just a couple of lines (copy-pasting commands and config files), this increases the barrier for package creation—so people opt in for less modular approaches.

This can be mitigated with templating—common files are copied into the new package. But this creates a problem of maintaining the setup (how to update all the package that use similar setup).

Bit.dev solves this by decoupling components from packages. Component directory only contains files that constitute the essence of the component (it does not contain package setup files).

Bit executes “aspects” to assemble a package during the build by augmenting component files with package setup files (package.json, webpack config, jest, etc.). The resulting package is created in a temporary directory (called “capsule”).

This allows bit to abstract package setup into its own component (or package) completely. Bit.dev calls these components “env.” This has a great benefit of allowing envs to be reused—instead of setting up compiler, linter, and formatter for every package manually, you specify the env when creating a component. There are no extra files in the component and env can be automatically updated as any other dependency.

See also