From 260d6a5f9e5024fff7a1b2d0444cab3edc2f576c Mon Sep 17 00:00:00 2001 From: Matt Wonlaw Date: Thu, 9 Oct 2025 06:28:08 -0400 Subject: [PATCH 1/4] add bun support --- .github/workflows/build.yml | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7481724..731db78 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,8 @@ env: # See https://github.com/nodejs/release#release-schedule # Node.js v20 EOL = 2026-04-30. v22 EOL = 2027-04-30. v23 EOL = 2025-06-01. v24 EOL = 2028-04-30. NODE_BUILD_CMD: npx --no-install prebuild -r node -t 20.0.0 -t 22.0.0 -t 23.0.0 -t 24.0.0 --include-regex '_sqlite3' + # Bun versions - see https://github.com/oven-sh/bun/releases + BUN_BUILD_CMD: npx --no-install prebuild -r bun -t 1.1.0 --include-regex '_sqlite3' jobs: test: @@ -53,6 +55,35 @@ jobs: - run: npm run build-debug - run: npm test + test-bun: + strategy: + matrix: + os: + - ubuntu-22.04 + - macos-13 + - macos-14 + bun: + - 1.1.38 + name: Testing Bun ${{ matrix.bun }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v5 + - uses: oven-sh/setup-bun@v2 + with: + bun-version: ${{ matrix.bun }} + - if: ${{ startsWith(matrix.os, 'macos') }} + run: brew install python-setuptools + - if: ${{ !startsWith(matrix.os, 'macos') }} + run: python3 -m pip install setuptools + - if: ${{ startsWith(matrix.os, 'ubuntu') }} + run: | + sudo apt update + sudo apt install -y gcc-10 g++-10 libreadline-dev libncurses5-dev + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 + - run: bun install --ignore-scripts + - run: bun run build-debug + - run: bun test + publish: if: ${{ github.event_name == 'release' }} name: Publishing to NPM @@ -63,6 +94,7 @@ jobs: - prebuild-alpine-arm - prebuild-linux-x64 - prebuild-linux-arm + - prebuild-bun steps: - uses: actions/checkout@v5 - uses: actions/setup-node@v5 @@ -164,3 +196,35 @@ jobs: cd /tmp/project && \ npm install --ignore-scripts && \ ${{ env.NODE_BUILD_CMD }} -u ${{ secrets.GITHUB_TOKEN }}" + + prebuild-bun: + if: ${{ github.event_name == 'release' }} + strategy: + fail-fast: false + matrix: + os: + - macos-13 + - macos-14 + - ubuntu-22.04 + name: Prebuild Bun on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + needs: test-bun + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 + with: + node-version: 20 + - uses: oven-sh/setup-bun@v2 + with: + bun-version: 1.1.38 + - if: ${{ startsWith(matrix.os, 'macos') }} + run: brew install python-setuptools + - if: ${{ !startsWith(matrix.os, 'macos') }} + run: python3 -m pip install setuptools + - if: ${{ startsWith(matrix.os, 'ubuntu') }} + run: | + sudo apt update + sudo apt install -y gcc-10 g++-10 libreadline-dev libncurses5-dev + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 + - run: npm install --ignore-scripts + - run: ${{ env.BUN_BUILD_CMD }} -u ${{ secrets.GITHUB_TOKEN }} From 2fb77bd8f222df165ec6bee5758eb0a63d70db24 Mon Sep 17 00:00:00 2001 From: Matt Wonlaw Date: Thu, 9 Oct 2025 06:35:14 -0400 Subject: [PATCH 2/4] latest stable bun --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 731db78..505a171 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,7 +63,7 @@ jobs: - macos-13 - macos-14 bun: - - 1.1.38 + - 1.2.23 name: Testing Bun ${{ matrix.bun }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} steps: @@ -216,7 +216,7 @@ jobs: node-version: 20 - uses: oven-sh/setup-bun@v2 with: - bun-version: 1.1.38 + bun-version: 1.2.23 - if: ${{ startsWith(matrix.os, 'macos') }} run: brew install python-setuptools - if: ${{ !startsWith(matrix.os, 'macos') }} From 0e7f87348c12479583538fb28d62293bde80637a Mon Sep 17 00:00:00 2001 From: Matt Wonlaw Date: Thu, 9 Oct 2025 09:43:34 -0400 Subject: [PATCH 3/4] bun docs and engine req --- README.md | 1 + docs/troubleshooting.md | 10 ++++++++++ package.json | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 140fd27..2ec6e42 100644 --- a/README.md +++ b/README.md @@ -4,5 +4,6 @@ So far the changes are: * Build the [bedrock](https://sqlite.org/src/timeline?r=bedrock) branch of SQLite to enable [`begin concurrent`](https://www.sqlite.org/src/doc/begin-concurrent/doc/begin_concurrent.md). * Create a shell too, so we can debug db files created +* Supports both Node.js (20.x, 22.x, 23.x, 24.x) and Bun (>=1.1.0) runtimes Other changes will be likely be made over time. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 1197f34..1d49fca 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -38,6 +38,16 @@ If you still have issues, try these steps: 1. Delete your `$HOME/.node-gyp` directory 1. Run `npm install` +## Bun + +If you're using Bun and encounter issues: + +1. Ensure you're using Bun 1.1.0 or later +2. Try rebuilding: `bun run build-release` +3. Check that prebuilt binaries are available for your platform + +Note: Bun uses the same native module system as Node.js, so most Node.js troubleshooting steps apply. + ## Still stuck? Browse [previous installation issues](https://github.com/WiseLibs/better-sqlite3/issues?q=is%3Aissue). diff --git a/package.json b/package.json index 7cd264c..c8b313f 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "shell.sh" ], "engines": { - "node": "20.x || 22.x || 23.x || 24.x" + "node": "20.x || 22.x || 23.x || 24.x", + "bun": ">=1.1.0" }, "types": "lib/index.d.ts", "dependencies": { From d78fdc169bcc0823c5e5ce6713ad599d816b97b9 Mon Sep 17 00:00:00 2001 From: Matt Wonlaw Date: Thu, 9 Oct 2025 09:49:29 -0400 Subject: [PATCH 4/4] fix ci error for bun tests --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 505a171..2d52882 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,7 +82,7 @@ jobs: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 - run: bun install --ignore-scripts - run: bun run build-debug - - run: bun test + - run: bun run test publish: if: ${{ github.event_name == 'release' }}