Building Components

Bit components can be built from any execution environment using Bit’s isolated component environment.

The build process of bit components is done in an isolated component environment, using compilers, environments - a special kind of extension.

In order to build a component, you need to have a compiler defined.

Defining a default compiler for your project

A compiler is defined per Scope. Once defined, building a component within that Scope will build the component using the defined compiler. In order to do that, just import the compiler:

$ bit import bit.envs/compilers/babel --compiler
the following component environments were installed
- bit.envs/compilers/babel@0.0.7

You can now go take a look at the env configuration in your bit.json and see your compiler over there.

Curated list of build environments on Bitsrc.io

You can find a list of Build Environments maintained by the bitsrc.io team here.

Building your component

Once you have a defined compiler, you can build your component:

$ bit build foo/bar
foo/bar
dist/foo/bar.js
dist/foo/bar.js.map

Building a component remotely

When staging or exporting components, Bit runs When staging or exporting components, Bit runs the components’ extensions in an isolated component environment. So the build process for the component will run outside of the context of the project. This will help to understand how separated the component truly is.

Self-managed Scope

After exporting a component to a self-managed remote Scope, the component will be built in the remote Scope in an isolated component environment.

bitsrc.io-managed Scope

After exporting a component to a bitsrc.io-managed Scope, bitsrc.io will create an isolated container, where the component will be built in the remote Scope in an isolated component environment. As the Scope owner or collaborator, you can enter the component page on bitsrc.io, and view the build log in the Console Output tab.

Set dist target and entry

You can set your dist target and entry by editing the bit.json.

Implementing a component compiler

You can implement your own custom compiler. See here for more details.