Skip to content

Commit 0f50264

Browse files
dylangcolinhacks
authored andcommitted
docs - Add "workspace:*" to workspace docs. (oven-sh#5379)
* add workspace:* to docs * Updates --------- Co-authored-by: Colin McDonnell <[email protected]>
1 parent 6eb7736 commit 0f50264

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

docs/install/workspaces.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,34 @@ To try it, specify a list of sub-packages in the `workspaces` field of your `pac
66
{
77
"name": "my-project",
88
"version": "1.0.0",
9-
"workspaces": ["packages/*"]
9+
"workspaces": ["packages/*"],
10+
"devDependencies": {
11+
"example-package-in-monorepo": "workspace:*"
12+
}
1013
}
1114
```
1215

1316
{% callout %}
1417
**Glob support** — Bun supports simple `<directory>/*` globs in `"workspaces"`. Full glob syntax (e.g. `**` and `?`) is not yet supported.
1518
{% /callout %}
1619

17-
This has a couple major benefits.
20+
When referencing other packages in the monorepo, use `"workspace:*"` as the version field in your `package.json`.
21+
22+
```json
23+
{
24+
"name": "pkg-a",
25+
"version": "1.0.0",
26+
"dependencies": {
27+
"pkg-b": "workspace:*"
28+
}
29+
}
30+
```
31+
32+
{% callout %}
33+
**Version support** — Bun supports simple `workspace:*` versions in `"dependencies"`. Full version syntax (e.g. `workspace:^*`) is not yet supported.
34+
{% /callout %}
35+
36+
Workspaces have a couple major benefits.
1837

1938
- **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 package `b` depends on `a`, `bun install` will symlink your local `packages/a` directory into the `node_modules` folder of `b`, instead of trying to download it from the npm registry.
2039
- **Dependencies can be de-duplicated.** If `a` and `b` share a common dependency, it will be _hoisted_ to the root `node_modules` directory. This reduces redundant disk usage and minimizes "dependency hell" issues associated with having multiple versions of a package installed simultaneously.

0 commit comments

Comments
 (0)