Skip to content

🔧 update: migrate to node.js runtime with bun as toolchain - #4

Open
warengonzaga wants to merge 12 commits into
devfrom
feature/node-runtime-migration
Open

🔧 update: migrate to node.js runtime with bun as toolchain#4
warengonzaga wants to merge 12 commits into
devfrom
feature/node-runtime-migration

Conversation

@warengonzaga

@warengonzaga warengonzaga commented Aug 27, 2026

Copy link
Copy Markdown
Member

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)

  • Remove isBun() detection and the entire openBunDatabase() / getBunSqliteSpecifier() path
  • Simplify openDatabase() to always use better-sqlite3

Dependencies (package.json)

  • Drop @types/bun devDependency, add @types/better-sqlite3
  • Make better-sqlite3 a required peer dependency (remove optional flag)
  • Update engines to ^22.0.0 || ^24.0.0 || ^26.0.0 (matches CI matrix, aligns with org standard)
  • Add packageManager: bun@1.3.9
  • Update description and keywords to reflect Node.js runtime

Build (scripts/build.ts, tsconfig.json)

  • Remove bun:sqlite from build externals
  • Remove types: ["bun"] from tsconfig compilerOptions

CI (.github/workflows/build-flow.yml)

  • Migrate from package-build-flow-action to build-flow-action/app.yml@v0.2.0 (org-standard reusable workflow)
  • Rename build.ymlbuild-flow.yml to match org convention
  • Use ci-profile: node-bun with matrix ["22", "24", "26"] — tests Node 22 LTS, 24 current, 26 latest
  • Enable package publishing to both NPM and GitHub Packages (enable-package: true, package-registry: both)
  • Add concurrency group and workflow_dispatch trigger

Tests (tests/runtime.test.ts)

  • Simplify bundle regression test: verifies no bun:sqlite leakage and that better-sqlite3 stays external

Docs / misc

  • Update module-level JSDoc in src/index.ts
  • Update src/types.ts adapter comment
  • Fix src/encryption.ts install hint (bun addnpm install)

- 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>
Copilot AI lite review requested due to automatic review settings August 27, 2026 12:04
@warengonzaga warengonzaga added enhancement [Type] New feature or improvement to existing functionality [issues, PRs] core [Area] Core logic, business rules, and primary functionality [issues, PRs] refactor [Type] Code improvement without changing functionality [PRs] labels Aug 27, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in Workbench Aug 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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-sqlite3 and remove Bun runtime detection.
  • Update dependencies/engines to reflect Node.js runtime support and better-sqlite3 as 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.

Comment thread tests/runtime.test.ts Outdated
warengonzaga and others added 8 commits August 27, 2026 20:07
…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>
@github-advanced-security

Copy link
Copy Markdown

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:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

warengonzaga and others added 3 commits August 27, 2026 23:02
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core [Area] Core logic, business rules, and primary functionality [issues, PRs] enhancement [Type] New feature or improvement to existing functionality [issues, PRs] refactor [Type] Code improvement without changing functionality [PRs]

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants