feat: usar alias bun:sqlite a better-sqlite3 solo en dev y ajustar Docker

Co-authored-by: aider (openrouter/openai/gpt-5) <aider@aider.chat>
webui
borja 2 weeks ago
parent fe6e08d9df
commit 3a5b212271

@ -17,6 +17,8 @@ RUN bun install
# Prepare and install web dependencies # Prepare and install web dependencies
COPY apps/web/package.json apps/web/ COPY apps/web/package.json apps/web/
WORKDIR /app/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
# Copy sources # Copy sources

@ -23,7 +23,7 @@
"typescript": "^5.9.2", "typescript": "^5.9.2",
"vite": "^7.1.7" "vite": "^7.1.7"
}, },
"dependencies": { "optionalDependencies": {
"better-sqlite3": "^12.4.1" "better-sqlite3": "^12.4.1"
} }
} }

@ -1,14 +1,22 @@
import { sveltekit } from '@sveltejs/kit/vite'; import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
export default defineConfig({ export default defineConfig(({ mode }) => {
plugins: [sveltekit()], const isDev = mode === 'development';
ssr: {
// Evita que Node intente resolver el esquema 'bun:' durante el build SSR return {
external: ['bun:sqlite'] plugins: [sveltekit()],
}, resolve: {
optimizeDeps: { // En desarrollo, alias para usar better-sqlite3 (Vite/HMR no entiende 'bun:sqlite')
// No prebundlear 'bun:sqlite' en dev alias: isDev ? { 'bun:sqlite': 'better-sqlite3' } : {}
exclude: ['bun:sqlite'] },
} ssr: {
// En producción, evitar que Node intente resolver el esquema 'bun:'
external: isDev ? [] : ['bun:sqlite']
},
optimizeDeps: {
// No prebundlear 'bun:sqlite' (no aplica en dev si alias está activo, pero es inofensivo)
exclude: ['bun:sqlite']
}
};
}); });

Loading…
Cancel
Save