diff options
author | 2023-04-13 18:26:45 -0700 | |
---|---|---|
committer | 2023-04-13 18:26:45 -0700 | |
commit | 011e157cac7698050370e24495a9002dacfceea9 (patch) | |
tree | ebb561dbda3e8f67302cc4d5b398f4a2744f7884 /docs/install/workspaces.md | |
parent | 0cc56e8efce9c7d4905b3649827bf9b40a677b25 (diff) | |
download | bun-011e157cac7698050370e24495a9002dacfceea9.tar.gz bun-011e157cac7698050370e24495a9002dacfceea9.tar.zst bun-011e157cac7698050370e24495a9002dacfceea9.zip |
Docs restructuring (#2638)
* Restructure
* Update nav
* Reorg
* Reshuffle ecosystem pages
* Split up runtime/runtime
* Back to runtime/index
* Fix issue
* Split up runtime/index
* Add Writing Tests page
* Prettier matcher table
* More updates
Diffstat (limited to 'docs/install/workspaces.md')
-rw-r--r-- | docs/install/workspaces.md | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/docs/install/workspaces.md b/docs/install/workspaces.md new file mode 100644 index 000000000..cf5a20e19 --- /dev/null +++ b/docs/install/workspaces.md @@ -0,0 +1,30 @@ +Bun supports [`workspaces`](https://docs.npmjs.com/cli/v9/using-npm/workspaces?v=true#description) in `package.json`. Workspaces make it easy to develop complex software as a _monorepo_ consisting of several independent packages. + +To try it, specify a list of sub-packages in the `workspaces` field of your `package.json`; it's conventional to place these sub-packages in a directory called `packages`. + +```json +{ + "name": "my-project", + "version": "1.0.0", + "workspaces": ["packages/*"] +} +``` + +{% callout %} +**Glob support** — Bun v0.5.8 added support for simple `<directory>/*` globs in `"workspaces"`. Full glob syntax (e.g. `**` and `?`) is not yet supported (soon!). +{% /callout %} + +This has 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. + +{% callout %} +⚡️ **Speed** — Installs are fast, even for big monorepos. Bun installs the [Remix](https://github.com/remix-run/remix) monorepo in about `500ms` on Linux. + +- 28x faster than `npm install` +- 12x faster than `yarn install` (v1) +- 8x faster than `pnpm install` + +{% image src="https://user-images.githubusercontent.com/709451/212829600-77df9544-7c9f-4d8d-a984-b2cd0fd2aa52.png" /%} +{% /callout %} |