fix(runtime): bundle all deps to avoid bun CJS loader crash

This commit is contained in:
2026-03-14 22:13:37 +01:00
parent 7cafa0ed2f
commit cb8ffb346d
8 changed files with 23 additions and 50 deletions

View File

@@ -63,8 +63,6 @@ services:
ROOT_ADMIN_EMAIL: ${ROOT_ADMIN_EMAIL}
PUBLIC_SENTRY_DSN: ${PUBLIC_SENTRY_DSN}
NODE_ENV: production
volumes:
- staging-app-logs:/var/log/app
env_file:
- .env.staging
healthcheck:
@@ -82,4 +80,3 @@ services:
volumes:
pgdata-staging:
staging-app-logs:

View File

@@ -36,8 +36,6 @@ services:
OSU_IRC_PASSWORD: ${OSU_IRC_PASSWORD}
PUBLIC_SENTRY_DSN: ${PUBLIC_SENTRY_DSN}
NODE_ENV: production
volumes:
- app-logs:/var/log/app
env_file:
- .env
healthcheck:
@@ -90,4 +88,3 @@ services:
volumes:
pgdata:
umamidata:
app-logs:

View File

@@ -46,6 +46,7 @@
"globals": "^17.3.0",
"husky": "^9.1.7",
"lint-staged": "^16.3.3",
"pino": "^10.3.1",
"pino-pretty": "^13.1.3",
"playwright": "^1.58.1",
"postgres": "^3.4.8",
@@ -73,7 +74,6 @@
},
"dependencies": {
"bancho.js": "^0.12.3",
"discord.js": "^14.25.1",
"pino": "^10.3.1"
"discord.js": "^14.25.1"
}
}

View File

@@ -3,6 +3,16 @@ import type { Handle, HandleServerError } from '@sveltejs/kit';
import { sequence } from '@sveltejs/kit/hooks';
import { building } from '$app/environment';
import * as Sentry from '@sentry/sveltekit';
if (!building) {
Sentry.init({
dsn: process.env.PUBLIC_SENTRY_DSN,
tracesSampleRate: 0.2,
environment: process.env.NODE_ENV ?? 'development',
sendDefaultPii: true
});
}
import { auth } from '$lib/server/auth';
import { svelteKitHandler } from 'better-auth/svelte-kit';
import { db } from '$lib/server/db';

View File

@@ -1,8 +0,0 @@
import * as Sentry from '@sentry/sveltekit';
Sentry.init({
dsn: process.env.PUBLIC_SENTRY_DSN,
tracesSampleRate: 0.2,
environment: process.env.NODE_ENV ?? 'development',
sendDefaultPii: true
});

View File

@@ -4,32 +4,14 @@ import { building } from '$app/environment';
const isProduction = !building && process.env.NODE_ENV === 'production';
const transport = building
? undefined
: isProduction
? pino.transport({
targets: [
{ target: 'pino/file', options: { destination: 1 } },
{
target: 'pino/file',
options: { destination: '/var/log/app/app.log', mkdir: true }
}
]
})
: pino.transport({
target: 'pino-pretty',
options: { colorize: true, translateTime: 'HH:MM:ss' }
});
export const logger = pino(
{
level: isProduction ? 'info' : 'debug',
base: { service: 'vash-esports' },
serializers: pino.stdSerializers,
redact: ['req.headers.authorization', 'req.headers.cookie']
},
transport
);
// Production: JSON to stdout (Docker captures logs via log driver)
// Dev: pipe through pino-pretty (`bun run dev | bunx pino-pretty`)
export const logger = pino({
level: isProduction ? 'info' : 'debug',
base: { service: 'vash-esports' },
serializers: pino.stdSerializers,
redact: ['req.headers.authorization', 'req.headers.cookie']
});
// Child loggers per subsystem — maps to existing [Tag] prefixes
export const log = {

View File

@@ -3,12 +3,7 @@ import adapter from '@sveltejs/adapter-node';
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter(),
experimental: {
instrumentation: {
server: true
}
}
adapter: adapter()
}
};

View File

@@ -37,11 +37,11 @@ export default defineConfig({
devtoolsJson()
],
ssr: {
external: ['bun', 'pino', 'pino-pretty']
external: ['bun']
},
build: {
rollupOptions: {
external: ['bun', 'pino', 'pino-pretty']
external: ['bun']
},
reportCompressedSize: false
},