Skip to content

chore: Use Bun for package management #1649

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

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 9 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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Mark lock files as generated to avoid diffing
pnpm-lock.yaml linguist-generated
package-lock.json linguist-generated
bun.lock linguist-generated
bun.lockb linguist-generated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bun.lockb linguist-generated

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still a test fixture containing a binary lockfile, I'll try and remove this one when I update E2E tests to use bun.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still a test fixture containing a binary lockfile, I'll try and remove this one when I update E2E tests to use bun.

Okay

yarn.lock linguist-generated

Expand Down
18 changes: 7 additions & 11 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
name: Basic Setup
description: Install PNPM, Node, and dependencies
description: Install Bun and Dependencies

inputs:
install:
default: 'true'
type: boolean
description: Whether or not to run 'pnpm install'
description: Whether or not to run 'bun i'

installArgs:
default: ''
type: string
description: Additional args to append to "pnpm install"
description: Additional args to append to "bun i"

runs:
using: composite

steps:
- name: 🛠️ Setup PNPM
uses: pnpm/action-setup@v4

- name: 🛠️ Setup NodeJS
uses: actions/setup-node@v4
- name: 🛠️ Setup Bun
uses: oven-sh/setup-bun@v2
with:
node-version: 18
cache: pnpm
bun-version-file: package.json

- name: 📦 Install Dependencies
if: ${{ inputs.install == 'true' }}
shell: bash
run: pnpm install ${{ inputs.installArgs }}
run: bun i ${{ inputs.installArgs }}
4 changes: 2 additions & 2 deletions .github/workflows/pkg.pr.new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: ./.github/actions/setup

- name: Build All Packages
run: pnpm buildc all
run: bun buildc all

- name: Publish
run: pnpx pkg-pr-new publish --compact --pnpm './packages/*'
run: bunx pkg-pr-new publish --compact './packages/*'
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Build docs
run: |
pnpm docs:build
bun docs:build
docker build docs/.vitepress -t ${{ secrets.DOCKER_REGISTRY_HOSTNAME }}/wxt/docs:${{ github.event.inputs.tag || 'latest' }}

- name: Push Image
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ jobs:

- name: Bump and Tag
run: |
pnpm tsx scripts/bump-package-version.ts ${{ inputs.package }}
bun scripts/bump-package-version.ts ${{ inputs.package }}
git push
git push --tags

- name: Publish to NPM
working-directory: packages/${{ inputs.package }}
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc
pnpm build
pnpm publish
bun run build
bun publish
Comment on lines +63 to +64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend using npm instead in this case, because Bun does not yet support the --provenance flag for signing releases (see oven-sh/bun#15601)

Suggested change
bun run build
bun publish
bunx npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}"
bunx npm publish --provenance --access public

Copy link
Collaborator Author

@aklinker1 aklinker1 May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WXT doesn't have provenance right now, so I'll do this in a separate PR.

#1654

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WXT doesn't have provenance right now, so I'll do this in a separate PR.

#1654

Ok


- name: Create GitHub release
run: pnpm tsx scripts/create-github-release.ts ${{ inputs.package }}
run: bun scripts/create-github-release.ts ${{ inputs.package }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/sync-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ jobs:
installArgs: --ignore-scripts

- name: Sync Releases
run: pnpm tsx scripts/sync-releases.ts ${{ inputs.package }}
run: bun scripts/sync-releases.ts ${{ inputs.package }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/update-browser-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:

- name: Generate Latest Code
working-directory: packages/browser
run: pnpm gen
run: bun gen

- name: Run Checks
working-directory: packages/browser
run: pnpm check
run: bun check

- name: Commit Changes
id: commit
Expand All @@ -43,4 +43,4 @@ jobs:
working-directory: packages/browser
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc
pnpm publish
bun publish
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bun publish
bunx npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}"
bunx npm publish --provenance --access public

20 changes: 10 additions & 10 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: ./.github/actions/setup

- name: Basic Checks
run: pnpm check
run: bun check

builds:
name: Builds
Expand All @@ -34,7 +34,7 @@ jobs:
uses: ./.github/actions/setup

- name: Build All Packages
run: pnpm buildc all
run: bun buildc all

build-demo:
name: Build Demo
Expand All @@ -47,11 +47,11 @@ jobs:
uses: ./.github/actions/setup

- name: Build
run: pnpm build:all
run: bun build:all
working-directory: packages/wxt-demo

- name: ZIP
run: pnpm wxt zip
run: bun wxt zip
working-directory: packages/wxt-demo

tests:
Expand All @@ -68,7 +68,7 @@ jobs:
uses: oven-sh/setup-bun@v2

- name: Run Tests
run: pnpm test:coverage -- --reporter=default --reporter=hanging-process
run: bun test:coverage -- --reporter=default --reporter=hanging-process

- name: Upload Coverage
uses: codecov/codecov-action@v5
Expand All @@ -86,7 +86,7 @@ jobs:
uses: ./.github/actions/setup

- name: Run Tests
run: pnpm test
run: bun run test

template:
name: Template
Expand All @@ -108,7 +108,7 @@ jobs:
uses: ./.github/actions/setup

- name: Pack WXT package
run: pnpm pack
run: bun pm pack
working-directory: packages/wxt

- name: Install Dependencies
Expand All @@ -120,15 +120,15 @@ jobs:
working-directory: templates/${{ matrix.template }}

- name: Type Check Template
run: pnpm compile
run: bun compile
if: matrix.template != 'svelte'
working-directory: templates/${{ matrix.template }}

- name: Type Check Template
run: pnpm check
run: bun check
if: matrix.template == 'svelte'
working-directory: templates/${{ matrix.template }}

- name: Build Template
run: pnpm build
run: bun run build
working-directory: templates/${{ matrix.template }}
6 changes: 3 additions & 3 deletions .github/workflows/vhs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
with:
install: false

# This prevents pnpm dlx from downloading WXT in the video
# This prevents bunx from downloading WXT in the video
- name: Pre-install WXT
run: |
pnpm store add wxt@latest
pnpm dlx wxt@latest --version
bun i wxt@latest
bunx wxt@latest --version

- name: Record VHS
uses: charmbracelet/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ dist
.wxt
docs/.vitepress/cache
pnpm-lock.yaml
bun.lock
CHANGELOG.md
packages/browser/src/gen
24 changes: 12 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The title of your pull request should follow the [conventional commit format](#c

## Setup

WXT uses `pnpm`, so make sure you have it installed.
WXT uses `bun`, so make sure you have it installed.

```sh
corepack enable
Expand All @@ -31,7 +31,7 @@ corepack enable
Then, simply run the install command:

```sh
pnpm i
bun i
```

## Development
Expand All @@ -41,44 +41,44 @@ Here are some helpful commands:
```sh
# Build WXT package
cd packages/wxt
pnpm build
bun run build
```

```sh
# Build WXT package, then build demo extension
cd packages/wxt-demo
pnpm build
bun run build
```

```sh
# Build WXT package, then start the demo extension in dev mode
cd packages/wxt-demo
pnpm dev
bun dev
```

```sh
# Run unit and E2E tests
pnpm test
bun run test
```

```sh
# Start the docs website locally
pnpm docs:dev
bun docs:dev
```

## Profiling

```sh
# Build the latest version
pnpm --filter wxt build
bun run --filter wxt build

# CD to the demo directory
cd packages/wxt-demo

# 1. Generate a flamechart with 0x
pnpm dlx 0x node_modules/wxt/bin/wxt.mjs build
bunx 0x node_modules/wxt/bin/wxt.mjs build
# 2. Inspect the process with chrome @ chrome://inspect
pnpm node --inspect node_modules/wxt/bin/wxt.mjs build
node --inspect node_modules/wxt/bin/wxt.mjs build
```

## Updating Docs
Expand All @@ -96,7 +96,7 @@ WXT has unit and E2E tests. When making a change or adding a feature, make sure
To run tests for a specific file, add the filename at the end of the test command:

```sh
pnpm test manifest-contents
bun run test manifest-contents
```

All test (unit and E2E) for all packages are ran together via [Vitest workspaces](https://vitest.dev/guide/#workspaces-support).
Expand Down Expand Up @@ -149,7 +149,7 @@ Releases are done with GitHub actions:
Use [`taze`](https://www.npmjs.com/package/taze) to upgrade dependencies throughout the entire monorepo.

```sh
pnpm dlx taze -r
bunx taze@latest -r
```

Configuration is in [`taze.config.ts`](./taze.config.ts).
Expand Down
Loading
Loading