Skip to content

fix(core): restore hreflang links in bundled SSR#2198

Open
masonjames wants to merge 1 commit into
emdash-cms:mainfrom
masonjames:codex/fix-i18n-config-singleton
Open

fix(core): restore hreflang links in bundled SSR#2198
masonjames wants to merge 1 commit into
emdash-cms:mainfrom
masonjames:codex/fix-i18n-config-singleton

Conversation

@masonjames

Copy link
Copy Markdown
Contributor

What does this PR do?

Keeps the configured locale list available when Vite loads EmDash through more than one SSR module chunk. This restores the hreflang links that were skipped when the UI and middleware read separate module instances, and adds a regression test that recreates that boundary.

Closes #2061

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: Not applicable; this is a bug fix.

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: OpenAI Codex (GPT-5)

Screenshots / test output

  • pnpm build
  • pnpm typecheck
  • pnpm lint
  • pnpm --filter emdash exec vitest run tests/unit/i18n/config.test.ts (1 test passed)
  • Full core run: 5,014 tests passed; the only failure is the pre-existing macOS /var vs /private/var path assertion in virtual-modules.test.ts.
  • No admin UI strings or screenshots are involved.

@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 31ebda6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/plugin-mcp-smoke Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@2198

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@2198

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@2198

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@2198

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@2198

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@2198

emdash

npm i https://pkg.pr.new/emdash@2198

create-emdash

npm i https://pkg.pr.new/create-emdash@2198

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@2198

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@2198

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@2198

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@2198

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@2198

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@2198

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@2198

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@2198

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@2198

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@2198

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@2198

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@2198

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@2198

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@2198

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@2198

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@2198

commit: 31ebda6

@masonjames
masonjames marked this pull request as ready for review July 22, 2026 14:35
@github-actions github-actions Bot added the review/needs-review No maintainer or bot review yet label Jul 22, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the right fix for the problem described in #2061. Moving the i18n config from a module-scoped variable to a Symbol.for("emdash:i18n-config") slot on globalThis matches the repository's established singleton pattern (used in request-context.ts, settings/index.ts, and the middleware runtime/setup holders) and directly addresses Vite/Rollup duplicating modules across SSR chunks. The regression test recreates that boundary by using vi.resetModules() and dynamic re-imports, and it would fail under the old module-level _config implementation.

I checked:

  • The new packages/core/src/i18n/config.ts singleton store and all updated consumers (getI18nConfig, isI18nEnabled, resolveConfiguredLocale, getFallbackChain).
  • Callers of setI18nConfig/getI18nConfig, including the middleware virtual-config initialization and seo/hreflang.ts.
  • The new unit test in packages/core/tests/unit/i18n/config.test.ts.
  • The changeset (correct package emdash, user-facing wording).

No blocking issues, convention violations, or new logged-out queries. LGTM.

@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core review/approved Approved; no new commits since size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hreflang still missing from page head

1 participant