Skip to content

refactor(domain): resolve every locale into one domain shape at build time - #4093

Merged
BobbieGoede merged 2 commits into
mainfrom
refactor/normalize-domain-locale-type
Jul 27, 2026
Merged

refactor(domain): resolve every locale into one domain shape at build time#4093
BobbieGoede merged 2 commits into
mainfrom
refactor/normalize-domain-locale-type

Conversation

@BobbieGoede

@BobbieGoede BobbieGoede commented Jul 27, 2026

Copy link
Copy Markdown
Member

Based on #4092, the diff will settle once that merges.

The domain bugs fixed in #4090 came from the same place: domain/domainDefault and domains/defaultForDomains describe the same thing, and the build and the runtime each picked which pair to read. normalizeDomainLocale was meant to settle that but only resolved part of it, so a locale could reach route generation or link resolution with either shape missing.

It's now total, domains and defaultForDomains are always set, and the result is typed as NormalizedLocaleObject. Domain logic reads the array fields without falling back, and domainDefault is dropped from that type since it resolves fully into defaultForDomains - reading it past normalization is how the two sides came to disagree. domain is kept, it additionally marks the locale's own domain and domains can't express that.

Behavior is unchanged. domainFromLocale still prefers a locale's own domain, and a host matching no configured domain still resolves none, so dev and staging keep relative URLs.

The type is applied where locales reach domain logic: the resolved context, the runtime config channel and localizeRoutes. The test helpers resolve their locales through the normalizer the way resolveContext does, rather than passing a shape the build never produces.

Summary by CodeRabbit

  • New Features
    • Added normalized locale configuration types with consistently available domain metadata.
    • Improved support for multi-domain locale routing and runtime domain overrides.
  • Bug Fixes
    • Corrected domain detection, default-locale resolution, and host matching for normalized configurations.
    • Ensured locale fallbacks consistently include complete domain metadata.
  • Tests
    • Expanded coverage for domain routing, locale normalization, and runtime domain behavior.

Base automatically changed from fix/x-default-cluster to main July 27, 2026 15:48
…time

`normalizeDomainLocale` now always sets `domains` and `defaultForDomains`, so domain
logic can read them without a fallback, and the result is typed as
`NormalizedLocaleObject`. `domainDefault` is fully resolved into `defaultForDomains`,
so the type takes it away - reading it past normalization is how the build and the
runtime came to disagree in #4090.

The test helpers resolve their locales through the normalizer the same way
`resolveContext` does, rather than passing a shape the build never produces.
Domain resolution reads the array fields directly rather than falling back between
the two shapes. Behavior is unchanged, `domainFromLocale` still prefers a locale's
own `domain` and a host matching no configured domain still resolves none, so dev
and staging keep relative URLs.

`composer.localeProperties` falls back to a bare locale when the current one is not
configured, which is now built in the normalized shape.
@BobbieGoede
BobbieGoede force-pushed the refactor/normalize-domain-locale-type branch from 37f3242 to 552e5dc Compare July 27, 2026 15:50
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3814aea5-528f-49f5-a9c9-14fd2fa67583

📥 Commits

Reviewing files that changed from the base of the PR and between e07063e and 552e5dc.

⛔ Files ignored due to path filters (1)
  • test/__snapshots__/gen.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (19)
  • internals.d.ts
  • src/context.ts
  • src/gen.ts
  • src/prepare/options.ts
  • src/routing.ts
  • src/runtime/context.ts
  • src/runtime/plugins/i18n.ts
  • src/runtime/routing/context.ts
  • src/runtime/routing/head.ts
  • src/runtime/shared/detection.ts
  • src/runtime/shared/domain.ts
  • src/runtime/shared/locales.ts
  • src/types.ts
  • src/utils.ts
  • test/domain.test.ts
  • test/kit.test.ts
  • test/pages/localize_routes.test.ts
  • test/pages/utils.ts
  • test/routing-head.test.ts

Walkthrough

The change introduces NormalizedLocaleObject with guaranteed domain arrays and updates locale normalization to always produce that shape. Build declarations, runtime contexts, routing APIs, domain matching, locale detection, and runtime overrides now consume normalized locales. Tests now construct normalized fixtures and cover domain resolution, route localization, runtime overrides, and normalization edge cases.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main refactor: normalizing every locale into one domain shape at build time.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/normalize-domain-locale-type

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@BobbieGoede
BobbieGoede merged commit ee54631 into main Jul 27, 2026
11 checks passed
@BobbieGoede
BobbieGoede deleted the refactor/normalize-domain-locale-type branch July 27, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant