Skip to content

docs: add Bun to package manager tabs #10321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/site/components/tabs.tsx
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ export function Tabs({
);
}

const packageManagers = ["pnpm", "yarn", "npm"];
const packageManagers = ["pnpm", "yarn", "npm", "bun (Beta)"];

const checkPackageManagerIndex = (index: number, provided: string) => {
if (provided !== packageManagers[index]) {
@@ -43,11 +43,11 @@ export function PackageManagerTabs({
throw new Error("Children must be an array.");
}

children.forEach((packageManager, index) => {
if (!packageManager.props.value) {
throw new Error(`Package manager tab is missing a value.`);
}
if (packageManagers.length > children.length) {
throw new Error(`Package manager tab is missing a value.`);
}

children.forEach((packageManager, index) => {
checkPackageManagerIndex(index, packageManager.props.value);
});

10 changes: 10 additions & 0 deletions docs/site/content/docs/core-concepts/internal-packages.mdx
Original file line number Diff line number Diff line change
@@ -40,6 +40,16 @@ Internal Packages are used in your repository by installing them in `package.jso
}
```
</Tab>

<Tab value="bun (Beta)">
```json title="./apps/web/package.json"
{
"dependencies": {
"@repo/ui": "workspace:*" // [!code highlight]
}
}
```
</Tab>
</PackageManagerTabs>

In the [Creating an Internal Package guide](/docs/crafting-your-repository/creating-an-internal-package), you can build an Internal Package from the beginning using [the Compiled Package strategy](#compiled-packages). On this page, we'll describe other strategies for creating Internal Packages and their tradeoffs, including [publishing the package to the npm registry](#publishable-packages) to create an External Package.
8 changes: 8 additions & 0 deletions docs/site/content/docs/core-concepts/remote-caching.mdx
Original file line number Diff line number Diff line change
@@ -112,6 +112,14 @@ yarn dlx turbo login
npx turbo login
```

</Tab>

<Tab value="bun (Beta)">

```bash title="Terminal"
bunx turbo login
```

</Tab>
</PackageManagerTabs>

8 changes: 8 additions & 0 deletions docs/site/content/docs/crafting-your-repository/caching.mdx
Original file line number Diff line number Diff line change
@@ -70,6 +70,14 @@ yarn build
npm run build
```

</Tab>

<Tab value="bun (Beta)">

```bash title="Terminal"
bun run build
```

</Tab>
</PackageManagerTabs>

Original file line number Diff line number Diff line change
@@ -124,7 +124,35 @@ Next, create the `package.json` for the package. By adding this file, you'll ful
"typescript": "latest"
}
}
````
```

</Tab>

<Tab value="bun (Beta)">
```json title="./packages/math/package.json"
{
"name": "@repo/math",
"type": "module",
"scripts": {
"dev": "tsc --watch",
"build": "tsc"
},
"exports": {
"./add": {
"types": "./src/add.ts",
"default": "./dist/add.js"
},
"./subtract": {
"types": "./src/subtract.ts",
"default": "./dist/subtract.js"
}
},
"devDependencies": {
"@repo/typescript-config": "workspace:*",
"typescript": "latest"
}
}
```

</Tab>
</PackageManagerTabs>
@@ -237,6 +265,17 @@ You're ready to use your new package in an application. Let's add it to the `web
},
```
</Tab>

<Tab value="bun (Beta)">
```diff title="apps/web/package.json"
"dependencies": {
+ "@repo/math": "workspace:*",
"next": "latest",
"react": "latest",
"react-dom": "latest"
},
```
</Tab>
</PackageManagerTabs>

<Callout type="warn">
Original file line number Diff line number Diff line change
@@ -44,6 +44,17 @@ import { LinkToDocumentation } from '#/components/link-to-documentation';
}
```
</Tab>

<Tab value="bun (Beta)">
```json title="./apps/web/package.json"
{
"dependencies": {
"next": "latest", // External dependency
"@repo/ui": "workspace:*" // Internal dependency
}
}
```
</Tab>
</PackageManagerTabs>

## Best practices for dependency installation
@@ -101,6 +112,15 @@ npm install jest --workspace=web --workspace=@repo/ui --save-dev

<LinkToDocumentation href="https://docs.npmjs.com/cli/v7/using-npm/config#workspace">npm documentation</LinkToDocumentation>
</Tab>

<Tab value="bun (Beta)">

```bash title="Terminal"
bun install jest --filter=web --filter=@repo/ui --dev
```

<LinkToDocumentation href="https://bun.sh/docs/install/workspaces">bun documentation</LinkToDocumentation>
</Tab>
</PackageManagerTabs>

This practice has several benefits:
@@ -190,6 +210,13 @@ npm install typescript@latest --workspaces
```
<small>[→ npm documentation](https://docs.npmjs.com/cli/v7/using-npm/config#workspaces)</small>

</Tab>

<Tab value="bun (Beta)">
No equivalent

<small>[→ Bun documentation](https://bun.sh/docs/install/workspaces)</small>

</Tab>
</PackageManagerTabs>

Original file line number Diff line number Diff line change
@@ -60,6 +60,14 @@ yarn dev

```bash title="Terminal"
npm run dev
```

</Tab>

<Tab value="bun (Beta)">

```bash title="Terminal"
bun run dev
```

</Tab>
Original file line number Diff line number Diff line change
@@ -45,6 +45,13 @@ npx create-turbo@latest

</Tab>

<Tab value="bun (Beta)">
```bash title="Terminal"
bunx create-turbo@latest
```

</Tab>

</PackageManagerTabs>

You can then review the repository for the characteristics described in this guide.
@@ -61,6 +68,7 @@ Below, the structural elements of `create-turbo` that make it a valid workspace
<Files>
<File name="package.json" green />
<File name="pnpm-lock.yaml" green />
<File name="pnpm-workspace.yaml" green />
<File name="turbo.json" />
<Folder name="apps" defaultOpen>
<Folder name="docs" className="text-foreground" defaultOpen>
@@ -120,6 +128,27 @@ Below, the structural elements of `create-turbo` that make it a valid workspace
</Files>
</Tab>

<Tab value="bun (Beta)">
<Files>
<File name="package.json" green />
<File name="bun.lock" green />
<File name="turbo.json" />
<Folder name="apps" defaultOpen>
<Folder name="docs" className="text-foreground" defaultOpen>
<File name="package.json" green />
</Folder>
<Folder name="web">
<File name="package.json" green />
</Folder>
</Folder>
<Folder name="packages">
<Folder name="ui">
<File name="package.json" green />
</Folder>
</Folder>
</Files>
</Tab>

</PackageManagerTabs>

### Minimum requirements
@@ -176,6 +205,20 @@ First, your package manager needs to describe the locations of your packages. We

<LinkToDocumentation href="https://docs.npmjs.com/cli/v7/using-npm/workspaces#defining-workspaces">npm workspace documentation</LinkToDocumentation>
</Tab>

<Tab value="bun (Beta)">
```json title="./package.json"
{
"workspaces": [
"apps/*",
"packages/*"
]
}
```

<LinkToDocumentation href="https://bun.sh/docs/install/workspaces">npm workspace documentation</LinkToDocumentation>
</Tab>

</PackageManagerTabs>

Using this configuration, every directory **with a `package.json`** in the `apps` or `packages` directories will be considered a package.
@@ -258,6 +301,25 @@ The root `package.json` is the base for your workspace. Below is a common exampl
}
```

</Tab>

<Tab value="bun (Beta)">

```json title="./package.json"
{
"private": true,
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev",
"lint": "turbo run lint"
},
"devDependencies": {
"turbo": "latest"
},
"packageManager": "[email protected]"
}
```

</Tab>
</PackageManagerTabs>

18 changes: 18 additions & 0 deletions docs/site/content/docs/crafting-your-repository/upgrading.mdx
Original file line number Diff line number Diff line change
@@ -42,6 +42,14 @@ npx @turbo/codemod migrate

</Tab>

<Tab value="bun (Beta)">

```bash title="Terminal"
bunx @turbo/codemod migrate
```

</Tab>

</PackageManagerTabs>

This will update your `turbo.json`(s) for many of the breaking changes from 1.x to 2.0.
@@ -93,6 +101,16 @@ Turborepo 2.0 requires that your Workspace define this field as a way to improve
}
```

</Tab>

<Tab value="bun (Beta)">

```diff title="./package.json"
{
+ "packageManager": "[email protected]"
}
```

</Tab>
</PackageManagerTabs>

12 changes: 12 additions & 0 deletions docs/site/content/docs/getting-started/examples.mdx
Original file line number Diff line number Diff line change
@@ -47,6 +47,18 @@ npx create-turbo@latest --example [github-url]

</Tab>

<Tab value="bun (Beta)">

```bash title="Terminal"
# Use an example listed below
bunx create-turbo@latest --example [example-name]

# Use a GitHub repository from the community
bunx create-turbo@latest --example [github-url]
```

</Tab>

</PackageManagerTabs>

## Core-maintained examples
21 changes: 21 additions & 0 deletions docs/site/content/docs/getting-started/installation.mdx
Original file line number Diff line number Diff line change
@@ -31,6 +31,13 @@ npx create-turbo@latest

</Tab>

<Tab value="bun (Beta)">
```bash title="Terminal"
bunx create-turbo@latest
```

</Tab>

</PackageManagerTabs>

The starter repository will have:
@@ -71,6 +78,13 @@ A global install of `turbo` brings flexibility and speed to your local workflows

</Tab>

<Tab value="bun (Beta)">
```bash title="Terminal"
bun install turbo --global
```

</Tab>

</PackageManagerTabs>

Once installed globally, you can run your scripts through `turbo` from your terminal, quickly running one-off commands to use within your repository. For example:
@@ -123,6 +137,13 @@ When collaborating with other developers in a repository, it's a good idea to pi

</Tab>

<Tab value="bun (Beta)">
```bash title="Terminal"
bun install turbo --dev
```

</Tab>

</PackageManagerTabs>

You can continue to use your global installation of `turbo` to run commands. Global `turbo` will defer to the local version of your repository if it exists.
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ lockfile formats.
| pnpm 8+ | Yes |
| npm 8+ | Yes |
| yarn 1+ | Yes (Includes Yarn Plug'n'Play) |
| bun 1+ | Beta |
| bun 1.2+ | Beta |

<Callout type="info">
Package managers have their own release schedules, bugs, and features. While
Loading