From 79381a4cc99d62ac990e5e5ef5d246f52265d350 Mon Sep 17 00:00:00 2001 From: Antigravity Date: Sat, 9 May 2026 15:49:05 +0000 Subject: [PATCH] fix: isolate detect-user-language from client bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove detectUserLanguage re-export from i18n barrel index.ts — it depends on next/headers (server-only) and was being pulled into client component bundles via sidebar.tsx → lib/i18n/index.ts, causing build failure. Add 'server-only' guard to detect-user-language.ts to make the constraint explicit. --- memento-note/lib/i18n/detect-user-language.ts | 6 +++++- memento-note/lib/i18n/index.ts | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/memento-note/lib/i18n/detect-user-language.ts b/memento-note/lib/i18n/detect-user-language.ts index 229ecea..fa93cb3 100644 --- a/memento-note/lib/i18n/detect-user-language.ts +++ b/memento-note/lib/i18n/detect-user-language.ts @@ -5,11 +5,15 @@ * 1. Most common language among user's notes (DB GROUP BY) * 2. Browser language hint (passed from server component via Accept-Language) * 3. Default: 'en' + * + * SERVER ONLY — uses next/headers and Prisma. Never import from client components. */ +import 'server-only' import { auth } from '@/auth' import { prisma } from '@/lib/prisma' -import { unstable_cache, cookies } from 'next/cache' +import { unstable_cache } from 'next/cache' +import { cookies } from 'next/headers' import { SupportedLanguage } from './load-translations' const SUPPORTED_LANGUAGES = new Set(['en', 'fr', 'es', 'de', 'fa', 'it', 'pt', 'ru', 'zh', 'ja', 'ko', 'ar', 'hi', 'nl', 'pl']) diff --git a/memento-note/lib/i18n/index.ts b/memento-note/lib/i18n/index.ts index 00b3667..4564283 100644 --- a/memento-note/lib/i18n/index.ts +++ b/memento-note/lib/i18n/index.ts @@ -1,8 +1,11 @@ /** - * i18n exports - * Centralized internationalization system with JSON-based translations + * i18n exports — client-safe barrel + * Centralized internationalization system with JSON-based translations. + * + * detectUserLanguage is intentionally NOT re-exported here because it depends + * on next/headers (server-only). Import it directly: + * import { detectUserLanguage } from '@/lib/i18n/detect-user-language' */ export { LanguageProvider, useLanguage } from './LanguageProvider' -export { detectUserLanguage } from './detect-user-language' export { loadTranslations, getTranslationValue, type SupportedLanguage, type Translations } from './load-translations'