Skip to content

fix(tools): support object-form workspaces in BunTool#266

Merged
Andarist merged 4 commits intoThinkmill:mainfrom
MatthieuMordrel:fix/bun-object-form-workspaces
Feb 23, 2026
Merged

fix(tools): support object-form workspaces in BunTool#266
Andarist merged 4 commits intoThinkmill:mainfrom
MatthieuMordrel:fix/bun-object-form-workspaces

Conversation

@MatthieuMordrel
Copy link
Copy Markdown
Contributor

Summary

Bun supports an object-form workspaces field in package.json for features like workspace catalogs:

"workspaces": {
  "packages": ["apps/*", "packages/*"],
  "catalog": { "some-dep": "^1.0.0" }
}

BunTool only checked Array.isArray(pkgJson.workspaces), so it missed monorepos using this object form. This caused findRoot to fall through to RootTool, treating the project as a single-package repo and skipping all workspace packages.

The fix mirrors YarnTool's existing approach — it already handles both string[] and { packages: string[] }.

Changes

  • BunTool.isMonorepoRoot / isMonorepoRootSync — now recognize workspaces.packages in addition to the array form
  • BunTool.getPackages / getPackagesSync — extract globs from either workspaces (array) or workspaces.packages (object)
  • BunPackageJSON type — updated to string[] | { packages: string[] }

Test plan

  • Added basic-bun-object-workspaces fixture for findRoot tests
  • Added bun-object-workspace-base fixture for getPackages tests
  • All 93 tests pass (92 existing + 2 new, 1 skipped)

Bun supports an object-form `workspaces` field in package.json for
features like workspace catalogs:

  "workspaces": {
    "packages": ["apps/*", "packages/*"],
    "catalog": { "some-dep": "^1.0.0" }
  }

BunTool only checked for `Array.isArray(workspaces)`, causing it to
miss monorepos using this format. The fix mirrors YarnTool's existing
approach: accept both `string[]` and `{ packages: string[] }`.

Affected methods:
- `isMonorepoRoot` / `isMonorepoRootSync` — now recognize object form
- `getPackages` / `getPackagesSync` — extract globs from either form
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 23, 2026

🦋 Changeset detected

Latest commit: 45b60ac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@manypkg/tools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR


interface BunPackageJSON extends PackageJSON {
workspaces?: string[];
workspaces?: string[] | { packages: string[] };
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice to declare the catalog's type here - even if we don't need it now.

@Andarist
Copy link
Copy Markdown
Collaborator

Please add a changeset file documenting the change.

MatthieuMordrel and others added 2 commits February 23, 2026 14:37
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MatthieuMordrel
Copy link
Copy Markdown
Contributor Author

Done, added the catalog type to BunPackageJSON and included the changeset. Thanks for the review!

@Andarist Andarist merged commit 8c4e03b into Thinkmill:main Feb 23, 2026
6 checks passed
@github-actions github-actions bot mentioned this pull request Feb 23, 2026
@MatthieuMordrel MatthieuMordrel deleted the fix/bun-object-form-workspaces branch March 5, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants