From dd07b86509db62e7f3665ffd225cf440a84110c6 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Sat, 5 Dec 2026 19:50:46 +0100 Subject: [PATCH] Create the log time formatter on first use --- packages/void/src/log.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/void/src/log.ts b/packages/void/src/log.ts index e6f75c32e5..cf19bc0760 100644 --- a/packages/void/src/log.ts +++ b/packages/void/src/log.ts @@ -2,11 +2,9 @@ import pc from 'picocolors'; const tag = pc.bold(pc.blue('[void]')); -const timeFormat = new Intl.DateTimeFormat(undefined, { - hour: 'numeric', - minute: 'numeric', - second: 'numeric', -}); +// Creating the formatter loads locale data. Builds import this module but usually never +// log, so create it on first use. +let timeFormat: Intl.DateTimeFormat | undefined; let showTimestamp = true; @@ -18,6 +16,11 @@ function prefix(): string { if (!showTimestamp) { return tag; } + timeFormat ??= new Intl.DateTimeFormat(undefined, { + hour: 'numeric', + minute: 'numeric', + second: 'numeric', + }); return `${pc.dim(timeFormat.format())} ${tag}`; }