chore: Migrate monorepo to use Bun instead of PNPM (#2009)

Co-authored-by: Okinea Dev <hi@okinea.dev>
This commit is contained in:
Aaron
2026-04-12 22:17:20 -05:00
committed by GitHub
parent a008426317
commit 4d5eb28cb4
67 changed files with 3519 additions and 10653 deletions
+1
View File
@@ -7,6 +7,7 @@
pnpm-lock.yaml linguist-generated
package-lock.json linguist-generated
bun.lockb linguist-generated
bun.lock linguist-generated
yarn.lock linguist-generated
# Exclude templates from language statistics
+6 -14
View File
@@ -1,29 +1,21 @@
name: Basic Setup
description: Install PNPM, Node, and dependencies
description: Install Bun and dependencies
inputs:
install:
default: 'true'
description: Whether or not to run 'pnpm install'
installArgs:
default: ''
description: Additional args to append to "pnpm install"
description: Whether or not to run 'bun install'
runs:
using: composite
steps:
- name: 🛠️ Setup PNPM
uses: pnpm/action-setup@f2b2b233b538f500472c7274c7012f57857d8ce0 # v4.1.0
- name: 🛠️ Setup NodeJS
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
- name: 🛠️ Setup Bun
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
with:
node-version: 20
cache: pnpm
bun-version-file: '.tool-versions'
- name: 📦 Install Dependencies
if: ${{ inputs.install == 'true' }}
shell: bash
run: pnpm install ${{ inputs.installArgs }}
run: bun ci ${{ inputs.installArgs }}
+7 -2
View File
@@ -23,7 +23,12 @@ jobs:
uses: ./.github/actions/setup
- name: Build All Packages
run: pnpm buildc all
run: bun run buildc all
- name: Publish
run: pnpx pkg-pr-new publish --compact --pnpm './packages/*'
run: bun pkg-pr-new publish --compact --bun './packages/*'
- name: DEBUG
if: always()
run: ls -lhA
working-directory: packages/analytics
+1 -1
View File
@@ -37,7 +37,7 @@ jobs:
- name: Build docs
run: |
pnpm docs:build
bun run docs:build
docker build docs/.vitepress -t ${{ secrets.DOCKER_REGISTRY_HOSTNAME }}/wxt/docs:${{ github.event.inputs.tag || 'latest' }}
- name: Push Image
+4 -4
View File
@@ -56,18 +56,18 @@ jobs:
- name: Bump and Tag
run: |
pnpm tsx scripts/bump-package-version.ts ${{ inputs.package }}
bun run scripts/bump-package-version.ts ${{ inputs.package }}
git push
git push --tags
- name: Publish to NPM
working-directory: packages/${{ inputs.package }}
run: |
pnpm pack
bun pm pack
sudo npm i -g npm@latest
/usr/local/bin/npm publish *.tgz
npm publish *.tgz
- name: Create GitHub release
run: pnpm tsx scripts/create-github-release.ts ${{ inputs.package }}
run: bun run scripts/create-github-release.ts ${{ inputs.package }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+1 -1
View File
@@ -39,6 +39,6 @@ jobs:
installArgs: --ignore-scripts
- name: Sync Releases
run: pnpm tsx scripts/sync-releases.ts ${{ inputs.package }}
run: bun run scripts/sync-releases.ts ${{ inputs.package }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+4 -4
View File
@@ -28,11 +28,11 @@ jobs:
- name: Generate Latest Code
working-directory: packages/browser
run: pnpm gen
run: bun run gen
- name: Run Checks
working-directory: packages/browser
run: pnpm check
run: bun run check
- name: Commit Changes
id: commit
@@ -46,6 +46,6 @@ jobs:
if: steps.commit.outputs.changes_detected == 'true'
working-directory: packages/browser
run: |
pnpm pack
bun pm pack
sudo npm i -g npm@latest
/usr/local/bin/npm publish *.tgz
npm publish *.tgz
+14 -12
View File
@@ -21,7 +21,7 @@ jobs:
uses: ./.github/actions/setup
- name: Basic Checks
run: pnpm check
run: bun run check
builds:
name: Builds
@@ -34,7 +34,7 @@ jobs:
uses: ./.github/actions/setup
- name: Build All Packages
run: pnpm buildc all
run: bun run buildc all
build-demo:
name: Build Demo
@@ -47,11 +47,11 @@ jobs:
uses: ./.github/actions/setup
- name: Build
run: pnpm build:all
run: bun run build:all
working-directory: packages/wxt-demo
- name: ZIP
run: pnpm wxt zip
run: bun run wxt zip
working-directory: packages/wxt-demo
tests:
@@ -73,16 +73,18 @@ jobs:
- name: Setup
uses: ./.github/actions/setup
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
- name: Setup PNPM
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
with:
version: latest
- name: Run Tests
if: ${{ ! matrix.coverage }}
run: pnpm test
run: bun run test
- name: Run Tests (Coverage)
if: matrix.coverage
run: pnpm test:coverage --reporter=default --reporter=hanging-process
run: bun run test:coverage --reporter=default --reporter=hanging-process
- name: Upload Coverage
if: matrix.coverage
@@ -110,7 +112,7 @@ jobs:
uses: ./.github/actions/setup
- name: Pack WXT package
run: pnpm pack
run: bun pm pack
working-directory: packages/wxt
- name: Install Dependencies
@@ -122,15 +124,15 @@ jobs:
working-directory: templates/${{ matrix.template }}
- name: Type Check Template
run: pnpm compile
run: bun run compile
if: matrix.template != 'svelte'
working-directory: templates/${{ matrix.template }}
- name: Type Check Template
run: pnpm check
run: bun run 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 }}
+5 -3
View File
@@ -20,11 +20,13 @@ jobs:
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.ref_name }}
- name: Setup PNPM
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
- name: Setup
uses: ./.github/actions/setup
- name: Setup NodeJS
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
install: false
cache: pnpm
- name: Setup Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c
+1 -1
View File
@@ -7,6 +7,7 @@
.wxt
.wxt-runner
*.log
*.tgz
/docs/.vitepress/cache
docs/.vitepress/.temp
coverage
@@ -20,6 +21,5 @@ templates/*/yarn.lock
templates/*/package-lock.json
docs/api/reference
stats.html
.tool-versions
.cache
*-stats.txt
+1
View File
@@ -0,0 +1 @@
bun 1.3.12
+56 -33
View File
@@ -48,16 +48,12 @@ To make a breaking change:
## Setup
WXT uses `pnpm`, so make sure you have it installed.
WXT uses Bun for package management and development. Install it from: <https://bun.com/>
Then install dependencies:
```sh
corepack enable
```
Then, simply run the install command:
```sh
pnpm i
bun install
```
## Development
@@ -65,48 +61,68 @@ pnpm i
Here are some helpful commands:
```sh
# Build WXT package
cd packages/wxt
pnpm build
# Build WXT package and workspace dependencies
bun run --filter wxt build
```
```sh
# Build WXT package, then build demo extension
cd packages/wxt-demo
pnpm build
```
```sh
# Build WXT package, then start the demo extension in dev mode
cd packages/wxt-demo
pnpm dev
# Build workspace dependencies, then start the demo extension in dev mode
bun run --filter wxt-demo dev
```
```sh
# Run unit and E2E tests
pnpm test
bun run test
```
```sh
# Start the docs website locally
pnpm docs:dev
bun run docs:dev
```
> Above, we used bun's `--filter` flag to choose which package to run a command in, but there are other ways:
>
> ```sh
> bun run -F @wxt-dev/i18n build
> # or
> bun run --cwd packages/i18n build
> # or
> cd packages/i18n
> bun run build
> ```
>
> Pick your poison!
## 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 flame graph with 0x
pnpm dlx 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
```
Then there are a few different ways to profile WXT commands:
- Generate a flamechart with 0x:
```sh
bunx 0x node_modules/wxt/bin/wxt.mjs build
```
- Create a CPU profile:
```sh
bun run --cpu-prof node_modules/wxt/bin/wxt.mjs build
```
- Debug the process:
```sh
bun run --inspect node_modules/wxt/bin/wxt.mjs build
```
## Updating Docs
Documentation is written with VitePress, and is located in the `docs/` directory.
@@ -122,7 +138,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 --filter wxt test manifest-contents
```
All test (unit and E2E) for all packages are ran together via [Vitest workspaces](https://vitest.dev/guide/#workspaces-support).
@@ -131,7 +147,7 @@ If you want to manually test a change, you can modify the demo project for your
## Templates
Each directory inside `templates/` is it's own standalone project. Simply `cd` into the directory you're updating, install dependencies with `npm` (NOT `pnpm`), and run the relevant commands
Each directory inside `templates/` is it's own standalone project. Simply `cd` into the directory you're updating, install dependencies with `npm` (NOT `bun`), and run the relevant commands
```sh
cd templates/vue
@@ -147,7 +163,7 @@ Note that templates are hardcoded to a specific version of `wxt` from NPM, they
"typescript": "^5.3.2",
"vite-plugin-solid": "^2.7.0",
- "wxt": "^0.8.0"
+ "wxt": "../.."
+ "wxt": "../../packages/wxt"
}
```
@@ -163,18 +179,25 @@ cp -r templates/vanilla templates/<new-template-name>
That's it. Once your template is merged, it will be available inside `wxt init` immediately. You don't need to release a new version of WXT to release a new template.
## Releasing Updates
Releases are done with GitHub actions:
- Use the [Release workflow](https://github.com/wxt-dev/wxt/actions/workflows/release.yml) to release a single package in the monorepo. This automatically detects the version change with conventional commits, builds and uploads the package to NPM, and creates a GitHub release.
- Use the [Sync Releases workflow](https://github.com/wxt-dev/wxt/actions/workflows/sync-releases.yml) to sync the GitHub releases with changes to the changelog. To change a release, update the `CHANGELOG.md` file and run the workflow. It will sync the releases of a single package in the monorepo.
## Upgrading Dependencies
WXT has custom rules around what dependencies can be upgraded. Use the `scripts/upgrade-deps.ts` script to upgrade dependencies and follow these rules.
```sh
pnpm tsx scripts/upgrade-deps.ts
bun run scripts/upgrade-deps.ts
```
To see all the options, run:
```sh
pnpm tsx scripts/upgrade-deps.ts --help
bun run scripts/upgrade-deps.ts --help
```
## Install Unreleased Versions
+1 -1
View File
@@ -78,7 +78,7 @@ Example PR: <https://github.com/wxt-dev/wxt/pull/2152>
```sh
cd packages/<dir-name>
pnpm publish --access public
bun publish --access public
```
7. Create a basic release on GitHub mentioning the new package is available.
Generated
+3033
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -44,6 +44,7 @@ words:
- favicons
- fieldtrials
- firefoxdeveloperedition
- flamechart
- Florian
- focusring
- frontmatter
@@ -108,6 +109,7 @@ words:
- unstub
- unwatch
- USSS
- vitepress
- webext
- webextension
- webextrc
+21 -21
View File
@@ -1,5 +1,25 @@
import { Feed } from 'feed';
import footnote from 'markdown-it-footnote';
import fs from 'node:fs/promises';
import { join } from 'node:path';
import { DefaultTheme, defineConfig } from 'vitepress';
import addKnowledge from 'vitepress-knowledge';
import {
groupIconMdPlugin,
groupIconVitePlugin,
localIconLoader,
} from 'vitepress-plugin-group-icons';
import llmstxt from 'vitepress-plugin-llms';
import { version as analyticsVersion } from '../../packages/analytics/package.json';
import { version as autoIconsVersion } from '../../packages/auto-icons/package.json';
import { version as i18nVersion } from '../../packages/i18n/package.json';
import { version as runnerVersion } from '../../packages/runner/package.json';
import { version as storageVersion } from '../../packages/storage/package.json';
import { version as unocssVersion } from '../../packages/unocss/package.json';
import { version as wxtVersion } from '../../packages/wxt/package.json';
import { version as isBackgroundVersion } from '../../packages/is-background/package.json';
import typedocSidebar from '../api/reference/typedoc-sidebar.json';
import { meta, script } from './utils/head';
import {
menuGroup,
menuItem,
@@ -7,26 +27,6 @@ import {
navItem,
prepareTypedocSidebar,
} from './utils/menus';
import { meta, script } from './utils/head';
import footnote from 'markdown-it-footnote';
import { version as wxtVersion } from '../../packages/wxt/package.json';
import { version as i18nVersion } from '../../packages/i18n/package.json';
import { version as autoIconsVersion } from '../../packages/auto-icons/package.json';
import { version as unocssVersion } from '../../packages/unocss/package.json';
import { version as storageVersion } from '../../packages/storage/package.json';
import { version as analyticsVersion } from '../../packages/analytics/package.json';
import { version as runnerVersion } from '../../packages/runner/package.json';
import { version as isBackgroundVersion } from '../../packages/is-background/package.json';
import addKnowledge from 'vitepress-knowledge';
import {
groupIconMdPlugin,
groupIconVitePlugin,
localIconLoader,
} from 'vitepress-plugin-group-icons';
import { Feed } from 'feed';
import { writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import llmstxt from 'vitepress-plugin-llms';
const origin = 'https://wxt.dev';
@@ -113,7 +113,7 @@ export default defineConfig({
});
// console.log('rss.xml:');
// console.log(feed.rss2());
await writeFile(join(site.outDir, 'rss.xml'), feed.rss2(), 'utf8');
await fs.writeFile(join(site.outDir, 'rss.xml'), feed.rss2());
},
head: [
+6 -7
View File
@@ -1,6 +1,6 @@
import { resolve } from 'node:path';
import consola from 'consola';
import spawn from 'nano-spawn';
import { resolve } from 'node:path';
const cliDir = resolve('packages/wxt/src/cli/commands');
const cliDirGlob = resolve(cliDir, '**');
@@ -38,20 +38,19 @@ export default {
async function getHelp(command: string): Promise<string> {
const args = command.split(' ');
const res = await spawn(args[0], [...args.slice(1), '--help'], {
const result = await spawn(args[0], [...args.slice(1), '--help'], {
cwd: 'packages/wxt',
});
return res.stdout;
return result.stdout;
}
function getWxtHelp(command: string): Promise<string> {
return getHelp(`pnpm -s wxt ${command}`.trim());
return getHelp(`bun run --silent wxt ${command}`.trim());
}
async function getPublishExtensionHelp(command: string): Promise<string> {
const res = await getHelp(
`./node_modules/.bin/publish-extension ${command}`.trim(),
);
// console.error('\n\n\n', await fs.readdir('.'));
const res = await getHelp(`publish-extension ${command}`.trim());
return res.replace(/\$ publish-extension/g, '$ wxt submit');
}
+2 -2
View File
@@ -163,8 +163,8 @@ yarn zip:firefox
```
```sh [bun]
bun i
bun zip:firefox
bun install
bun run zip:firefox
```
:::
+1 -1
View File
@@ -76,7 +76,7 @@ Once you've run the `dev` command, continue to [Next Steps](#next-steps)!
```
```sh [Bun]
bun i -D wxt
bun add -D wxt
```
```sh [NPM]
+6
View File
@@ -0,0 +1,6 @@
[build]
command = "bun run docs:build"
publish = "docs/.vitepress/dist"
[build.environment]
BUN_VERSION = "1.3.5"
+19 -7
View File
@@ -1,22 +1,28 @@
{
"private": true,
"type": "module",
"packageManager": "pnpm@10.29.2+sha512.bef43fa759d91fd2da4b319a5a0d13ef7a45bb985a3d7342058470f9d2051a3ba8674e629672654686ef9443ad13a82da2beb9eeb3e0221c87b8154fff9d74b8",
"engines": {
"bun": ">=1.3.5"
},
"workspaces": [
"packages/*"
],
"scripts": {
"check": "check && pnpm -r --sequential run check",
"test": "pnpm -r --sequential run test run",
"test:coverage": "pnpm -r --sequential run test:coverage",
"check": "check && bun run --workspaces check",
"test": "bun run --workspaces test run",
"test:coverage": "bun run --workspaces test:coverage",
"prepare": "simple-git-hooks",
"docs:gen": "typedoc --options docs/typedoc.json",
"docs:dev": "pnpm -s docs:gen && vitepress dev docs",
"docs:build": "pnpm -s docs:gen && vitepress build docs",
"docs:preview": "pnpm -s docs:gen && vitepress preview docs"
"docs:dev": "bun run --silent docs:gen && bun run vitepress dev docs",
"docs:build": "bun run --silent docs:gen && bun run vitepress build docs",
"docs:preview": "bun run --silent docs:gen && bun run vitepress preview docs"
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"@aklinker1/check": "^2.4.0",
"@commitlint/config-conventional": "^20.4.3",
"@commitlint/types": "^20.4.3",
"@types/bun": "^1.3.5",
"@types/semver": "^7.7.1",
"@vitest/coverage-v8": "^4.0.18",
"changelogen": "^0.6.2",
@@ -28,6 +34,7 @@
"nano-spawn": "^2.0.0",
"nano-staged": "^0.8.0",
"p-map": "^7.0.4",
"pkg-pr-new": "^0.0.66",
"prettier": "^3.8.1",
"prettier-plugin-jsdoc": "^1.8.0",
"semver": "^7.7.4",
@@ -48,6 +55,11 @@
"vue": "^3.5.29",
"wxt": "workspace:*"
},
"patchedDependencies": {
"markdown-it-footnote@4.0.0": "patches/markdown-it-footnote.patch",
"simple-git-hooks@2.13.1": "patches/simple-git-hooks@2.13.1.patch",
"pkg-pr-new@0.0.66": "patches/pkg-pr-new@0.0.66.patch"
},
"simple-git-hooks": {
"pre-commit": "./node_modules/.bin/nano-staged"
},
+7 -3
View File
@@ -6,10 +6,12 @@
"scripts": {
"dev": "buildc --deps-only -- wxt",
"dev:build": "buildc --deps-only -- wxt build",
"check": "pnpm build && check",
"check": "bun run build && check",
"build": "buildc -- tsdown",
"prepack": "pnpm build",
"prepare": "buildc --deps-only -- wxt prepare"
"prepack": "bun run build",
"postinstall": "buildc --deps-only -- wxt prepare",
"test": "echo 'noop'",
"test:coverage": "echo 'noop'"
},
"dependencies": {
"@wxt-dev/browser": "workspace:^",
@@ -20,8 +22,10 @@
"wxt": ">=0.20.0"
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"@types/ua-parser-js": "^0.7.39",
"publint": "^0.3.18",
"tsdown": "^0.21.0",
"typescript": "^5.9.3",
"wxt": "workspace:*"
},
+1 -1
View File
@@ -16,7 +16,7 @@ Install the package:
npm i --save-dev @wxt-dev/auto-icons
pnpm i -D @wxt-dev/auto-icons
yarn add --dev @wxt-dev/auto-icons
bun i -D @wxt-dev/auto-icons
bun add -D @wxt-dev/auto-icons
```
Add the module to `wxt.config.ts`:
+6 -2
View File
@@ -39,9 +39,10 @@
],
"scripts": {
"build": "buildc -- tsdown",
"check": "pnpm build && check",
"check": "bun run build && check",
"test": "buildc --deps-only -- vitest",
"prepack": "pnpm build"
"test:coverage": "bun run test run --coverage",
"prepack": "bun run build"
},
"peerDependencies": {
"wxt": ">=0.19.0"
@@ -51,8 +52,11 @@
"sharp": "^0.34.5"
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"@types/fs-extra": "^11.0.4",
"oxlint": "^1.51.0",
"publint": "^0.3.18",
"tsdown": "^0.21.0",
"typescript": "^5.9.3",
"vitest": "^4.0.18",
"wxt": "workspace:*"
+3 -1
View File
@@ -12,7 +12,9 @@
},
"scripts": {
"check": "check",
"gen": "tsx scripts/generate.ts"
"gen": "bun run scripts/generate.ts",
"test": "echo 'noop'",
"test:coverage": "echo 'noop'"
},
"author": {
"name": "Aaron Klinker",
+8 -9
View File
@@ -1,14 +1,13 @@
import spawn from 'nano-spawn';
import { mkdir, readdir, readFile, writeFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { dirname, join, resolve, sep } from 'node:path';
import { sep as posixSep } from 'node:path/posix';
import { readdir, mkdir } from 'node:fs/promises';
import { styleText } from 'node:util';
// Fetch latest version
console.log(`Getting latest version of ${styleText('cyan', '@types/chrome')}`);
await spawn('pnpm', ['i', '--ignore-scripts', '-D', '@types/chrome@latest']);
await Bun.$`bun install --ignore-scripts -D @types/chrome@latest`;
// Generate new package.json
@@ -18,8 +17,8 @@ const pkgJsonPath = fileURLToPath(
import.meta.resolve('@types/chrome/package.json'),
);
const pkgDir = dirname(pkgJsonPath);
const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf-8'));
const pkgJsonTemplate = await readFile('templates/package.json', 'utf8');
const pkgJson = await Bun.file(pkgJsonPath).json();
const pkgJsonTemplate = await Bun.file('templates/package.json').text();
const newPkgJson = JSON.parse(
pkgJsonTemplate.replaceAll('{{chromeTypesVersion}}', pkgJson.version),
);
@@ -28,8 +27,8 @@ newPkgJson.peerDependencies = pkgJson.peerDependencies;
newPkgJson.peerDependenciesMeta = pkgJson.peerDependenciesMeta;
const outPkgJsonPath = resolve('package.json');
await writeFile(outPkgJsonPath, JSON.stringify(newPkgJson, null, 2));
await spawn('pnpm', ['-w', 'prettier', '--write', outPkgJsonPath]);
await Bun.write(outPkgJsonPath, JSON.stringify(newPkgJson));
await Bun.$`bun run --cwd ../.. prettier --write "${outPkgJsonPath}"`;
// Generate declaration files
@@ -51,11 +50,11 @@ const declarationFileMapping = (
}));
for (const { file, srcPath, destPath } of declarationFileMapping) {
const content = await readFile(srcPath, 'utf8');
const content = await Bun.file(srcPath).text();
const transformedContent = transformFile(file, content);
const destDir = dirname(destPath);
await mkdir(destDir, { recursive: true });
await writeFile(destPath, transformedContent);
await Bun.write(destPath, transformedContent);
console.log(` ${styleText('dim', '-')} ${styleText('cyan', file)}`);
}
+3 -1
View File
@@ -12,7 +12,9 @@
},
"scripts": {
"check": "check",
"gen": "tsx scripts/generate.ts"
"gen": "bun run scripts/generate.ts",
"test": "echo 'noop'",
"test:coverage": "echo 'noop'"
},
"author": {
"name": "Aaron Klinker",
+4 -1
View File
@@ -24,7 +24,8 @@
"build": "buildc -- tsdown",
"check": "buildc --deps-only -- check",
"test": "buildc --deps-only -- vitest",
"prepack": "pnpm build"
"test:coverage": "bun run test run --coverage",
"prepack": "bun run build"
},
"dependencies": {
"@wxt-dev/browser": "workspace:^",
@@ -41,9 +42,11 @@
}
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"@types/node": "^20.17.6",
"oxlint": "^1.51.0",
"publint": "^0.3.18",
"tsdown": "^0.21.0",
"typescript": "^5.9.3",
"vitest": "^4.0.18",
"vitest-plugin-random-seed": "^1.1.2",
+3 -3
View File
@@ -6,10 +6,10 @@
"license": "MIT",
"scripts": {
"build": "buildc -- tsdown",
"check": "pnpm build && check",
"check": "bun run build && check",
"test": "buildc --deps-only -- vitest",
"test:coverage": "pnpm test run --coverage",
"prepack": "pnpm build"
"test:coverage": "bun run test run --coverage",
"prepack": "bun run build"
},
"dependencies": {
"@wxt-dev/browser": "workspace:^"
+6 -3
View File
@@ -40,10 +40,12 @@
],
"scripts": {
"dev": "wxt",
"check": "pnpm build && check",
"check": "bun run build && check",
"build": "buildc -- tsdown",
"prepare": "buildc --deps-only -- wxt prepare",
"prepack": "pnpm build"
"postinstall": "buildc --deps-only -- wxt prepare",
"test": "echo 'noop'",
"test:coverage": "echo 'noop'",
"prepack": "bun run build"
},
"peerDependencies": {
"vite": "^5.4.19 || ^6.3.4 || ^7.0.0 || ^8.0.0-0",
@@ -53,6 +55,7 @@
"@vitejs/plugin-react": "^4.4.1 || ^5.0.0 || ^6.0.0"
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"publint": "^0.3.18",
+7 -3
View File
@@ -40,10 +40,12 @@
],
"scripts": {
"dev": "wxt",
"check": "pnpm build && check",
"check": "bun run build && check",
"build": "buildc -- tsdown",
"prepare": "buildc --deps-only -- wxt prepare",
"prepack": "pnpm build"
"postinstall": "buildc --deps-only -- wxt prepare",
"test": "echo 'noop'",
"test:coverage": "echo 'noop'",
"prepack": "bun run build"
},
"peerDependencies": {
"wxt": ">=0.19.16"
@@ -52,8 +54,10 @@
"vite-plugin-solid": "^2.11.10"
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"publint": "^0.3.18",
"solid-js": "^1.9.11",
"tsdown": "^0.21.0",
"typescript": "^5.9.3",
"wxt": "workspace:*"
}
+6 -2
View File
@@ -40,8 +40,10 @@
],
"scripts": {
"build": "buildc -- tsdown",
"check": "pnpm build && check",
"prepack": "pnpm build"
"check": "bun run build && check",
"test": "echo 'noop'",
"test:coverage": "echo 'noop'",
"prepack": "bun run build"
},
"peerDependencies": {
"wxt": ">=0.18.6",
@@ -51,7 +53,9 @@
"@sveltejs/vite-plugin-svelte": ">=4"
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"publint": "^0.3.18",
"tsdown": "^0.21.0",
"typescript": "^5.9.3",
"wxt": "workspace:*"
}
+6 -2
View File
@@ -40,8 +40,10 @@
],
"scripts": {
"build": "buildc -- tsdown",
"check": "pnpm build && check",
"prepack": "pnpm build"
"check": "bun run build && check",
"test": "echo 'noop'",
"test:coverage": "echo 'noop'",
"prepack": "bun run build"
},
"peerDependencies": {
"wxt": ">=0.19.16"
@@ -50,7 +52,9 @@
"@vitejs/plugin-vue": "^5.2.3 || ^6.0.0"
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"publint": "^0.3.18",
"tsdown": "^0.21.0",
"typescript": "^5.9.3",
"wxt": "workspace:*"
}
+3 -3
View File
@@ -1,8 +1,8 @@
//
// USAGE:
// pnpm dev
// pnpm dev firefox-nightly
// pnpm dev <target>
// bun run dev
// bun run dev firefox-nightly
// bun run dev <target>
//
import { run } from './src';
+6 -3
View File
@@ -21,15 +21,18 @@
"license": "MIT",
"funding": "https://github.com/sponsors/wxt-dev",
"scripts": {
"check": "pnpm build && check",
"check": "bun run build && check",
"test": "buildc --deps-only -- vitest",
"dev": "tsx --trace-warnings dev.ts",
"test:coverage": "bun run test run --coverage",
"dev": "bun run dev.ts",
"build": "buildc -- tsdown",
"prepack": "pnpm build"
"prepack": "bun run build"
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"oxlint": "^1.51.0",
"publint": "^0.3.18",
"tsdown": "^0.21.0",
"typescript": "^5.9.3",
"vitest": "^4.0.18"
},
+4 -1
View File
@@ -28,7 +28,8 @@
"build": "buildc -- tsdown",
"check": "buildc --deps-only -- check",
"test": "buildc --deps-only -- vitest",
"prepack": "pnpm build"
"test:coverage": "bun run test run --coverage",
"prepack": "bun run build"
},
"dependencies": {
"@wxt-dev/browser": "workspace:^",
@@ -36,9 +37,11 @@
"dequal": "^2.0.3"
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"@webext-core/fake-browser": "^1.3.4",
"oxlint": "^1.51.0",
"publint": "^0.3.18",
"tsdown": "^0.21.0",
"typescript": "^5.9.3",
"vitest": "^4.0.18"
},
+1 -1
View File
@@ -10,7 +10,7 @@ Install the package:
npm i --save-dev @wxt-dev/unocss unocss
pnpm i -D @wxt-dev/unocss unocss
yarn add --dev @wxt-dev/unocss unocss
bun i -D @wxt-dev/unocss unocss
bun add -D @wxt-dev/unocss unocss
```
Add the module to `wxt.config.ts`:
+5 -1
View File
@@ -34,15 +34,19 @@
"scripts": {
"build": "buildc -- tsdown",
"check": "buildc --deps-only -- check",
"prepack": "pnpm build"
"test": "echo 'noop'",
"test:coverage": "echo 'noop'",
"prepack": "bun run build"
},
"peerDependencies": {
"unocss": ">=0.60.0",
"wxt": ">=0.19.0"
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"oxlint": "^1.51.0",
"publint": "^0.3.18",
"tsdown": "^0.21.0",
"typescript": "^5.9.3",
"unocss": "^0.64.0 || ^0.65.0 || ^65.0.0 || ^66.0.0",
"wxt": "workspace:*"
+7 -3
View File
@@ -36,18 +36,22 @@
],
"scripts": {
"dev": "wxt",
"check": "pnpm build && check",
"check": "bun run build && check",
"build": "buildc -- tsdown",
"prepare": "buildc --deps-only -- wxt prepare",
"prepack": "pnpm build"
"postinstall": "buildc --deps-only -- wxt prepare",
"test": "echo 'noop'",
"test:coverage": "echo 'noop'",
"prepack": "bun run build"
},
"peerDependencies": {
"webextension-polyfill": "*",
"wxt": ">=0.20.0"
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"@types/webextension-polyfill": "^0.12.5",
"publint": "^0.3.18",
"tsdown": "^0.21.0",
"typescript": "^5.9.3",
"webextension-polyfill": "^0.12.0",
"wxt": "workspace:*"
+4 -1
View File
@@ -8,12 +8,13 @@
"dev:firefox": "buildc --deps-only -- wxt -b firefox",
"dev:firefox-mv3": "buildc --deps-only -- wxt -b firefox --mv3",
"build": "buildc --deps-only -- wxt build",
"build:all": "buildc --deps-only -- pnpm run --reporter-hide-prefix /^build:all:.*/",
"build:all": "buildc --deps-only -- bun run build:all:chrome-mv3 && bun run build:all:chrome-mv2 && bun run build:all:firefox-mv3 && bun run build:all:firefox-mv2",
"build:all:chrome-mv3": "wxt build",
"build:all:chrome-mv2": "wxt build --mv2",
"build:all:firefox-mv3": "wxt build -b firefox --mv3",
"build:all:firefox-mv2": "wxt build -b firefox",
"test": "buildc --deps-only -- vitest",
"test:coverage": "bun run test run --coverage",
"zip": "buildc --deps-only -- wxt zip",
"check": "buildc --deps-only -- check",
"postinstall": "buildc --deps-only -- wxt prepare"
@@ -24,6 +25,8 @@
"react-dom": "^19.2.4"
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"@aklinker1/check": "^2.2.0",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@wxt-dev/auto-icons": "workspace:*",
+3 -5
View File
@@ -1,6 +1,5 @@
import { describe, it, expect } from 'vitest';
import { describe, expect, it } from 'vitest';
import { TestProject } from '../utils';
import spawn from 'nano-spawn';
describe('Auto Imports', () => {
describe('imports: { ... }', () => {
@@ -318,9 +317,8 @@ describe('Auto Imports', () => {
await project.prepare({
imports: { eslintrc: { enabled: version } },
});
return await spawn('pnpm', ['eslint', 'entrypoints/background.js'], {
cwd: project.root,
});
return await project.run('eslint', 'entrypoints/background.js');
}
describe('ESLint 9', () => {
+26 -5
View File
@@ -5,12 +5,23 @@ import { describe, expect, it } from 'vitest';
import { TestProject, WXT_PACKAGE_DIR } from '../utils';
describe('Init command', () => {
it('should download and create a template', async () => {
// Broken on Windows + Bun
it.skip('should download and create a template', async () => {
const project = new TestProject();
await spawn(
'pnpm',
['-s', 'wxt', 'init', project.root, '-t', 'vue', '--pm', 'npm'],
'bun',
[
'run',
'--silent',
'wxt',
'init',
project.root,
'-t',
'vue',
'--pm',
'npm',
],
{
env: { CI: 'true' },
stdio: 'ignore',
@@ -57,8 +68,18 @@ describe('Init command', () => {
await expect(() =>
spawn(
'pnpm',
['-s', 'wxt', 'init', project.root, '-t', 'vue', '--pm', 'npm'],
'bun',
[
'run',
'--silent',
'wxt',
'init',
project.root,
'-t',
'vue',
'--pm',
'npm',
],
{
env: { CI: 'true' },
stdio: 'ignore',
+6 -31
View File
@@ -1,40 +1,15 @@
import { test, expect } from 'vitest';
import spawn from 'nano-spawn';
import {
NpmListDependency,
NpmListProject,
} from '../../src/core/package-managers/npm';
// Tests to ensure the total size of the WXT module is as small as possible
// https://pkg-size.dev/wxt
test('Only one version of esbuild should be installed (each version is ~20mb of node_modules)', async () => {
const { stdout } = await spawn('pnpm', [
'why',
'esbuild',
'--prod',
'--json',
]);
const projects: NpmListProject[] = JSON.parse(stdout);
const esbuildVersions = new Set<string>();
iterateDependencies(projects, (name, meta) => {
if (name === 'esbuild') esbuildVersions.add(meta.version);
});
const { stdout } = await spawn('bun', ['why', 'esbuild']);
expect([...esbuildVersions]).toHaveLength(1);
// This text represents the wxt package being responsible for a version of esbuild?
// If this doesn't work, we'll need to find a better way to check this.
const count = stdout.match(/\n [└├]─ wxt@workspace/g)?.length || 0;
expect(count).toBe(1);
});
function iterateDependencies(
projects: NpmListProject[],
cb: (name: string, meta: NpmListDependency) => void,
) {
const recurse = (dependencies: Record<string, NpmListDependency>) => {
Object.entries(dependencies).forEach(([name, meta]) => {
cb(name, meta);
if (meta.dependencies) recurse(meta.dependencies);
});
};
projects.forEach((project) => {
if (project.dependencies) recurse(project.dependencies);
});
}
+6 -19
View File
@@ -1,13 +1,10 @@
import { describe, expect, it } from 'vitest';
import { TestProject } from '../utils';
import extract from 'extract-zip';
import spawn from 'nano-spawn';
import { readFile, writeFile } from 'node:fs/promises';
process.env.WXT_PNPM_IGNORE_WORKSPACE = 'true';
import { describe, expect, it } from 'vitest';
import { TestProject } from '../utils';
describe('Zipping', () => {
it('should download packages and produce a valid build when zipping sources', async () => {
it('should download packages and include them as overrides in the zipped package.json', async () => {
const project = new TestProject({
name: 'test',
version: '1.0.0',
@@ -29,24 +26,15 @@ describe('Zipping', () => {
expect(await project.pathExists('.output/')).toBe(true);
await extract(sourcesZip, { dir: unzipDir });
// Update package json wxt path
const packageJsonPath = project.resolvePath(unzipDir, 'package.json');
const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf-8'));
packageJson.dependencies.wxt = '../../../../..';
await writeFile(
packageJsonPath,
JSON.stringify(packageJson, null, 2),
'utf-8',
);
// Build zipped extension
await expect(
spawn('pnpm', ['i', '--ignore-workspace', '--frozen-lockfile', 'false'], {
spawn('bun', ['install'], {
cwd: unzipDir,
}),
).resolves.not.toHaveProperty('exitCode');
await expect(
spawn('pnpm', ['wxt', 'build', '-b', 'firefox'], {
spawn('bun', ['wxt', 'build', '-b', 'firefox'], {
cwd: unzipDir,
}),
).resolves.not.toHaveProperty('exitCode');
@@ -64,10 +52,9 @@ describe('Zipping', () => {
"description": "Example description",
"version": "1.0.0",
"dependencies": {
"wxt": "../../../../..",
"flatten": "1.0.3"
},
"resolutions": {
"overrides": {
"flatten@1.0.3": "file://./.wxt/local_modules/flatten-1.0.3.tgz"
}
}"
+10 -6
View File
@@ -1,5 +1,5 @@
import merge from 'lodash.merge';
import spawn from 'nano-spawn';
import spawn, { Subprocess } from 'nano-spawn';
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import { dirname, relative, resolve } from 'path';
import { glob } from 'tinyglobby';
@@ -14,7 +14,7 @@ import {
import { normalizePath } from '../src/core/utils';
import { pathExists, readJson } from '../src/core/utils/fs';
// Run "pnpm wxt" to use the "wxt" dev script, not the "wxt" binary from the
// Run "bun wxt" to use the "wxt" dev script, not the "wxt" binary from the
// wxt package. This uses the TS files instead of the compiled JS package
// files.
export const WXT_PACKAGE_DIR = resolve(__dirname, '..');
@@ -48,9 +48,6 @@ export class TestProject {
name: 'E2E Extension',
description: 'Example description',
version: '0.0.0',
dependencies: {
wxt: '../../..',
},
},
packageJson,
),
@@ -127,7 +124,7 @@ export class TestProject {
// Only install dependencies if the project has custom ones - otherwise the
// project will reuse the ones in `packages/wxt/node_modules`!
if (this.hasCustomDependencies) {
await spawn('pnpm', ['--ignore-workspace', 'i', '--ignore-scripts'], {
await spawn('bun', ['install', '--ignore-scripts'], {
cwd: this.root,
});
}
@@ -199,4 +196,11 @@ export class TestProject {
): Promise<any> {
return readJson(this.resolvePath(path));
}
/** Run a command using the project's package manager. */
async run(...args: string[]): Promise<Subprocess> {
return await spawn('bun', args, {
cwd: this.root,
});
}
}
+9 -5
View File
@@ -5,15 +5,15 @@
"description": "⚡ Next-gen Web Extension Framework",
"license": "MIT",
"scripts": {
"wxt": "tsx src/cli/index.ts",
"build": "buildc -- tsdown --config-loader unrun",
"check": "pnpm build && pnpm run --reporter-hide-prefix /^check:.*/",
"wxt": "bun run src/cli/index.ts",
"build": "buildc -- bun run tsdown --config-loader unrun",
"check": "bun run build && bun run check:default && bun run check:tsc-virtual",
"check:default": "check",
"check:tsc-virtual": "tsc --noEmit -p src/virtual",
"test": "buildc --deps-only -- vitest",
"test:coverage": "pnpm test run --coverage",
"test:coverage": "bun run test run --coverage",
"sync-releases": "pnpx changelogen@latest gh release",
"prepack": "pnpm build"
"prepack": "bun run build"
},
"dependencies": {
"@1natsu/wait-element": "^4.1.2",
@@ -68,7 +68,10 @@
}
},
"devDependencies": {
"@aklinker1/buildc": "^1.1.7",
"@faker-js/faker": "^10.3.0",
"@types/bun": "^1.3.5",
"@types/fs-extra": "^11.0.4",
"@types/lodash.merge": "^4.6.9",
"@types/node": "^20.17.6",
"@types/normalize-path": "^3.0.2",
@@ -80,6 +83,7 @@
"lodash.merge": "^4.6.2",
"oxlint": "^1.51.0",
"publint": "^0.3.18",
"tsdown": "^0.21.0",
"typescript": "^5.9.3",
"vitest": "^4.0.18",
"vitest-plugin-random-seed": "^1.1.2"
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';
import path from 'node:path';
import { bun } from '../bun';
// TODO: Remove now that bun supports windows?
describe.skipIf(() => process.platform === 'win32')(
'Bun Package Management Utils',
() => {
@@ -0,0 +1,22 @@
{
"lockfileVersion": 1,
"configVersion": 1,
"workspaces": {
"": {
"name": "bun-ls",
"dependencies": {
"mime-types": "2.1.35",
},
"devDependencies": {
"flatten": "1.0.3",
},
},
},
"packages": {
"flatten": ["flatten@1.0.3", "", {}, "sha512-dVsPA/UwQ8+2uoFe5GHtiBMu48dWLTdsuEd7CKGlZlD78r1TTWBvDuFaFGKCo/ZfEr95Uk56vZoX86OsHkUeIg=="],
"mime-db": ["mime-db@1.52.0", "", {}, "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="],
"mime-types": ["mime-types@2.1.35", "", { "dependencies": { "mime-db": "1.52.0" } }, "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw=="],
}
}
@@ -1,5 +1,6 @@
{
"name": "bun-ls",
"packageManager": "bun@1.3.5",
"dependencies": {
"mime-types": "2.1.35"
},
@@ -1,5 +1,6 @@
{
"name": "pnpm-ls",
"packageManager": "pnpm@10.29.3",
"dependencies": {
"mime-types": "2.1.35"
},
@@ -9,7 +9,7 @@ describe('NPM Package Management Utils', () => {
const cwd = path.resolve(__dirname, 'fixtures/simple-npm-project');
beforeAll(async () => {
// NPM needs the modules installed for 'npm ls' to work
await spawn('npm', ['i'], { cwd });
await spawn('npm', ['install'], { cwd });
}, 60e3);
it('should list direct dependencies', async () => {
@@ -1,7 +1,7 @@
import { beforeAll, describe, expect, it } from 'vitest';
import path from 'node:path';
import { pnpm } from '../pnpm';
import spawn from 'nano-spawn';
import path from 'node:path';
import { beforeAll, describe, expect, it } from 'vitest';
import { pnpm } from '../pnpm';
process.env.WXT_PNPM_IGNORE_WORKSPACE = 'true';
@@ -10,7 +10,7 @@ describe('PNPM Package Management Utils', () => {
const cwd = path.resolve(__dirname, 'fixtures/simple-pnpm-project');
beforeAll(async () => {
// PNPM needs the modules installed, or 'pnpm ls' will return a blank list.
await spawn('pnpm', ['i', '--ignore-workspace'], { cwd });
await spawn('pnpm', ['install'], { cwd });
});
it('should list direct dependencies', async () => {
@@ -4,11 +4,11 @@ import { isOnline, fetchCached } from '../network';
import { ResolvedConfig } from '../../../types';
type DnsCallback = (err: NodeJS.ErrnoException | null) => void;
type MockedFetch = ReturnType<typeof vi.fn>;
vi.mock('node:dns');
global.fetch = vi.fn();
const fetchMock = vi.fn<typeof fetch>();
global.fetch = fetchMock;
describe('Network utils', () => {
describe('isOnline', () => {
@@ -75,11 +75,11 @@ describe('Network utils', () => {
};
const mockContent = 'cached content';
(global.fetch as MockedFetch).mockReturnValueOnce(
fetchMock.mockReturnValueOnce(
Promise.resolve({
status: 200,
text: async () => mockContent,
}),
} as Response),
);
const result = await fetchCached(
@@ -112,11 +112,11 @@ describe('Network utils', () => {
},
};
(global.fetch as MockedFetch).mockReturnValueOnce(
fetchMock.mockReturnValueOnce(
Promise.resolve({
status: 500,
text: async () => '',
}),
} as Response),
);
const result = await fetchCached(
@@ -154,7 +154,7 @@ describe('Network utils', () => {
);
expect(result).toBe('offline cache');
expect(global.fetch as MockedFetch).not.toHaveBeenCalled();
expect(fetchMock).not.toHaveBeenCalled();
});
it('should throw error when offline and no cache available', async () => {
@@ -47,6 +47,7 @@ describe('Content Script UIs', () => {
<p id="three"></p>
</div>
`;
// @ts-ignore
window.fetch = fetch;
fetch.mockResolvedValue({ text: () => Promise.resolve('') });
ctx = new ContentScriptContext('test');
+7
View File
@@ -0,0 +1,7 @@
Bun outputs packed tarballs relative to the workspace root when using `--filename`. So we need to use an absolute patht make sure the file is output where pkg-pr-new expects it to be - in the package's directory.
`p3` is equal to: '/home/runner/work/wxt/wxt/packages/analytics/'
This has been fixed in <https://github.com/stackblitz-labs/pkg.pr.new/pull/483>, but is not released as of `0.66.0`.
Once v0.67.0 is released, we can revert back to using bunx, delete this patch, and remove the local dependency in `<root>/package.json`.
+47
View File
@@ -0,0 +1,47 @@
diff --git a/node_modules/pkg-pr-new/.bun-tag-c719f450f9f5410d b/.bun-tag-c719f450f9f5410d
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/dist/index.js b/dist/index.js
index e2626a009efe1ee3cfa6c96fe712341d3501ba1c..20755fe90b3c8807b28e63e9ebcfb244aea07be9 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -3743,7 +3743,7 @@ async function resolveTarball(pm, p3, pJson) {
if (pm === "yarn") {
cmd += ` --filename ${filename}`;
} else if (pm === "bun") {
- cmd = `bun pm pack --quiet --filename ${filename}`;
+ cmd = `bun pm pack --quiet --filename ${p3}${filename}`;
}
const { stdout: stdout2 } = await ezSpawn.async(cmd, {
stdio: "overlapped",
@@ -3753,18 +3753,18 @@ async function resolveTarball(pm, p3, pJson) {
if (pm !== "yarn" && pm !== "bun") {
filename = lines[lines.length - 1].trim();
}
- if (pm === "bun") {
- const tgzFiles = fsSync.readdirSync(p3).filter((file) => file.endsWith(".tgz"));
- const bunFilename = stdout2.trim();
- if (bunFilename) {
- filename = bunFilename;
- }
- console.warn(`[bun pack] stdout:
-${stdout2}`);
- console.warn(
- `[bun pack] expected filename: ${filename}; tgz files: ${tgzFiles.join(", ") || "(none)"}`
- );
- }
+// if (pm === "bun") {
+// const tgzFiles = fsSync.readdirSync(p3).filter((file) => file.endsWith(".tgz"));
+// const bunFilename = stdout2.trim();
+// if (bunFilename) {
+// filename = bunFilename;
+// }
+// console.warn(`[bun pack] stdout:
+// ${stdout2}`);
+// console.warn(
+// `[bun pack] expected filename: ${filename}; tgz files: ${tgzFiles.join(", ") || "(none)"}`
+// );
+// }
const shasum = createHash("sha1").update(await fs.readFile(path.resolve(p3, filename))).digest("hex");
return { filename, shasum };
}
+3
View File
@@ -0,0 +1,3 @@
Manually apply PR: <https://github.com/toplenboren/simple-git-hooks/pull/136>
Can be removed after >=2.13.2 is released.
+15
View File
@@ -0,0 +1,15 @@
diff --git a/simple-git-hooks.js b/simple-git-hooks.js
index 093890d21800c9feb34cb6da5b997b947da812cd..3b11e62bbfcbdf7d2dc8f553237750a220ecae6f 100644
--- a/simple-git-hooks.js
+++ b/simple-git-hooks.js
@@ -100,6 +100,10 @@ function getProjectRootDirectoryFromNodeModules(projectPath) {
if (indexOfDenoDir > -1) {
return projDir.slice(0, indexOfDenoDir - 1).join('/');
}
+ const indexOfBunDir = projDir.indexOf('.bun')
+ if (indexOfBunDir > -1) {
+ return projDir.slice(0, indexOfBunDir - 1).join('/');
+ }
const indexOfStoreDir = projDir.indexOf('.store')
if (indexOfStoreDir > -1) {
-10336
View File
File diff suppressed because it is too large Load Diff
-18
View File
@@ -1,18 +0,0 @@
packages:
- docs
- packages/*
onlyBuiltDependencies:
- '@parcel/watcher'
- dtrace-provider
- esbuild
- sharp
- simple-git-hooks
- spawn-sync
autoInstallPeers: false
patchedDependencies:
markdown-it-footnote: patches/markdown-it-footnote.patch
peerDependencyRules:
ignoreMissing:
- '@algolia/client-search'
- search-insights
- svelte
+5 -5
View File
@@ -16,17 +16,17 @@ N=20
function benchmark_ref() {
# Prep
git checkout $1
pnpm buildc clean
bun run buildc clean
git apply scripts/benchmarks/browser-startup.patch
pnpm i --ignore-scripts
pnpm -r --filter wxt build
bun install --ignore-scripts
bun run --cwd packages/wxt build
echo -n "$1 " >> stats.txt
# Run benchmark
for i in $(seq $N); do
pnpm wxt packages/wxt-demo
bun wxt packages/wxt-demo
done
git checkout HEAD -- packages/wxt/src/core/runners/web-ext.ts pnpm-lock.yaml
git checkout HEAD -- packages/wxt/src/core/runners/web-ext.ts bun.lock
echo "" >> stats.txt
}
+16 -33
View File
@@ -7,14 +7,13 @@ import {
} from 'changelogen';
import { consola } from 'consola';
import { readdir, readFile, writeFile } from 'node:fs/promises';
import spawn from 'nano-spawn';
import path from 'node:path';
import { join } from 'node:path';
import { getPkgTag, grabPackageDetails, listCommitsInDir } from './git';
const pkg = process.argv[2];
if (!pkg) {
throw Error(
'Package name missing. Usage: tsx bump-package-version.ts <package-name>',
'Package name missing. Usage: bun run scripts/bump-package-version.ts <package-name>',
);
}
const { pkgDir, pkgName, currentVersion, prevTag, changelogPath, pkgJsonPath } =
@@ -38,10 +37,8 @@ if (currentVersion.startsWith('0.')) {
bumpType = 'patch';
}
}
await spawn('pnpm', ['version', bumpType], {
cwd: pkgDir,
});
const updatedPkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf-8'));
await Bun.$`bun --cwd "${pkgDir}" pm version ${bumpType}`;
const updatedPkgJson = await Bun.file(pkgJsonPath).json();
const newVersion: string = updatedPkgJson.version;
const newTag = getPkgTag(pkg, newVersion);
consola.info('Bump:', { currentVersion, bumpType, newVersion });
@@ -63,7 +60,8 @@ if (originalBumpType === 'major') {
`[⚠️ breaking changes](https://wxt.dev/guide/resources/upgrading.html) &bull; [compare changes]`,
);
}
const { releases: prevReleases } = await readFile(changelogPath, 'utf8')
const { releases: prevReleases } = await Bun.file(changelogPath)
.text()
.then(parseChangelogMarkdown)
.catch(() => ({ releases: [] }));
const allReleases = [
@@ -79,7 +77,7 @@ const newChangelog =
allReleases
.map((release) => [`## v${release.version}`, release.body].join('\n\n'))
.join('\n\n');
await writeFile(changelogPath, newChangelog, 'utf8');
await Bun.write(changelogPath, newChangelog);
consola.success('Updated changelog');
// Update WXT version in templates when releasing wxt package
@@ -88,39 +86,24 @@ if (pkg === 'wxt') {
const templatesDir = 'templates';
const templateDirs = await readdir(templatesDir);
for (const templateDir of templateDirs) {
const templatePkgJsonPath = path.join(
templatesDir,
templateDir,
'package.json',
);
try {
const templatePkgJson = JSON.parse(
await readFile(templatePkgJsonPath, 'utf-8'),
);
const templatePkgJsonPath = join(templatesDir, templateDir, 'package.json');
const templatePkgJsonFile = Bun.file(templatePkgJsonPath);
if (await templatePkgJsonFile.exists()) {
const templatePkgJson = await templatePkgJsonFile.json();
if (templatePkgJson.devDependencies?.wxt) {
templatePkgJson.devDependencies.wxt = `^${newVersion}`;
await writeFile(
templatePkgJsonPath,
await templatePkgJsonFile.write(
JSON.stringify(templatePkgJson, null, 2),
);
templatePkgJsonPaths.push(templatePkgJsonPath);
consola.success(`Updated wxt version in ${templatePkgJsonPath}`);
}
} catch {}
}
}
}
// Commit changes
await spawn('git', [
'add',
pkgJsonPath,
changelogPath,
...templatePkgJsonPaths,
]);
await spawn('git', [
'commit',
'-m',
`chore(release): ${pkgName} v${newVersion}`,
]);
await spawn('git', ['tag', newTag]);
await Bun.$`git add "${pkgJsonPath}" "${changelogPath}" ${templatePkgJsonPaths.join(' ')}`;
await Bun.$`git commit -m "chore(release): ${pkgName} v${newVersion}"`;
await Bun.$`git tag ${newTag}`;
consola.success('Committed version and changelog');
+3 -3
View File
@@ -4,14 +4,13 @@ import {
loadChangelogConfig,
parseChangelogMarkdown,
} from 'changelogen';
import { readFile } from 'node:fs/promises';
import { grabPackageDetails } from './git';
import consola from 'consola';
const pkg = process.argv[2];
if (!pkg) {
throw Error(
'Package name missing. Usage: tsx create-github-release.ts <package-name>',
'Package name missing. Usage: bun run scripts/create-github-release.ts <package-name>',
);
}
@@ -19,7 +18,8 @@ const { pkgName, prevTag, currentVersion, changelogPath } =
await grabPackageDetails(pkg);
consola.info('Creating release for:', { pkg, pkgName, prevTag });
const { releases } = await readFile(changelogPath, 'utf8')
const { releases } = await Bun.file(changelogPath)
.text()
.then(parseChangelogMarkdown)
.catch(() => ({ releases: [] }));
+1 -2
View File
@@ -1,11 +1,10 @@
import { RawGitCommit, getGitDiff } from 'changelogen';
import { consola } from 'consola';
import { readFile } from 'node:fs/promises';
export async function grabPackageDetails(pkg: string) {
const pkgDir = `packages/${pkg}`;
const pkgJsonPath = `${pkgDir}/package.json`;
const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf-8'));
const pkgJson = await Bun.file(pkgJsonPath).json();
const currentVersion: string = pkgJson.version;
return {
pkgDir,
+3 -3
View File
@@ -5,19 +5,19 @@ import {
updateGithubRelease,
} from 'changelogen';
import { getPkgTag, grabPackageDetails } from './git';
import { readFile } from 'node:fs/promises';
import consola from 'consola';
const pkg = process.argv[2];
if (!pkg) {
throw Error(
'Package name missing. Usage: tsx sync-releases.ts <package-name>',
'Package name missing. Usage: bun run scripts/sync-releases.ts <package-name>',
);
}
// Update
const { changelogPath, pkgName } = await grabPackageDetails(pkg);
const { releases } = await readFile(changelogPath, 'utf8')
const { releases } = await Bun.file(changelogPath)
.text()
.then(parseChangelogMarkdown)
.catch(() => ({ releases: [] }));
const config = await loadChangelogConfig(process.cwd());
+39 -12
View File
@@ -1,17 +1,15 @@
import consola from 'consola';
import spawn from 'nano-spawn';
import { readFile, writeFile } from 'node:fs/promises';
import { glob } from 'tinyglobby';
import { dirname } from 'node:path';
import { styleText } from 'node:util';
import pMap from 'p-map';
import * as semver from 'semver';
import { glob } from 'tinyglobby';
import { styleText } from 'node:util';
const HELP_MESSAGE = `
Upgrades dependencies throughout WXT using custom rules.
Usage:
pnpm tsx scripts/upgrade-deps.ts [options]
bun run scripts/upgrade-deps.ts [options]
Options:
--write, -w Write changes to package.json files
@@ -78,7 +76,7 @@ async function main(): Promise<never> {
consola.start('Writing new versions to package.json files...');
await writeUpgrades(packageJsonFiles, upgrades);
consola.success('Done!');
consola.info('\nRun `pnpm i` to install new dependencies\n');
consola.info('\nRun `bun install` to install new dependencies\n');
process.exit(0);
}
@@ -102,7 +100,7 @@ async function getPackageJsonDependencies(
);
const packageJsons: PackageJsonData[] = await Promise.all(
packageJsonFiles.map(async (path) => ({
content: JSON.parse(await readFile(path, 'utf-8')),
content: await Bun.file(path).json(),
path,
folder: dirname(path),
})),
@@ -171,10 +169,38 @@ function validateNoMultipleVersions(
process.exit(1);
}
async function spawnJson(cmd: string[]): Promise<any> {
const child = Bun.spawn({ cmd });
const exitCode = await child.exited;
if (exitCode !== 0)
throw new Error(`Command failed with exit code ${exitCode}`);
return JSON.parse(
// @ts-ignore: text() is an untyped util Bun provides for ReadableStreams
await child.stdout.text(),
);
}
async function fetchPackageInfo(name: string): Promise<PackageInfo> {
// Use PNPM instead of API in case dependencies don't come from NPM
const res = await spawn('pnpm', ['view', name, '--json']);
return JSON.parse(res.stdout);
// Use Bun instead of API in case dependencies don't come from NPM.
const partial = await spawnJson(['bun', 'info', name, '--json']);
// Bun doesn't return the dist-tags and time fields by default, have to fetch
// them separately.
const distTags = await spawnJson([
'bun',
'info',
name,
'dist-tags',
'--json',
]);
const time = await spawnJson(['bun', 'info', name, 'time', '--json']);
return {
...partial,
'dist-tags': distTags,
time,
};
}
type PackageInfo = {
@@ -352,7 +378,8 @@ async function writeUpgrades(
upgrades: UpgradeDetails[],
) {
for (const packageJsonFile of packageJsonFiles) {
const oldText = await readFile(packageJsonFile, 'utf8');
const file = Bun.file(packageJsonFile);
const oldText = await file.text();
let newText = oldText;
for (const upgrade of upgrades) {
const search = `"${upgrade.name}": "${upgrade.currentRange}"`;
@@ -360,7 +387,7 @@ async function writeUpgrades(
newText = newText.replaceAll(search, replace);
}
if (newText !== oldText) {
await writeFile(packageJsonFile, newText, 'utf8');
await file.write(newText);
}
}
}