From 9f1207505a6da8e6a41fee8ba7ddc62547aa876e Mon Sep 17 00:00:00 2001 From: iTrooz Date: Mon, 8 Sep 2025 23:47:45 +0200 Subject: [PATCH 1/4] fix: pino-pretty crashing in web environment by only using it in CLI --- mclib/src/logger.ts | 11 +++++++---- mclib/tsconfig.json | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mclib/src/logger.ts b/mclib/src/logger.ts index 36023d4..9b66ff8 100644 --- a/mclib/src/logger.ts +++ b/mclib/src/logger.ts @@ -1,5 +1,4 @@ -import pino from 'pino'; -import pinoPretty from 'pino-pretty'; +import pino, { DestinationStream } from 'pino'; export enum LogLevel { Fatal = 'fatal', @@ -9,13 +8,17 @@ export enum LogLevel { Debug = 'debug', Trace = 'trace' } - +let maybePretty: DestinationStream | undefined = undefined; +if (typeof window === 'undefined') { + const pinoPretty = (await import("pino-pretty")).default; + maybePretty = pinoPretty(); +} const logger = pino({ level: 'info', // default level base: { pid: false, } -}, pinoPretty()); +}, maybePretty); class LoggerConfig { static setLevel(level: LogLevel): void { diff --git a/mclib/tsconfig.json b/mclib/tsconfig.json index 1e09cc5..9411092 100644 --- a/mclib/tsconfig.json +++ b/mclib/tsconfig.json @@ -5,7 +5,7 @@ "composite": true, "declaration": true, "module": "ESNext", - "target": "ES6", + "target": "es2017", "moduleResolution": "bundler", "strict": true, "lib": ["esnext", "DOM", "DOM.Iterable"] From bb9bfb88f671fed40d43ce69f2bdab6357808cb3 Mon Sep 17 00:00:00 2001 From: iTrooz Date: Mon, 8 Sep 2025 23:55:30 +0200 Subject: [PATCH 2/4] use esnext in web frontend (I hate js) --- web/vite.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/vite.config.ts b/web/vite.config.ts index db944df..fc227c7 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -14,5 +14,8 @@ export default defineConfig({ define: { __APP_VERSION__: JSON.stringify(pkg.version), CONFIG_BACKEND_URL: JSON.stringify(process.env.BACKEND_URL) + }, + build: { + target: "esnext", } }); From a6f5bdab767c59fbb03ed4f12a1f8a4cf0798401 Mon Sep 17 00:00:00 2001 From: iTrooz Date: Mon, 8 Sep 2025 23:59:24 +0200 Subject: [PATCH 3/4] while we're at it let's target esnext everywhere, whatever that means --- mclib/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mclib/tsconfig.json b/mclib/tsconfig.json index 9411092..7c9db10 100644 --- a/mclib/tsconfig.json +++ b/mclib/tsconfig.json @@ -5,7 +5,7 @@ "composite": true, "declaration": true, "module": "ESNext", - "target": "es2017", + "target": "esnext", "moduleResolution": "bundler", "strict": true, "lib": ["esnext", "DOM", "DOM.Iterable"] From 62bdc817e03264de9eca27ab35cd55d0406b606d Mon Sep 17 00:00:00 2001 From: iTrooz Date: Tue, 9 Sep 2025 00:01:33 +0200 Subject: [PATCH 4/4] fix linting --- web/vite.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/vite.config.ts b/web/vite.config.ts index fc227c7..06248bd 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -16,6 +16,6 @@ export default defineConfig({ CONFIG_BACKEND_URL: JSON.stringify(process.env.BACKEND_URL) }, build: { - target: "esnext", + target: 'esnext' } });