Skip to content

Export kit driver as injectable string for drizzle-kit - #3

Merged
js85rem merged 3 commits into
mainfrom
support-kit
Mar 5, 2026
Merged

js85rem merged 3 commits into
mainfrom
support-kit

Conversation

@js85rem

@js85rem js85rem commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a ./kit-string export containing the bundled driver code as a string. This enables drizzle-kit to inject the node:sqlite driver without adding a runtime dependency.

Changes

API Refactoring

  • Move kit-only functions (prepareSqliteParams, normaliseSQLiteUrl) from shared.ts to kit.ts
  • Simplify driver API: createNodeSqlDriver(dbPath, prepareSqliteParams) — caller provides the param preparation function

New Export

  • ./kit-string exports drizzleKitDriverBlock: string containing the bundled driver code
  • Generated via deno task build:kit-string using Deno.bundle
  • Output goes to dist/kit-string.ts (gitignored, generated at publish time)

CI/Publishing

  • Added build:kit-string step to publish workflow
  • Validates export statement is stripped (fails fast if bundler output format changes)

Improved Error Handling

  • Add hasColumns() guard in proxy fallback path with descriptive error message
  • Consistent error handling between shared and kit code paths

Usage in drizzle-kit

import { drizzleKitDriverBlock } from "@hotsauce/drizzle-runtime-sqlite/kit-string";

// Inject into connections.ts at build time
const nodeSqliteDriver = new Function(drizzleKitDriverBlock + "; return createNodeSqlDriver;")();

Testing

  • All 133 tests pass (Deno 2.7)
  • Build script validated

- Move kit-only functions (prepareSqliteParams, normaliseSQLiteUrl) to kit.ts
- Simplify API: createNodeSqlDriver(dbPath, prepareSqliteParams)
- Add build script to bundle kit.ts as injectable string (dist/kit-string.ts)
- Add prepublish task to generate kit-string at publish time
- Configure CI workflow to run build:kit-string before publish
- Add hasColumns guard in proxy fallback path (consistent error handling)
- Clarify migration-only usage of internal drizzle instance
- Document Deno 2.x requirement for --unstable-bundle in README
- Add local publishing instructions to README
@js85rem
js85rem merged commit 7b23ac6 into main Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants