Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
- name: Check formatting
run: deno fmt --check

- name: Build kit-string
run: deno task build:kit-string

- name: Lint
run: deno lint

Expand Down
38 changes: 38 additions & 0 deletions PR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## Export kit driver as injectable string for drizzle-kit

### 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

```ts
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
3 changes: 3 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@
"strict": true,
"noImplicitAny": true
},
"publish": {
"exclude": ["!dist/kit-string.ts"]
},
"nodeModulesDir": "auto"
}