Skip to content

Commit 0cdd87d

Browse files
committed
fix(dialect-wasqlite-worker): make onCreateConnection promisable
1 parent 9a9788d commit 0cdd87d

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

packages/dialect-wasqlite-worker/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ export interface WaSqliteWorkerDialectConfig {
4343

4444
see in [playground](../../playground/src/modules/wasqliteWorker.ts)
4545

46+
if throw error when using `Vite` to build, add worker config
47+
48+
```ts
49+
export default defineConfig({
50+
// ...
51+
worker: {
52+
format: 'es',
53+
},
54+
})
55+
```
56+
4657
## limitation
4758

4859
only worked in secure environment, like:

packages/dialect-wasqlite-worker/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { DatabaseConnection, DatabaseIntrospector, Dialect, DialectAdapter, Driver, Kysely, QueryCompiler } from 'kysely'
22
import { SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler } from 'kysely'
33
import { WaSqliteWorkerDriver } from './driver'
4+
import type { Promisable } from './type'
45

56
export interface WaSqliteWorkerDialectConfig {
67
/**
@@ -29,7 +30,7 @@ export interface WaSqliteWorkerDialectConfig {
2930
* prefer to use OPFS, fallback to IndexedDB
3031
*/
3132
preferOPFS?: boolean
32-
onCreateConnection?: (connection: DatabaseConnection) => Promise<void>
33+
onCreateConnection?: (connection: DatabaseConnection) => Promisable<void>
3334
}
3435
export class WaSqliteWorkerDialect implements Dialect {
3536
readonly #config: WaSqliteWorkerDialectConfig

packages/dialect-wasqlite-worker/src/type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { QueryResult } from 'kysely'
22

3+
export type Promisable<T> = T | Promise<T>
4+
35
export type RunMsg = {
46
type: 'run'
57
isSelect: boolean

0 commit comments

Comments
 (0)