Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Workspaces

Several packages in one repo, sharing one lock and one vendor/.

Got several packages in one repo? Make it a workspace. They all share one composer.lock and one vendor/ at the root.

Set it up

  1. List the members in the root pun.toml:

    [workspace]
    members = ["packages/*", "apps/*"]
  2. Give each member a composer.json with a name:

    {
        "name": "acme/billing",
        "require": {
            "acme/core": "*"
        }
    }
  3. Run pun install.

That’s it. Pun links each member into vendor/, so members can require each other like normal packages.

Good to know

  • A folder without a composer.json is skipped.
  • Every member needs a name, and no two can share one.
  • * in a glob matches one folder name, not nested ones.
  • Members must live inside the workspace root. A glob such as ../other/*, or a symlink to a folder outside the root, is an error.
  • The root doesn’t need its own composer.json. Add one only for root-level requirements.

Working inside a member

pun install, update, require and remove work from any member folder. They always use the root lock and vendor/.

require and remove change the member you’re in. To change another one, use -p:

pun require -p acme/billing guzzlehttp/guzzle

Edited a member’s composer.json by hand? Run pun update <member>, because pun install won’t notice.

Last updated on

Was this page helpful?