The optional configuration for a workspace is defined in a file such as bw.workspace.json in its directory or in its package.json file.
You can set a workspace's alias(es), the order sequence for its scripts, workspace tags (see below), and workspace dependency rules (see below).
You can also use the root config to set workspace configs in bulk by using workspace patterns. See the workspace pattern configs page for more information.
Tags are simple strings that can be used to group workspaces together. They can be used in workspace patterns.
Using the rules.workspaceDependencies field, you can define rules for which workspaces are allowed to be dependencies,
using allowPatterns, denyPatterns, or both.
Workspace patterns are used to match workspaces.
allowPatterns defines the permitted subset of dependencies. denyPatterns forbids specific dependencies.
When both are present, denyPatterns further filters within the subset permitted by allowPatterns.
You can also use negated workspace patterns to exclude workspaces from the allowed or denied list.
For example, you may disallow dependencies with the tag "backend" for a frontend workspace with denyPatterns: ["tag:backend"].
{
// Must be unique across other aliases and workspace names
alias?: string | string[],
// Tags can be used to group workspaces together
tags?: string[],
scripts?: {
[script: string]: {
// Optional sorting order for running scripts
order?: number
}
},
rules?: {
workspaceDependencies?: {
// Use workspace patterns to match workspaces to allow as dependencies
allowPatterns?: string[],
// Workspace patterns to forbid as dependencies.
// When combined with allowPatterns, filters within that allowed subset.
denyPatterns?: string[]
}
}
}
path/to/your/workspace/bw.workspace.ts
or
path/to/your/workspace/bw.workspace.js
import { defineWorkspaceConfig } from "bun-workspaces/config";
export default defineWorkspaceConfig({
alias: "myApp",
tags: [
"my-tag"
],
scripts: {
start: {
order: 10
},
test: {
order: 20
}
},
rules: {
workspaceDependencies: {
allowPatterns: [
"my-workspace-a",
"tag:my-tag",
"path:my-path/**/*",
"not:tag:my-excluded-tag"
]
}
}
});
You can use the mergeWorkspaceConfig function to merge multiple workspace configurations left to right, with each subsequent config taking precedence.
Objects are merged deeply, and array items are concatenated while keeping items unique.
import { mergeWorkspaceConfig } from "bun-workspaces/config";
export default mergeWorkspaceConfig(
{ alias: "a", tags: ["x"] },
{ alias: "b", scripts: { build: { order: 1 } } },
// Factory function receives the accumulated config up to that point
(prevConfig) => ({ tags: ["y"] }),
);
path/to/your/workspace/bw.workspace.json
or
path/to/your/workspace/bw.workspace.jsonc
{
"alias": "myApp",
"tags": [
"my-tag"
],
"scripts": {
"start": {
"order": 10
},
"test": {
"order": 20
}
},
"rules": {
"workspaceDependencies": {
"allowPatterns": [
"my-workspace-a",
"tag:my-tag",
"path:my-path/**/*",
"not:tag:my-excluded-tag"
]
}
}
}
path/to/your/workspace/package.json
{
"name": "@my-organization/my-application",
"description": "My app",
"version": "1.0.0",
"bw": {
"alias": "myApp",
"tags": [
"my-tag"
],
"scripts": {
"start": {
"order": 10
},
"test": {
"order": 20
}
},
"rules": {
"workspaceDependencies": {
"allowPatterns": [
"my-workspace-a",
"tag:my-tag",
"path:my-path/**/*",
"not:tag:my-excluded-tag"
]
}
}
}
}