Understanding component's dependencies, devDependencies and peerDependencies

Dependencies, devDependencies, and peerDependencies are calculated automatically by Bit. Bit than takes the results, and create a package.json file for each Component.

Here’s a quick recap of how it works:

Bit reads each component’s code AST and lists all required/imported packages. Afterward, it splits those packages into three categories; dependencies, devDependencies, and peerDependencies using the following set of rules:

  1. If the required package is configured in the root package.json as a peerDependency, Bit will set it as a peerDependency for all components that depends on it.
  2. According to the specific file-type within the Component (implementation or a test-file) that requires a package;
  • Bit will set a devDependency for all packages required by test files.
  • A dependency will set for all packages required by implementation-files.

Several notes:

  • If the same package is listed as a peerDependency and a dependency/devDependency in your package.json, Bit will consider it as a peerDependency.
  • Package required by both test-file and implementation-file will be set as a dependency.