Repository navigation
TanStack: Support pathless layout routes - #35197
krish-mittal1 wants to merge 2 commits into
Conversation
pathless layouts like _auth.tsx were getting a "/" path from the createFileRoute mock, so the layout and its children dropped out of route matching. keep them id-only like the real generator does, and preserve the id when cloning the tree. closes storybookjs#35193
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughAdds an ChangesPathless layout route handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
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. Comment |
|
Hi @Sidnioulz, this PR addresses #35193 with focused unit coverage. It’s ready for review whenever you have time. Thanks! |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 18 | 18 | 0 |
| Self size | 1.29 MB | 1.31 MB | 🚨 +20 KB 🚨 |
| Dependency size | 9.28 MB | 9.28 MB | 🎉 -74 B 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/builder-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 186 | 186 | 0 |
| Self size | 79 KB | 79 KB | 🎉 -290 B 🎉 |
| Dependency size | 35.73 MB | 36.13 MB | 🚨 +391 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 73 | 73 | 0 |
| Self size | 21.39 MB | 22.16 MB | 🚨 +772 KB 🚨 |
| Dependency size | 36.75 MB | 31.22 MB | 🎉 -5.53 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/angular
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 185 | 185 | 0 |
| Self size | 160 KB | 160 KB | 🚨 +289 B 🚨 |
| Dependency size | 30.13 MB | 30.52 MB | 🚨 +391 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/angular-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 36 | 36 | 0 |
| Self size | 33.41 MB | 33.40 MB | 🎉 -3 KB 🎉 |
| Dependency size | 21.34 MB | 15.80 MB | 🎉 -5.54 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/ember
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 185 | 185 | 0 |
| Self size | 13 KB | 15 KB | 🚨 +2 KB 🚨 |
| Dependency size | 31.08 MB | 31.47 MB | 🚨 +391 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 531 | 531 | 0 |
| Self size | 641 KB | 663 KB | 🚨 +21 KB 🚨 |
| Dependency size | 62.41 MB | 62.84 MB | 🚨 +438 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 94 | 93 | 🎉 -1 🎉 |
| Self size | 1.42 MB | 1.39 MB | 🎉 -26 KB 🎉 |
| Dependency size | 23.91 MB | 23.88 MB | 🎉 -24 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-native-web-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 125 | 122 | 🎉 -3 🎉 |
| Self size | 29 KB | 30 KB | 🚨 +922 B 🚨 |
| Dependency size | 25.90 MB | 24.95 MB | 🎉 -944 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 83 | 83 | 0 |
| Self size | 32 KB | 36 KB | 🚨 +4 KB 🚨 |
| Dependency size | 21.22 MB | 21.65 MB | 🚨 +433 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 272 | 272 | 0 |
| Self size | 23 KB | 23 KB | 🚨 +777 B 🚨 |
| Dependency size | 48.19 MB | 48.62 MB | 🚨 +438 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/server-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 198 | 198 | 0 |
| Self size | 15 KB | 16 KB | 🚨 +761 B 🚨 |
| Dependency size | 37.00 MB | 37.39 MB | 🚨 +391 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/svelte-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 20 | 20 | 0 |
| Self size | 54 KB | 56 KB | 🚨 +2 KB 🚨 |
| Dependency size | 26.65 MB | 27.04 MB | 🚨 +385 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/sveltekit
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 21 | 21 | 0 |
| Self size | 56 KB | 56 KB | 🚨 +58 B 🚨 |
| Dependency size | 26.71 MB | 27.09 MB | 🚨 +387 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/tanstack-react
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 84 | 84 | 0 |
| Self size | 113 KB | 110 KB | 🎉 -3 KB 🎉 |
| Dependency size | 21.25 MB | 21.69 MB | 🚨 +436 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/vue3-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 103 | 102 | 🎉 -1 🎉 |
| Self size | 34 KB | 36 KB | 🚨 +2 KB 🚨 |
| Dependency size | 43.11 MB | 43.04 MB | 🎉 -74 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 205 | 205 | 0 |
| Self size | 827 KB | 827 KB | 🎉 -32 B 🎉 |
| Dependency size | 91.60 MB | 86.84 MB | 🎉 -4.76 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 198 | 198 | 0 |
| Self size | 32 KB | 32 KB | 🎉 -7 B 🎉 |
| Dependency size | 90.08 MB | 85.32 MB | 🎉 -4.76 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 74 | 74 | 0 |
| Self size | 1.09 MB | 1.09 MB | 🎉 -831 B 🎉 |
| Dependency size | 58.14 MB | 53.38 MB | 🎉 -4.76 MB 🎉 |
| Bundle Size Analyzer | node | node |
@storybook/preset-react-webpack
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 161 | 161 | 0 |
| Self size | 19 KB | 19 KB | 🎉 -137 B 🎉 |
| Dependency size | 32.70 MB | 33.09 MB | 🚨 +391 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 59 | 59 | 0 |
| Self size | 1.48 MB | 1.52 MB | 🚨 +47 KB 🚨 |
| Dependency size | 12.30 MB | 12.30 MB | 🚨 +46 B 🚨 |
| Bundle Size Analyzer | Link | Link |
|
#35193 seems like the issue was already solved |
Closes #35193
What I did
Pathless layout routes (file routes whose own segment starts with
_, like_auth.tsx) weren't working in the TanStack framework. The mockedcreateFileRoutesetpath/fullPathon every file route. For normal routes the generated route tree overwritespathwith the correct relative value, but pathless layouts are emitted without apath, so the placeholder/stuck around and turned the layout into an index route at/. The layout and everything nested under it then dropped out of matching, so those stories rendered only the root.Now pathless layouts are built as id-only routes (the same shape the generator emits), and their
idis kept when the tree is duplicated since there's nopathto derive identity from. Normal routes are untouched.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Added a
createFileRouteunit test checking that a pathless layout route (/_auth) stays id-only withpath/fullPathundefined. The existing cases (groups,_layout/page) are unchanged.Manual testing
yarn task sandbox --template react-vite/default-ts --start-from auto(orcd code && yarn storybook:ui)._auth→dashboard) throughparameters.tanstack.router.route.nextonly the root shows up and the layout + child are missing.Documentation
No docs changes — this just restores expected behavior for an existing feature.
Summary by CodeRabbit
Improvements
Tests