Skip to content

Commit f8ac3bd

Browse files
feat: add alias for bun import
1 parent 4c67f21 commit f8ac3bd

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/db/bun-sqlite-stub.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export class Database {
2+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3+
constructor(_path) {
4+
throw new Error('bun:sqlite is not available in this environment')
5+
}
6+
}

src/db/bun-sqlite-stub.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export class Database {
2+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3+
constructor(_path: string) {
4+
throw new Error('bun:sqlite is not available in this environment')
5+
}
6+
}

vitest.config.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import { defineConfig } from 'vitest/config'
2+
import path from 'path'
23

34
export default defineConfig({
5+
resolve: {
6+
alias: {
7+
'bun:sqlite': path.resolve(__dirname, 'src/db/bun-sqlite-stub.ts'),
8+
},
9+
},
410
test: {
511
globals: true,
612
environment: 'node',
7-
include: ['tests/**/*.test.ts'],
813
coverage: {
914
provider: 'v8',
1015
reporter: ['text', 'lcov', 'html'],
11-
include: ['src/**/*.ts'],
12-
exclude: ['**/node_modules/**', '**/dist/**', '**/*.test.ts'],
1316
thresholds: {
1417
lines: 80,
1518
branches: 80,

wrangler.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"enabled": true,
1212
"head_sampling_rate": 1
1313
},
14+
"alias": {
15+
"bun:sqlite": "./src/db/bun-sqlite-stub"
16+
},
1417
"vars": {
1518
"STUBIDP_TRUST_PROXY": "true",
1619
"STUBIDP_HTTPS_REDIRECT": "true"

0 commit comments

Comments
 (0)