Bun supports workspaces
in package.json
. Workspaces make it easy to develop complex software as a monorepo consisting of several independent packages.
To try it, specify a list of sub-packages in the workspaces
field of your package.json
; it's conventional to place these sub-packages in a directory called packages
.
{
"name": "my-project",
"version": "1.0.0",
"workspaces": ["packages/*"]
}
Glob support — Bun v0.5.8 added support for simple <directory>/*
globs in "workspaces"
. Full glob syntax (e.g. **
and ?
) is not yet supported (soon!).
This has a couple major benefits.
- Code can be split into logical parts. If one package relies on another, you can simply add it as a dependency with
bun add
. If packageb
depends ona
,bun install
will symlink your localpackages/a
directory into thenode_modules
folder ofb
, instead of trying to download it from the npm registry. - Dependencies can be de-duplicated. If
a
andb
share a common dependency, it will be hoisted to the rootnode_modules
directory. This reduces redundant disk usage and minimizes "dependency hell" issues associated with having multiple versions of a package installed simultaneously.
⚡️ Speed — Installs are fast, even for big monorepos. Bun installs the Remix monorepo in about 500ms
on Linux.
- 28x faster than
npm install
- 12x faster than
yarn install
(v1) - 8x faster than
pnpm install
