Repository navigation
docs(skill): add server-functions reference, deferred-sections CLS, export-type gotcha - #7
Merged
JonasJesus42 merged 1 commit intoMar 13, 2026
Conversation
There was a problem hiding this comment.
4 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=".cursor/skills/deco-to-tanstack-migration/references/deco-framework/README.md">
<violation number="1" location=".cursor/skills/deco-to-tanstack-migration/references/deco-framework/README.md:134">
P2: This explains the CLS issue using a code path that does not exist here; `DecoPageRenderer` already falls back to a default skeleton when `getSectionOptions` is undefined.</violation>
<violation number="2" location=".cursor/skills/deco-to-tanstack-migration/references/deco-framework/README.md:150">
P3: Drop the `as any` here; `registerSection` already accepts section modules with `loader` and `LoadingFallback`, so the cast just disables type checking in the example.</violation>
</file>
<file name=".cursor/skills/deco-to-tanstack-migration/references/server-functions/README.md">
<violation number="1" location=".cursor/skills/deco-to-tanstack-migration/references/server-functions/README.md:72">
P2: `Promise<any>` should not be documented as the default fix for serializability errors.</violation>
<violation number="2" location=".cursor/skills/deco-to-tanstack-migration/references/server-functions/README.md:118">
P2: The verification command only scans `.tsx` files, so it misses direct VTEX calls in `.ts` hooks and utilities.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| ```bash | ||
| # No direct VTEX API calls from client components | ||
| rg 'vtexcommercestable\.com\.br' src/ --include='*.tsx' |
There was a problem hiding this comment.
P2: The verification command only scans .tsx files, so it misses direct VTEX calls in .ts hooks and utilities.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .cursor/skills/deco-to-tanstack-migration/references/server-functions/README.md, line 118:
<comment>The verification command only scans `.tsx` files, so it misses direct VTEX calls in `.ts` hooks and utilities.</comment>
<file context>
@@ -0,0 +1,120 @@
+
+```bash
+# No direct VTEX API calls from client components
+rg 'vtexcommercestable\.com\.br' src/ --include='*.tsx'
+# Should return ZERO (all calls go through invoke)
+```
</file context>
Suggested change
| rg 'vtexcommercestable\.com\.br' src/ --include='*.tsx' | |
| rg 'vtexcommercestable\.com\.br' src/ --glob '*.{ts,tsx,js,jsx}' |
| // has loadingFallback on the very first render — no null flash. | ||
| registerSection( | ||
| "site/sections/Product/NotFoundChallenge.tsx", | ||
| () => import("./sections/Product/NotFoundChallenge") as any, |
There was a problem hiding this comment.
P3: Drop the as any here; registerSection already accepts section modules with loader and LoadingFallback, so the cast just disables type checking in the example.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .cursor/skills/deco-to-tanstack-migration/references/deco-framework/README.md, line 150:
<comment>Drop the `as any` here; `registerSection` already accepts section modules with `loader` and `LoadingFallback`, so the cast just disables type checking in the example.</comment>
<file context>
@@ -126,3 +126,49 @@ grep -r '@deco/deco' src/ --include='*.ts' --include='*.tsx'
+// has loadingFallback on the very first render — no null flash.
+registerSection(
+ "site/sections/Product/NotFoundChallenge.tsx",
+ () => import("./sections/Product/NotFoundChallenge") as any,
+ { loadingFallback: PDPSkeleton },
+);
</file context>
…x, export-type gotcha - New references/server-functions/README.md: createServerFn pattern using @decocms/apps actions, .inputValidator() requirement, Promise<any> for ValidateSerializable bypass, stripping non-serializable props - deco-framework/README.md: add Deferred Sections and CLS Prevention section — registerSection with loadingFallback pre-populated to prevent null flash on DeferredSectionWrapper first render - platform-hooks/README.md: fix .validator() -> .inputValidator() (deprecated API), update server functions pattern to use @decocms/apps invoke + src/server/invoke.ts - gotchas.md: add #19 — export type { X } re-export does not scope X in same file - SKILL.md: add server-functions to reference index and decision tree Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
JonasJesus42
force-pushed
the
JonasJesus42/skill-server-functions-cls-gotchas
branch
from
March 13, 2026 01:26
d221bb0 to
63b9262
Compare
|
🎉 This PR is included in version 0.21.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This was referenced May 1, 2026
vibe-dex
added a commit
that referenced
this pull request
May 1, 2026
…checklist (#109) Two stale areas in the deco-to-tanstack-migration skill, plus one brand-new reference distilling battle-tested cleanup patterns. ## Changes ### `templates/vite-config.md` — drop ~80 lines of stub duplication The old template inlined the entire `deco-server-only-stubs` plugin (react-dom/server, node:async_hooks, node:stream, node:stream/web, tanstack-head-scripts) — ~60 lines that exactly mirror what `@decocms/start/vite`'s `decoVitePlugin()` already does. The new template uses `decoVitePlugin()` and adds the production-grade boilerplate that real sites actually need (and that the old version omitted): VTEX dev proxy, CSP frame-ancestors header, build sourcemap, PLUGIN_WARNING filter, react-compiler config, `pure: ["console.log"]`, and the full `dedupe` list including `@decocms/start` + `@decocms/apps`. ### `references/vite-config/README.md` — fix "minimal" config that was broken The "post-migration minimal config" was missing `decoVitePlugin()` entirely. Without it, the client bundle crashes on transitively imported server modules. Added the plugin + the minimum dedupe list, and cross-referenced the full template. ### `references/post-migration-cleanup.md` — NEW Dedicated reference distilling the cleanup work that surfaces on every real migration: 1. Detect + delete unused `src/lib/*` shims (with a copy-paste detection script). Real-world data: baggagio-tanstack had 11 generated shims and 0 actual users; casaevideo had 11 generated and 1 used. 2. Drop the `site-manual-chunks` and `deco-stub-meta-gen` inline plugins that are now framework-provided in `@decocms/start >= 2.5.0`. 3. Drop the `runtime.ts` `invoke` shim — `@decocms/start/sdk` exports both `invoke` (singleton) and `createAppInvoke` (typed factory). 4. Drop site-local `withSiteGlobals` workaround — framework helper is now opt-in and tested. 5. Verify VTEX util imports point direct at `@decocms/apps/vtex/...`, not at dead `~/lib/vtex-*` shims (the migration script's stale `phase-cleanup.rewriteVtexUtilImports` was silently regressing them). 6. Search for orphan `TODO: move into framework` comments and either migrate, file an issue, or delete. Plus a verification checklist. ## Why now Validated in this session against three reference sites (casaevideo-storefront, baggagio-tanstack, casaevideo). Each cleanup step has a corresponding shipped or in-flight PR (#103/#106/#107/#108 on framework, #5/#6/#7 on baggagio-tanstack), so the checklist isn't speculative. ## Scope discipline This PR only edits skill content; no source/runtime changes. Both `.agents/skills/` and `.cursor/skills/` copies stay in sync. Made-with: Cursor
4 tasks
vibe-dex
added a commit
that referenced
this pull request
May 1, 2026
…ly imported (#110) * feat(migrate): generate src/lib/* shims lazily — only the ones actually imported The migration script used to write all 11 `src/lib/*.ts` shim files eagerly during `phase-scaffold`, regardless of whether the migrated codebase imported any of them. In practice, most sites end up importing zero shims — apps-start exports direct equivalents for nearly every VTEX utility (verified against baggagio in #7: 0 shims used out of 11 generated, ~235 LOC of dead code). This PR makes generation lazy: - `templates/lib-utils.ts`: Replaces the `generateLibUtils(ctx)` function (eager, returns all files) with a `LIB_TEMPLATES` registry (`{ "src/lib/<name>.ts": "...content..." }`) and a `selectImportedLibTemplates(specifiers)` filter helper. - `phase-scaffold.ts`: No longer calls `generateLibUtils`. Comment explains the lazy strategy and points at where the new pass runs. - `phase-cleanup.ts`: New final step `writeImportedLibShims(ctx)` that walks `src/**/*.{ts,tsx}` after every other transform settles, scans for `from "~/lib/<name>"` imports, and writes only the corresponding templates. Logs a warning if a `~/lib/X` import has no registered template. Why end-of-cleanup, not end-of-transform: phase-cleanup itself adds `from "~/lib/vtex-segment"` etc. via inline-stub hoisting (line ~1092 of the old file). Running the lazy writer at the very end of cleanup captures those late additions. Concrete impact: - Sites with zero `~/lib/*` imports (all clean migrations going forward) will have NO `src/lib/` directory at all. - Sites with a few imports get just those shims — not all 11. - baggagio-tanstack#7 type cleanups become unnecessary on future migrations. Verification: - `npm run build` exits 0 - vitest: 104/104 pass - Manual trace: import rewrite rules `apps/utils/{fetch,http,graphql}` → `~/lib/{fetch-utils,http-utils,graphql-utils}` are all matched by the new scan regex `/from\s+["']~\/lib\/([^"']+?)(?:\.ts)?["']/g` - Inline-stub hoisting paths (`from "~/lib/vtex-segment"`, `from "~/lib/vtex-intelligent-search"`, `from "~/lib/fetch-utils"`) also matched. Follow-up not in this PR: - Add vitest config for `scripts/` so we can write regression tests for this scan-and-write pipeline (instead of relying on manual smoke runs). Made-with: Cursor * test(migrate): add unit + integration tests for lazy shim generation Adds vitest coverage for the lazy shim pipeline introduced in this PR. The first round of code review caught zero bugs because there were zero tests; the new integration test caught one immediately (see "dry-run mode" test below). Changes: - `vitest.config.ts`: includes `scripts/**/*.test.ts` and uses `environmentMatchGlobs` so script tests run in node env (filesystem) while src tests stay in jsdom (React). - `scripts/migrate/templates/lib-utils.test.ts` (10 unit tests): - `LIB_TEMPLATES` registry shape (paths, non-empty contents, uniqueness). - `selectImportedLibTemplates`: empty/single/multiple/unknown specifier handling, no mutation, full coverage of every well-known migration target the writer might emit. - `scripts/migrate/phase-cleanup.test.ts` (7 integration tests against a real tmp directory): - Writes nothing when no `~/lib` imports are present. - Writes only the matching shim files for found imports. - Dry-run mode writes nothing (caught a real bug — the original impl was creating an empty `src/lib/` dir before the dry-run skip; fixed in this commit). - Strips trailing `.ts` from import specifiers. - Ignores imports inside the lib dir itself (no self-amplification). - Scans `.tsx` files too. - No-op when `src/` does not exist. - `phase-cleanup.ts`: - Bug fix surfaced by the dry-run test: gate `mkdirSync` on `!ctx.dryRun` so a stale empty directory isn't left on disk. - Export `writeImportedLibShims` for unit testability. Verification: - `npx vitest run scripts/` → 17 tests, all pass. - `npx vitest run` → 121 tests, all pass (was 104, now 17 more). - `npm run build` → exit 0. Total cumulative impact of #110: - +297 / -22 (was +155 / -22 before tests added) - One pre-existing bug found and fixed thanks to writing the test. Made-with: Cursor
guitavano
added a commit
that referenced
this pull request
Nov 17, 2026
…anStack Start, esbuild) (#832) Closes the open Dependabot alerts in one PR, with the lockfile. The Dependabot PRs (#811, #828, #747) only touch `package.json`, so they all fail `bun install --frozen-lockfile` in CI. | Package | From | To | Alerts | |---|---|---|---| | `react-server-dom-webpack` (tanstack-rsc-smoke) | 19.2.7 | 19.2.9 | #19, critical: RSC RCE, GHSA-xqc2-xf4c-x3h3 | | `react` / `react-dom` (all pinned workspaces) | 19.2.7 | 19.2.9 | peer floor of the above | | `next` (nextjs, compat-v7, nextjs-binding-smoke) | 16.3.8 | 16.4.6 | #10–12, #14, #15, #17, #18, #20–22 | | `@tanstack/react-start` (tanstack, compat-v7, smokes) | 1.168.58 | 1.168.61 | #2–4, #7, #9 | | `@tanstack/react-router` | 1.170.39 | 1.170.42 | the version react-start 1.168.61 pins, so it stays a single copy | | `esbuild` (blocks, tanstack, compat-v7) | ^0.27.3 | ^0.28.2 | #5, #6, #8 (low) | `bun.lock` was regenerated with bun 1.3.5 (the `packageManager`). React dedupes to a single 19.2.9 at the root, with no nested copies. Vite still has its own transitive `[email protected]` (its own range); that is outside our manifests. Supersedes #811, #828 and #747. ### Verified locally (bun 1.3.5, node 24) - `bun install --frozen-lockfile` ✅ - `bun run typecheck` ✅ · `bun run lint` ✅ - `bun x vitest run`: 3388 passed, 0 failed ✅ (includes `tests/release.test.ts`) - `examples/tanstack-worker-smoke`: build + smoke ✅ - `examples/nextjs-binding-smoke`: build + smoke ✅ - `examples/tanstack-rsc-smoke`: build + typecheck ✅ 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Bumps several dependencies to clear open Dependabot security alerts, including a critical RCE in `react-server-dom-webpack` (GHSA-xqc2-xf4c-x3h3). The lockfile was regenerated so `bun install --frozen-lockfile` passes — React dedupes to a single 19.2.9 copy. **Dependencies** - `react`, `react-dom`, and `react-server-dom-webpack` 19.2.7 → 19.2.9 - `next` 16.3.8 → 16.4.6 - `@tanstack/react-start` 1.168.58 → 1.168.61, with `@tanstack/react-router` 1.170.42 - `esbuild` ^0.27.3 → ^0.28.2; Vite's own transitive `[email protected]` is untouched - Typecheck, lint, the full test suite (3388 passed), and the Next.js and TanStack smoke builds all pass <sup>Written for commit 123acc8. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/decocms/blocks/pull/832?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/decocms/blocks/832?returnTo=https%3A%2F%2Fgithub.com%2Fdecocms%2Fblocks%2Fpull%2F832&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. --> Co-authored-by: Claude Opus 5.5 <[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
Learnings extracted from the casaevideo-storefront TanStack migration session.
New: references/server-functions/README.md
Full pattern for createServerFn wrapping @decocms/apps VTEX actions:
Updated: deco-framework/README.md
New section on Deferred Sections and CLS Prevention: when a CMS page wraps a section in Lazy.tsx, DeferredSectionWrapper renders null on first paint causing layout shift. Fix: registerSection(key, loader, { loadingFallback }) pre-populates sectionOptions synchronously.
Updated: platform-hooks/README.md
Updated: gotchas.md
Updated: SKILL.md
Generated with Claude Code
Summary by cubic
Adds a server-functions reference showing a typed
createServerFnwrapper over@decocms/appsVTEX actions, and documents a CLS-safe setup for deferred sections. Also updates platform hook examples, expands the SKILL guide, and adds a TypeScript re-export gotcha.references/server-functionsguide: singlesrc/server/invoke.tswrapper usingcreateServerFnfrom@tanstack/react-startaround@decocms/appsactions (use.inputValidator(), returnPromise<any>, and strip non-serializable props).registerSection(..., { loadingFallback })so the skeleton renders on first paint.invokepattern backed bysrc/server/invoke.tsand.inputValidator()(replaces deprecated.validator()).export type { X }scoping gotcha.Written for commit 63b9262. Summary will update on new commits.