Skip to content

workspaces

Command Description

This command enables rudimentary functionality similar to yarn -workspaces .... It is used to execute scripts on specified “workspaces” (folders under the /projects & /modules directories).

In the root package.json there is a script declared called ws (workspaces for short). This aliases bun run scripts/workspaces.ts to bun ws. This script accepts a few parameters workspace, script, an help.

This cli command respects passthrough parameters delimeted by -- (double hyphen). Anything following the space after -- will be passed to the underlying script called.

Input NameShorthandTypeDescription
workspacewstringName of a workspace under the package.json’s defined workspaces. Can be a workspace specific package.json script or a script in the workspace’s scripts/ directory.

Example Usage

Running a single workspace

Terminal window
bun ws --workspace foo --script build

Running a command against multiple workspaces

Terminal window
bun ws -w foo -w bar -s build

Running a command with passthrough parameters. Here the --mode param is propagated to the build command defined in the specified workspaces. This script will check the workspaces’s scripts directory first. Then the workspaces package.json scripts. If nothing is found that matches the script name it will fail.

Terminal window
bun ws -w foo -w bar -s build -- --mode production

Manually call the script

Terminal window
bun run scripts/workspaces.ts -w foo -w bar -s build