🔧 update: migrate to node.js runtime with bun as toolchain - #4
🔧 update: migrate to node.js runtime with bun as toolchain#4warengonzaga wants to merge 12 commits into
Conversation
- Remove dual-runtime adapter (isBun + bun:sqlite path) from runtime.ts - Simplify openDatabase() to always use better-sqlite3 - Remove @types/bun devDependency, add @types/better-sqlite3 - Make better-sqlite3 a required peer dependency (remove optional flag) - Remove bun:sqlite from build externals in scripts/build.ts - Remove types:[bun] from tsconfig.json compilerOptions - Update engines field to node>=22.0.0 (current LTS, aligns with org standard) - Update CI workflow to use Node 22 - Update module-level docs and description to reflect Node.js runtime - Update encryption.ts install hint from bun add to npm install - Simplify bundle regression test: verify no bun:sqlite leakage and that better-sqlite3 stays external in node-targeted builds Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Migrates config-engine to a Node.js-only runtime by removing Bun runtime branching and standardizing the SQLite adapter on better-sqlite3, while continuing to use Bun for build/test tooling. This aligns the package with Node.js >=22 environments without requiring Bun at runtime.
Changes:
- Simplify runtime DB adapter to always use
better-sqlite3and remove Bun runtime detection. - Update dependencies/engines to reflect Node.js runtime support and
better-sqlite3as a required peer dependency. - Adjust build/test/tooling configs to remove Bun runtime typing and prevent Bun-specific SQLite leakage in node-targeted bundles.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Removes Bun type injection to reflect Node.js-targeted runtime compilation. |
| tests/runtime.test.ts | Updates bundle regression test to check for Bun-specific imports and better-sqlite3 externalization. |
| src/types.ts | Updates adapter interface documentation to match the single-driver runtime. |
| src/runtime.ts | Removes Bun runtime path and standardizes DB open logic on better-sqlite3. |
| src/index.ts | Updates module-level docs to describe Node.js runtime + Bun toolchain. |
| src/encryption.ts | Updates peer dependency install hint to npm to match Node.js consumer runtime. |
| scripts/build.ts | Removes bun:sqlite from externals since it’s no longer a runtime concern. |
| package.json | Updates description/keywords/engines; swaps Bun types for @types/better-sqlite3; makes better-sqlite3 a required peer dep. |
| .github/workflows/build.yml | Bumps CI Node version to 22 to match the new engines/runtime target. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…b publishing - Replace package-build-flow-action with build-flow-action app.yml@v0.2.0 - Rename build.yml to build-flow.yml to match org convention - Use ci-profile: node-bun with matrix versions [22, 24, 26] - Enable package publishing to both npm and github packages - Add concurrency group and workflow_dispatch trigger - Update engines to node ^22.0.0 || ^24.0.0 || ^26.0.0 (matches org standard) - Add packageManager field to package.json Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Prevents CRLF/LF conflicts between Windows dev env and CI (Linux). Also fixes biome formatting and import sorting violations across codebase. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
better-sqlite3 is a native NAPI addon that requires a compile step during postinstall. Without --trust, bun blocks it and the .node binary is never built, causing a NAPI fatal crash at runtime. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…stall Bun blocks native postinstall scripts by default. Adding better-sqlite3 to trustedDependencies in package.json allows the native .node binary to be compiled during bun install, preventing the NAPI fatal crash. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Enables --frozen-lockfile in CI and ensures trustedDependencies (better-sqlite3 native postinstall) is preserved in the lockfile. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Replace bun:test imports with vitest across all test files - Rewrite runtime.test.ts to use child_process instead of Bun.build/spawnSync - Fix platform.test.ts toEndWith() -> toMatch regex (bun-only matcher) - Add vitest devDependency - Update test script: bun test -> vitest run - Update CI test command: bun test -> bunx vitest run bun:test + better-sqlite3 (native NAPI addon) causes a fatal crash when Bun tries to load the .node binary. Running tests under Node.js via vitest eliminates this incompatibility entirely. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
Package flow in build-flow-action requires bun to be pre-installed, but the job has no setup step for it. Switch package-manager to npm so the Package flow uses npm ci with package-lock.json instead. CI gate jobs continue to use bun for install/test via ci-install-command. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace bun-runtime build.ts with node-compatible build.mjs that invokes bun build as a subprocess via child_process.execFileSync. This allows npm run build to work in the Package flow CI job where only Node.js is available. Bun remains the bundler via subprocess. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace Bun.build() API with esbuild (new devDependency) in build.mjs. The script now runs under Node.js without requiring bun in PATH, which fixes the Package flow CI job that only has Node.js available. Remove build.ts (bun-native) since it is replaced by build.mjs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Summary
Migrates the runtime from a Bun-first dual-adapter approach to a pure Node.js runtime while keeping Bun as the build/test toolchain. This widens compatibility to any Node.js >=22 environment without requiring Bun at runtime.
Motivation
The Bun-first design required consumers to either run Bun or carry bundling workarounds. Node.js has significantly broader ecosystem support, making config-engine usable in any standard Node.js project without runtime-specific conditions.
Changes
Runtime (
src/runtime.ts)isBun()detection and the entireopenBunDatabase()/getBunSqliteSpecifier()pathopenDatabase()to always usebetter-sqlite3Dependencies (
package.json)@types/bundevDependency, add@types/better-sqlite3better-sqlite3a required peer dependency (remove optional flag)enginesto^22.0.0 || ^24.0.0 || ^26.0.0(matches CI matrix, aligns with org standard)packageManager: bun@1.3.9Build (
scripts/build.ts,tsconfig.json)bun:sqlitefrom build externalstypes: ["bun"]from tsconfig compilerOptionsCI (
.github/workflows/build-flow.yml)package-build-flow-actiontobuild-flow-action/app.yml@v0.2.0(org-standard reusable workflow)build.yml→build-flow.ymlto match org conventionci-profile: node-bunwith matrix["22", "24", "26"]— tests Node 22 LTS, 24 current, 26 latestenable-package: true,package-registry: both)workflow_dispatchtriggerTests (
tests/runtime.test.ts)bun:sqliteleakage and thatbetter-sqlite3stays externalDocs / misc
src/index.tssrc/types.tsadapter commentsrc/encryption.tsinstall hint (bun add→npm install)