Typorithm · medium

Workspaces & Monorepos

bun-workspacesbunworkspacesmonorepofilter
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn Workspaces & Monorepos

0%

Package Manager

Add "workspaces": ["packages/*"] to the root package.json to turn a repo into a monorepo. One bun install hoists shared deps and symlinks local packages, and bun --filter <name> runs a specific package's script.

A Bun monorepo is declared by a "workspaces" array in the root package.json, where each glob like packages/* marks which folders are workspace packages.

Running bun install once at the root resolves every package, hoists shared dependencies into the root node_modules, and symlinks local packages so imports between them resolve as if they were published.

bun --filter <name> run <script> scopes a command to one workspace by its package name, letting you run, build, or test a single package without leaving the root.

01

"workspaces": ["packages/*"] declares the monorepo in root package.json.

02

One bun install hoists deps and symlinks local packages.

03

bun --filter <name> runs a single package's script.

// root package.json
{
  "workspaces": ["packages/*"]
}
bun install
bun --filter web run dev

Read the implementation

Connect each part of the code to the concept before you type.

1. Declare workspaces

The root package.json lists workspace globs; packages/* makes every folder under packages/ a workspace package.

"workspaces": ["packages/*"]

2. Install & link

A single bun install at the root hoists shared dependencies and symlinks local packages so they resolve like published modules.

bun install

3. Filter a package

--filter <name> targets one workspace by its package name, running that package's dev script.

bun --filter web run dev

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

Workspaces & Monorepos: Lesson & Practice · Typorithm | ApplyDjinn