feat(router-generator): support higher-order wrappers around createFileRoute#7766
feat(router-generator): support higher-order wrappers around createFileRoute#7766dhleong wants to merge 1 commit into
Conversation
…leRoute
The route-file transform previously required the exported `Route` binding
to be exactly `createFileRoute('/path')({...})`, so a route wrapped by a
higher-order handler (e.g. `wrap('x')(createFileRoute('/path')({...}))`)
was silently left untouched — no route-id injection, no import management.
Recursively locate the single nested `createFileRoute(path)(options)` call
within the exported `Route` init, regardless of any wrapping calls. The
wrapper stays opaque to the generator; only the inner constructor call is
rewritten. Malformed wrapped routes now surface the same helpful error.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe route-export analyzer in transform.ts now recursively searches wrapper expressions for nested createFileRoute/createLazyFileRoute calls instead of requiring direct initialization. New helper functions replace the prior direct-call detection, and new tests validate wrapped route id injection, lazy swapping, multiple wrappers, and error cases. ChangesHigher-order Route Wrapper Support
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Transform as transform()
participant Finder as findExportedRouteCalls
participant Walker as findRouteConstructorInits
participant Checker as containsRouteConstructorCall
Transform->>Finder: analyze exported binding initializer
Finder->>Walker: traverse expression tree for route constructor inits
Walker-->>Finder: matched inits (createFileRoute/createLazyFileRoute)
alt no inits found
Finder->>Checker: check for any constructor call in tree
Checker-->>Finder: hasMalformedRouteCall or unsupported
end
Finder-->>Transform: calls list or error state
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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. Comment |
The route-file transform previously required the exported
Routebinding to be exactlycreateFileRoute('/path')({...}), so a route wrapped by a higher-order handler (e.g.wrap('x')(createFileRoute('/path')({...}))) was silently left untouched — no route-id injection, no import management.This change will recursively locate the single nested
createFileRoute(path)(options)call within the exportedRouteinit, regardless of any wrapping calls. The wrapper stays opaque to the generator; only the inner constructor call is rewritten. Malformed wrapped routes now surface the same helpful error.This is proposed as a first step toward unblocking #7619
Summary by CodeRabbit
New Features
Bug Fixes