Skip to content

Commit

Permalink
fix(wasm): override logger functions
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Jan 23, 2025
1 parent 7b480c5 commit 6a24a40
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/runtime/internal/database.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ export function loadDatabaseAdapter<T>(collection: T): DatabaseAdapter {
async function loadAdapter<T>(collection: T) {
if (!db) {
const sqlite3InitModule = await import('@sqlite.org/sqlite-wasm').then(m => m.default)
// @ts-expect-error sqlite3ApiConfig is not defined in the module
globalThis.sqlite3ApiConfig = {
// overriding default log function allows to avoid error when logger are dropped in build.
// For example `nuxt-security` module drops logger in production build by default.
silent: true,
debug: (...args: unknown[]) => console.debug(...args),
warn: (...args: unknown[]) => console.warn(...args),
error: (...args: unknown[]) => console.error(...args),
log: (...args: unknown[]) => console.log(...args),
}
const sqlite3 = await sqlite3InitModule()
db = new sqlite3.oo1.DB()
}
Expand Down

0 comments on commit 6a24a40

Please sign in to comment.