Repository navigation
fix: globalThis-backed CMS state for Vite split modules - #4
Merged
Merged
Conversation
Vite server function code-splitting creates isolated module instances, causing registries (blockData, sectionRegistry, commerceLoaders, etc.) to be empty in server function contexts. Back all shared state with globalThis.__deco so all module instances see the same data. Also changes loadDeferredSection from GET to POST since it sends a request body (component, rawProps, pagePath). Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
5 issues found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/cms/sectionLoaders.ts">
<violation number="1" location="src/cms/sectionLoaders.ts:24">
P2: Move `cacheableSections` to `globalThis` too; split module instances will otherwise bypass the configured SWR cache.</violation>
</file>
<file name="src/cms/loader.ts">
<violation number="1" location="src/cms/loader.ts:97">
P1: This only re-syncs empty local caches, so split-module instances that already loaded blocks can keep serving stale CMS data after another instance calls `setBlocks()`.</violation>
</file>
<file name="src/cms/resolve.ts">
<violation number="1" location="src/cms/resolve.ts:56">
P1: Reading `asyncConfig` from `globalThis` only once leaves earlier split-module copies with stale rendering config.</violation>
<violation number="2" location="src/cms/resolve.ts:233">
P1: Gating initialization on the global flag prevents later split-module copies from applying module-local resolver setup.</violation>
</file>
<file name="src/cms/registry.ts">
<violation number="1" location="src/cms/registry.ts:25">
P1: The split-module fix is incomplete: `resolvedComponents` and `syncComponents` still stay module-local, so preloaded/sync section components can disappear across server chunks.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
… state - loader.ts: compare by reference instead of checking empty (catches stale data) - resolve.ts: read asyncConfig from globalThis on every access, not just init - resolve.ts: simplify ensureInitialized to use globalThis directly - registry.ts: back resolvedComponents and syncComponents with globalThis - sectionLoaders.ts: back cacheableSections with globalThis Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
🎉 This PR is included in version 0.16.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
JonasJesus42
added a commit
that referenced
this pull request
Jun 18, 2026
…#256) "key" was listed as a React-internal prop to skip during schema generation. But unlike "ref" or "$$typeof", React's JSX "key" is a special attribute that never appears as an explicit TypeScript interface property — so filtering it drops legitimate "key" fields from data interfaces. Example breakage: a loader Props with `selectedFacets?: { key: string; value: string }[]` generated a schema with only "value" — the "key" field (e.g. "productClusterIds") was silently lost, blocking CMS editing. Fixes DECO-5296 bug #4. Co-authored-by: Claude Sonnet 4.6 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
Generated with Claude Code
Summary by cubic
Fixes isolated CMS state from Vite server function code-splitting by moving all shared CMS data to
globalThis.__decoand consistently reading from it. Also switches the deferred section loader to POST to send a JSON body.Bug Fixes
globalThis.__deco(blocks+revision with resync, registries/caches, commerce loaders/matchers, async config, init flags) so split modules see the same data.Migration
loadDeferredSectionnow uses POST. If you call it directly, send a JSON body withcomponent,rawProps, andpagePath.Written for commit 51e5a10. Summary will update on new commits.