Inputs

What is an Input?

Inputs are values considered to affect the state of a workspace or the result of a script.

A workspace's input can be one of the following:

  • A file, which must be git-trackable (not ignored and within your repo)
  • Another workspace (a dependency or may be explicitly configured as an input)
    • Note: When a workspace is an input, what determines if it affects the current workspace is whether it is affected itself
  • The version of an external dependency (e.g. an npm package)

These are set by workspace config options, which can be set at the workspace level (defaultInputs) or at the script level (scripts[name].inputs).

Defaults

The default inputs for a workspace are:

  • Files: all git-trackable files in a workspace's directory
  • Workspace dependencies: all explicit dependencies that are a workspace (via its package.json)
  • External dependencies: all dependencies in a workspace's package.json

Configuration

A workspace's inputs are can be set via workspace config.

Files

Files are specified as paths relative to the workspace's directory.

Paths with a leading / are relative to the project root. Prefix with ! to exclude.

Only git-trackable files can be considered inputs.

Workspace configuration example:

{
  "defaultInputs": {
    "files": [
      "src/**/*.ts", 
      "!src/**/*.test.ts",
      "/tsconfig.json" // relative to project root
    ],
  },
  "scripts": {
    "test": {
      "inputs": {
        "files": [
          "src/**/*.ts"
        ],
      },
    },
  },
}

Workspace Patterns

In cases such as determining affected workspaces, any explicit workspace dependencies are considered inputs to a workspace by default.

When you need to treat other workspaces like dependencies, you can also specify workspace patterns to be considered inputs to a workspace via the inputs.

Workspace configuration example:

{
  "defaultInputs": {
    "workspacePatterns": ["tag:my-tag"],
  },
  "scripts": {
    "build": {
      "inputs": {
        "workspacePatterns": ["path:my-path/**/*"],
      },
    },
  },
}

External Dependencies

By default, all other dependencies in a workspace's package.json are considered inputs to a workspace. The resolved version in bun.lock is used to determine if an external dependency has changed.

You can configure a list of specific external package names to consider inputs.

When not provided, all external dependencies are considered inputs. When provided, only the specified dependencies are considered inputs, so an empty array means no external dependencies are considered inputs.

Workspace configuration example:

{
  "defaultInputs": {
    "externalDependencies": ["lodash"],
  },
  "scripts": {
    "build": {
      "inputs": {
        "externalDependencies": ["lodash", "react"],
      },
    },
  },
}