diff options
author | 2023-09-14 18:04:26 -0400 | |
---|---|---|
committer | 2023-09-14 15:04:26 -0700 | |
commit | f3fe4508aeef8fc6258da0284d07f7a311caaa19 (patch) | |
tree | cd6e4522b411f07954f899bd700fa405fd475aaf /docs/install | |
parent | 96a1d5382fa6d91af1a315a6dc2dee449e66d846 (diff) | |
download | bun-f3fe4508aeef8fc6258da0284d07f7a311caaa19.tar.gz bun-f3fe4508aeef8fc6258da0284d07f7a311caaa19.tar.zst bun-f3fe4508aeef8fc6258da0284d07f7a311caaa19.zip |
docs - Add "workspace:*" to workspace docs. (#5379)
* add workspace:* to docs
* Updates
---------
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
Diffstat (limited to 'docs/install')
-rw-r--r-- | docs/install/workspaces.md | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/docs/install/workspaces.md b/docs/install/workspaces.md index f2a45048a..608efb537 100644 --- a/docs/install/workspaces.md +++ b/docs/install/workspaces.md @@ -6,7 +6,10 @@ To try it, specify a list of sub-packages in the `workspaces` field of your `pac { "name": "my-project", "version": "1.0.0", - "workspaces": ["packages/*"] + "workspaces": ["packages/*"], + "devDependencies": { + "example-package-in-monorepo": "workspace:*" + } } ``` @@ -14,7 +17,23 @@ To try it, specify a list of sub-packages in the `workspaces` field of your `pac **Glob support** — Bun supports simple `<directory>/*` globs in `"workspaces"`. Full glob syntax (e.g. `**` and `?`) is not yet supported. {% /callout %} -This has a couple major benefits. +When referencing other packages in the monorepo, use `"workspace:*"` as the version field in your `package.json`. + +```json +{ + "name": "pkg-a", + "version": "1.0.0", + "dependencies": { + "pkg-b": "workspace:*" + } +} +``` + +{% callout %} +**Version support** — Bun supports simple `workspace:*` versions in `"dependencies"`. Full version syntax (e.g. `workspace:^*`) is not yet supported. +{% /callout %} + +Workspaces have a couple major benefits. - **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. - **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. |