Skip to content

Breaking change (6.7.4): resolveSiteGlobals() now runs on all CMS routes, silently activating site globals for sites not using withSiteGlobals() #292

Description

@JonasJesus42

Summary

Starting from v6.7.4, resolveSiteGlobals() was moved from withSiteGlobals() into loadCmsPageInternal (inside cmsRoute.ts). This means it now runs on every CMS route, regardless of whether the site uses the withSiteGlobals() wrapper.

This is an undocumented breaking change for sites that use cmsRouteConfig without withSiteGlobals().

What changed

Before 6.7.4 (withSiteGlobals.ts):

  • resolveSiteGlobals() was only called inside the withSiteGlobals() wrapper
  • Sites using cmsRouteConfig alone had globals (including Theme section) silently not rendered
  • The site's :root CSS fallbacks were used for all custom properties

From 6.7.4 (cmsRoute.ts, comment references #233):

// Resolve page sections and site globals in parallel. Globals are merged
// into the same `resolvedSections` array so the path through this server
// function is identical for SSR (F5) and SPA (<Link>) navigations — see
// #233 for the previous SPA-breakage when `withSiteGlobals` ran client-side
const [enrichedSections, globals] = await Promise.all([
  runSectionLoaders(page.resolvedSections, request),
  resolveSiteGlobals(),
]);
  • resolveSiteGlobals() now runs unconditionally on all routes
  • Globals (e.g. Theme section from site.json) are rendered everywhere
  • This silently activates sections that the site had no idea were being injected

Impact

Sites that relied on globals NOT being rendered now have them injected without any code change on their end. In the lebiscuit project this manifested as:

  1. The Theme section (registered in site.json → "theme") now renders a <style> block into every page
  2. The Theme.tsx toValue() function emitted bare oklch components (47.81% 0.20 29deg) instead of full oklch(...) values
  3. These variables override the :root fallback hex values in app.css
  4. Tailwind v4's @theme { --color-brand-primary-1: var(--brand-primary-1) } now resolves to invalid CSS, breaking all custom colors site-wide

The site went from working colors to completely broken colors between 6.6.1 → 6.7.4 with no changes to the site's own code.

Reproduction

  1. Create a site using cmsRouteConfig without withSiteGlobals()
  2. Have a Theme section registered in site.json
  3. Run with 6.6.1 → Theme does NOT render, :root fallback CSS is used ✅
  4. Upgrade to 6.7.4+ → Theme now renders, overrides :root CSS variables ❌

Suggested fix

Either:

Option A — Document it as a breaking change in the CHANGELOG for 6.7.4, with a migration guide for sites that didn't use withSiteGlobals():

If your Theme section emits CSS variables, ensure the format matches what your app.css :root block expects (e.g. full oklch(...) vs bare components).

Option B — Add a flag to cmsRouteConfig to opt out of automatic globals resolution:

cmsRouteConfig({ resolveGlobals: false })

Option C — Validate that sections injected via resolveSiteGlobals() emit valid CSS custom property values (at least warn in dev when a <style> block contains malformed values).

Environment

  • @decocms/start: 6.6.1 → 6.22.1 (breaking introduced in 6.7.4)
  • Tailwind v4 + DaisyUI v5
  • cmsRouteConfig used without withSiteGlobals() wrapper

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions