Proposal to pull the route-component-colocation convention we shipped in muxa-io into stack. Decide accept/refuse while working in this repo — this issue just records the context.
What it is
A route file exports only Route. Each route becomes its own directory colocating route.tsx + -components/<name>.tsx + <feature>.test.tsx (route-only hooks in -hooks/, per ADR 0002). This restores TanStack Start's automatic code-splitting, which a named component export silently defeats — the route's render code stays in the eager route bundle and the dev server logs a code-split warning per route.
Why it matters for stack specifically
Stack already carries generalized ADR 0002 + 0003, but its placeholder routes currently demonstrate the exact anti-pattern 0005 fixes:
apps/web/src/routes/_app.home.tsx and apps/web/src/routes/index.tsx each set component: Home / component: Landing and export function Home() / export function Landing() — the named export exists only so home.test.tsx can import the component. That defeats code-splitting.
So a template that ships these teaches the anti-pattern by example.
Where it was done (muxa-io)
Rough scope if accepted
- Add generalized
docs/adr/0005-route-component-colocation.md (strip muxa-specific route names — Home/Backlog/Library/VideoDetail//v/$id).
- Append the "Update (ADR 0005)" note to
docs/adr/0002.
- Refactor the 2 placeholder routes to the colocated layout:
_app.home.tsx → _app/home/{route.tsx (exports only Route), -components/home.tsx, home.test.tsx}; keep landing's index.tsx flat with -components/landing.tsx.
vite.config.ts: tanstackStart({ router: { routeFileIgnorePattern: ".*\\.test\\.tsx$" } }) to keep colocated *.test.tsx out of the route tree.
- Regenerate
routeTree.gen.ts.
Stack has only 2 real routes, so the code change is small.
Proposal to pull the route-component-colocation convention we shipped in muxa-io into stack. Decide accept/refuse while working in this repo — this issue just records the context.
What it is
A route file exports only
Route. Each route becomes its own directory colocatingroute.tsx+-components/<name>.tsx+<feature>.test.tsx(route-only hooks in-hooks/, per ADR 0002). This restores TanStack Start's automatic code-splitting, which a namedcomponentexport silently defeats — the route's render code stays in the eager route bundle and the dev server logs a code-split warning per route.Why it matters for stack specifically
Stack already carries generalized ADR 0002 + 0003, but its placeholder routes currently demonstrate the exact anti-pattern 0005 fixes:
apps/web/src/routes/_app.home.tsxandapps/web/src/routes/index.tsxeach setcomponent: Home/component: Landingandexport function Home()/export function Landing()— the named export exists only sohome.test.tsxcan import the component. That defeats code-splitting.So a template that ships these teaches the anti-pattern by example.
Where it was done (muxa-io)
-hooks/, not the sharedroutes/-hooks/): https://github.com/dendotai/muxa-io/blob/dev/docs/adr/0002-route-scoped-hook-colocation.mdRough scope if accepted
docs/adr/0005-route-component-colocation.md(strip muxa-specific route names — Home/Backlog/Library/VideoDetail//v/$id).docs/adr/0002._app.home.tsx→_app/home/{route.tsx (exports only Route), -components/home.tsx, home.test.tsx}; keep landing'sindex.tsxflat with-components/landing.tsx.vite.config.ts:tanstackStart({ router: { routeFileIgnorePattern: ".*\\.test\\.tsx$" } })to keep colocated*.test.tsxout of the route tree.routeTree.gen.ts.Stack has only 2 real routes, so the code change is small.