From a9facabe0716d2de036e02bdac1ef67eeaa53ed3 Mon Sep 17 00:00:00 2001 From: borja Date: Wed, 15 Oct 2025 10:09:31 +0200 Subject: [PATCH] build: evita instalar dependencias opcionales y usa bun:sqlite Co-authored-by: aider (openrouter/openai/gpt-5) --- Dockerfile | 3 +-- apps/web/src/lib/server/db.ts | 12 +++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index e97ed4e..dfa162b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,8 +18,7 @@ RUN bun install COPY apps/web/package.json apps/web/ WORKDIR /app/apps/web # No instalar optionalDependencies (better-sqlite3) en build de producción -ENV npm_config_optional=false -RUN bun install +RUN bun install --no-optional # Copy sources WORKDIR /app diff --git a/apps/web/src/lib/server/db.ts b/apps/web/src/lib/server/db.ts index ae943c9..2c3037d 100644 --- a/apps/web/src/lib/server/db.ts +++ b/apps/web/src/lib/server/db.ts @@ -28,15 +28,9 @@ function applyDefaultPragmas(instance: any): void { * - En Node (Vite dev SSR): better-sqlite3 */ async function importSqliteDatabase(): Promise { - try { - // @ts-ignore - if (typeof Bun !== 'undefined') { - const mod = await import('bun:sqlite'); - return (mod as any).Database; - } - } catch {} - const mod = await import('better-sqlite3'); - return (mod as any).default || (mod as any).Database || mod; + // En desarrollo, el alias de Vite resolverá 'bun:sqlite' -> 'better-sqlite3' + const mod: any = await import('bun:sqlite'); + return (mod as any).Database || (mod as any).default || mod; } /**