diff --git a/.changeset/tired-ways-wonder.md b/.changeset/tired-ways-wonder.md new file mode 100644 index 00000000..1d418543 --- /dev/null +++ b/.changeset/tired-ways-wonder.md @@ -0,0 +1,5 @@ +--- +"emdash": patch +--- + +Fixes i18n config returning null in Vite dev SSR by reading from virtual module instead of dynamic import. diff --git a/packages/core/src/emdash-runtime.ts b/packages/core/src/emdash-runtime.ts index 810b0bba..dde8602b 100644 --- a/packages/core/src/emdash-runtime.ts +++ b/packages/core/src/emdash-runtime.ts @@ -9,6 +9,7 @@ import type { Element } from "@emdash-cms/blocks"; import { Kysely, sql, type Dialect } from "kysely"; +import virtualConfig from "virtual:emdash/config"; import { validateRev } from "./api/rev.js"; import type { @@ -1299,11 +1300,10 @@ export class EmDashRuntime { const authMode = getAuthMode(this.config); const authModeValue = authMode.type === "external" ? authMode.providerType : "passkey"; - // Include i18n config if enabled - const { getI18nConfig, isI18nEnabled } = await import("./i18n/config.js"); - const i18nConfig = getI18nConfig(); + // Include i18n config if enabled (read from virtual module to avoid SSR module singleton mismatch) + const i18nConfig = virtualConfig?.i18n; const i18n = - isI18nEnabled() && i18nConfig + i18nConfig && i18nConfig.locales && i18nConfig.locales.length > 1 ? { defaultLocale: i18nConfig.defaultLocale, locales: i18nConfig.locales } : undefined;