From 0604288f7ffd701c2541084e626add8cbecbefb9 Mon Sep 17 00:00:00 2001 From: ideepakchauhan7 Date: Mon, 6 Apr 2026 22:25:40 +0530 Subject: [PATCH 1/2] Fix i18n config returning null in Vite dev SSR The admin manifest endpoint was returning i18n: null in Vite dev mode due to a module singleton mismatch between static and dynamic imports. In getManifest(), the i18n config was loaded via dynamic import(), but the middleware that calls setI18nConfig() uses a static import. In Vite dev SSR, these resolve to different module instances. The fix reads i18n config directly from the virtual module (virtual:emdash/config) which contains the serialized config data populated by the Astro integration at build time. Fixes #294 --- .changeset/tired-ways-wonder.md | 5 +++++ packages/core/src/emdash-runtime.ts | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .changeset/tired-ways-wonder.md 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..e68b4df2 100644 --- a/packages/core/src/emdash-runtime.ts +++ b/packages/core/src/emdash-runtime.ts @@ -9,6 +9,8 @@ import type { Element } from "@emdash-cms/blocks"; import { Kysely, sql, type Dialect } from "kysely"; +// @ts-ignore - virtual module +import virtualConfig from "virtual:emdash/config"; import { validateRev } from "./api/rev.js"; import type { @@ -1299,11 +1301,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; From 8534adc95e7c0972392b61732588877fe276ac95 Mon Sep 17 00:00:00 2001 From: Deepak Chauhan <91007260+ideepakchauhan7@users.noreply.github.com> Date: Mon, 6 Apr 2026 23:08:06 +0530 Subject: [PATCH 2/2] Update packages/core/src/emdash-runtime.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/core/src/emdash-runtime.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/src/emdash-runtime.ts b/packages/core/src/emdash-runtime.ts index e68b4df2..dde8602b 100644 --- a/packages/core/src/emdash-runtime.ts +++ b/packages/core/src/emdash-runtime.ts @@ -9,7 +9,6 @@ import type { Element } from "@emdash-cms/blocks"; import { Kysely, sql, type Dialect } from "kysely"; -// @ts-ignore - virtual module import virtualConfig from "virtual:emdash/config"; import { validateRev } from "./api/rev.js";