fix(tools): support object-form workspaces in BunTool#266
Merged
Andarist merged 4 commits intoThinkmill:mainfrom Feb 23, 2026
Merged
fix(tools): support object-form workspaces in BunTool#266Andarist merged 4 commits intoThinkmill:mainfrom
Andarist merged 4 commits intoThinkmill:mainfrom
Conversation
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 detectedLatest commit: 45b60ac The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Andarist
reviewed
Feb 23, 2026
packages/tools/src/BunTool.ts
Outdated
|
|
||
| interface BunPackageJSON extends PackageJSON { | ||
| workspaces?: string[]; | ||
| workspaces?: string[] | { packages: string[] }; |
Collaborator
There was a problem hiding this comment.
it would be nice to declare the catalog's type here - even if we don't need it now.
Andarist
approved these changes
Feb 23, 2026
Collaborator
|
Please add a changeset file documenting the change. |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
Done, added the catalog type to BunPackageJSON and included the changeset. Thanks for the review! |
Andarist
reviewed
Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bun supports an object-form
workspacesfield inpackage.jsonfor features like workspace catalogs:BunToolonly checkedArray.isArray(pkgJson.workspaces), so it missed monorepos using this object form. This causedfindRootto fall through toRootTool, treating the project as a single-package repo and skipping all workspace packages.The fix mirrors
YarnTool's existing approach — it already handles bothstring[]and{ packages: string[] }.Changes
BunTool.isMonorepoRoot/isMonorepoRootSync— now recognizeworkspaces.packagesin addition to the array formBunTool.getPackages/getPackagesSync— extract globs from eitherworkspaces(array) orworkspaces.packages(object)BunPackageJSONtype — updated tostring[] | { packages: string[] }Test plan
basic-bun-object-workspacesfixture forfindRoottestsbun-object-workspace-basefixture forgetPackagestests