fix(create): generate minimal scaffolding when declining demo/example pages #429
main fromrefs/pull/429/head·opened For #422
Pass includeExamples to the EJS template context and conditionally render minimal output (no Header, Footer, ThemeToggle, theme system, or styled pages) for both React and Solid frameworks when the user selects "No" for demo/example pages.
Summary by CodeRabbit#
New Features
- Projects can now be generated as either a minimal starter or a full starter with example components, sample routes, and richer layout and styling options for React and Solid projects.
Tests
- Added test coverage for the new template-context behavior, ensuring the minimal vs full template selection and skipped/generated files behave as expected.
- 1
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/create/tests/template-context.test.ts (1)
316-376: Add framework-level fixture assertions for minimal scaffold output.This suite validates context plumbing and
ignoreFile()control flow, but it does not yet verify the user-facing contract (e.g., actual omission of React/SolidHeader,Footer,ThemeToggle, and/aboutfrom generated scaffolds). Adding one fixture-style generation test per framework would reduce regression risk.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/create/tests/template-context.test.ts` around lines 316 - 376, The tests exercise includeExamples and ignoreFile() logic but lack higher-level fixture assertions that verify generated scaffolds actually omit user-facing pieces (e.g., React/Solid Header, Footer, ThemeToggle, and /about); add one integration-style test per framework that uses createMemoryEnvironment() and createTemplateFile() to generate a minimal scaffold with includeExamples: false and then assert output.files does not contain the framework-specific files/components (e.g., verify '/about', 'Header', 'Footer', 'ThemeToggle' module paths are absent) to catch regressions in template plumbing and ignoreFile() usage.🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed. Inline comments: In `@packages/create/src/frameworks/solid/project/base/src/routes/__root.tsx.ejs`: - Around line 47-59: The HeadContent component is currently rendered inside <body> causing hydration and meta tag issues; move the <HeadContent /> render into the <head> block (near HydrationScript) so head-related tags are injected in the document head; update the template around HydrationScript and ensure any layout integrations loop (the integrations.filter(i => i.type === 'layout') insertion) remains in the body/Suspense area while HeadContent is relocated to the head section. --- Nitpick comments: In `@packages/create/tests/template-context.test.ts`: - Around line 316-376: The tests exercise includeExamples and ignoreFile() logic but lack higher-level fixture assertions that verify generated scaffolds actually omit user-facing pieces (e.g., React/Solid Header, Footer, ThemeToggle, and /about); add one integration-style test per framework that uses createMemoryEnvironment() and createTemplateFile() to generate a minimal scaffold with includeExamples: false and then assert output.files does not contain the framework-specific files/components (e.g., verify '/about', 'Header', 'Footer', 'ThemeToggle' module paths are absent) to catch regressions in template plumbing and ignoreFile() usage.🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
817d9635-338b-4052-9251-82078c2483c4📥 Commits
Reviewing files that changed from the base of the PR and between 31ae444503bbae7add4a9133411cd3f3f007cad3 and cc22c9c16c7afb8320e40a56c6cbb4e5399bcc82.
📒 Files selected for processing (14)
packages/create/src/frameworks/react/project/base/src/components/Footer.tsx.ejspackages/create/src/frameworks/react/project/base/src/components/Header.tsx.ejspackages/create/src/frameworks/react/project/base/src/components/ThemeToggle.tsx.ejspackages/create/src/frameworks/react/project/base/src/routes/__root.tsx.ejspackages/create/src/frameworks/react/project/base/src/routes/about.tsx.ejspackages/create/src/frameworks/react/project/base/src/routes/index.tsx.ejspackages/create/src/frameworks/react/project/base/src/styles.css.ejspackages/create/src/frameworks/solid/project/base/src/components/Header.tsx.ejspackages/create/src/frameworks/solid/project/base/src/routes/__root.tsx.ejspackages/create/src/frameworks/solid/project/base/src/routes/about.tsx.ejspackages/create/src/frameworks/solid/project/base/src/routes/index.tsx.ejspackages/create/src/frameworks/solid/project/base/src/styles.css.ejspackages/create/src/template-file.tspackages/create/tests/template-context.test.ts
@@ -18,0 +39,21 @@39+ links: [{ rel: "stylesheet", href: styleCss }],40+ }),41+ shellComponent: RootComponent,42+})43+44+function RootComponent() {45+ return (46+ <html>47+ <head>48+ <HydrationScript />49+ </head>50+ <body>51+ <HeadContent />52+ <Suspense>53+ <Outlet />54+ <TanStackRouterDevtools />55+ <% for(const integration of integrations.filter(i => i.type === 'layout')) { %>56+ <<%= integration.jsName %> />57+ <% } %>58+ </Suspense>59+ <Scripts />⚠️ Potential issue | 🟠 Major
🧩 Analysis chain
🌐 Web query:
For TanStack Router with Solid, when a root shell returns <html><head><body>, should <HeadContent /> be rendered inside <head>? Does placing it in <body> causehead()meta/link tags to be emitted there?💡 Result:
Yes, for TanStack Router with Solid, when the root shell returns , the component should be rendered inside the tag. Official documentation explicitly shows this placement in the root route component: tsx import { HeadContent } from '@tanstack/solid-router' export const Route = createRootRoute({ component: => ( ), }) The docs state: "The component is required to render the head, title, meta, link, and head-related script tags of a document. It should be rendered either in the tag of your root layout or as high up in the component tree as possible." Placing in causes issues. HeadContent uses portals internally to inject content into , but incorrect placement leads to problems like CSS reloads on navigation, hydration mismatches in SSR, and client navigation failures for meta tags. Issues report CSS refetching (
#6601), hydration stuck on loading (#6824resolved by moving to ), and fixes required proper placement for client-side updates (#3616). Thus, head meta/link tags are properly emitted/managed only when is in ; body placement emits them incorrectly or causes dysfunctional behavior.Citations:
- 1: https://tanstack.com/router/latest/docs/guide/document-head-management
- 2: https://github.com/TanStack/router/issues/6824
- 3: https://github.com/TanStack/router/issues/6601
Move
HeadContentinto<head>.The
<HeadContent />component must be rendered inside the<head>tag, not<body>. Per TanStack Router's official documentation,HeadContentis responsible for injecting head-related content (links, meta, title tags) and should be placed in<head>or as high in the component tree as possible. Placing it in<body>causes CSS reloads on navigation, hydration mismatches during SSR, and client-side navigation failures for meta tags (confirmed in TanStack Router issues#6601,#6824,#3616).Suggested fix
function RootComponent() { return ( <html> <head> <HydrationScript /> + <HeadContent /> </head> <body> - <HeadContent /> <Suspense> <Outlet /> <TanStackRouterDevtools />📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
<head> <HydrationScript /> <HeadContent /> </head> <body> <Suspense> <Outlet /> <TanStackRouterDevtools /> <% for(const integration of integrations.filter(i => i.type === 'layout')) { %> <<%= integration.jsName %> /> <% } %> </Suspense> <Scripts />🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/create/src/frameworks/solid/project/base/src/routes/__root.tsx.ejs` around lines 47 - 59, The HeadContent component is currently rendered inside <body> causing hydration and meta tag issues; move the <HeadContent /> render into the <head> block (near HydrationScript) so head-related tags are injected in the document head; update the template around HydrationScript and ensure any layout integrations loop (the integrations.filter(i => i.type === 'layout') insertion) remains in the body/Suspense area while HeadContent is relocated to the head section.✅ Addressed in commit 7f2732f
wyMinLwin(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
c21771bb-c0b1-4af9-bd68-d546d2627db5📥 Commits
Reviewing files that changed from the base of the PR and between cc22c9c16c7afb8320e40a56c6cbb4e5399bcc82 and 7f2732f7cc6fb242520418e0e96f3a562faa1787.
📒 Files selected for processing (1)
packages/create/src/frameworks/solid/project/base/src/routes/__root.tsx.ejs🚧 Files skipped from review as they are similar to previous changes (1)
📝 Walkthrough
Walkthrough#
Adds an
includeExamplestemplate-context flag and branches in EJS templates to either emit minimal/stub assets or full example code across React and Solid starter files; tests and template rendering now respect this flag.Changes#
packages/create/src/frameworks/react/project/base/src/components/Footer.tsx.ejs,packages/create/src/frameworks/react/project/base/src/components/Header.tsx.ejs,packages/create/src/frameworks/react/project/base/src/components/ThemeToggle.tsx.ejsignoreFile()and return whenincludeExamplesis false, preventing those component files from being generated.packages/create/src/frameworks/react/project/base/src/routes/__root.tsx.ejs,packages/create/src/frameworks/react/project/base/src/routes/about.tsx.ejs,packages/create/src/frameworks/react/project/base/src/routes/index.tsx.ejs__root.tsx.ejs: added!includeExamplesbranch defining a full root route (context types, shellComponent, head/beforeLoad, providers, devtools).about.tsx.ejs: added guard to skip file.index.tsx.ejs: conditional export wiring — uses minimalHomewhen!includeExamples, otherwiseApp.packages/create/src/frameworks/react/project/base/src/styles.css.ejsincludeExamplesis false; retains full stylesheet (typography, theme variables) when true.packages/create/src/frameworks/solid/project/base/src/components/Header.tsx.ejsignoreFile()and returns whenincludeExamplesis false, skipping header generation.packages/create/src/frameworks/solid/project/base/src/routes/__root.tsx.ejs,packages/create/src/frameworks/solid/project/base/src/routes/about.tsx.ejs,packages/create/src/frameworks/solid/project/base/src/routes/index.tsx.ejs__root.tsx.ejs: added!includeExamplesbranch producing a root route with HTML shell, head links, Suspense/HydrationScript, add-on init and devtools.about.tsx.ejs: added guard to skip file.index.tsx.ejs: conditional route usesHomewhen!includeExamples, otherwiseApp.packages/create/src/frameworks/solid/project/base/src/styles.css.ejsincludeExamplesis false; full stylesheet preserved when true.packages/create/src/template-file.tstemplateValues.includeExamplesderived fromoptions.includeExamples(defaults totrue) and passed into EJS render context.packages/create/tests/template-context.test.tsincludeExamplesdefaults totrue, respects explicitfalse, and thatignoreFile()behavior skips generation of example files whenincludeExamplesis false.Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~45 minutes
Poem#
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (2 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
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