-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
defineRoute: compile-time checks #11730
Conversation
|
let route = getRoute(ctx.reactRouterConfig, id); | ||
if (!route) return defineRoute.assertNotImported(code); | ||
|
||
defineRoute.transform(code); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the next PR, transform
will remove serverLoader
+ serverAction
from the AST and then return the modified code to this Vite transform. In this PR, its just an assertion/compile-time check function
8e51540
to
07fdc1d
Compare
// TODO: passing test for object literal | ||
// TODO: passing test for `defineRoute` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add these tests in a follow-up PR since passing tests will require updates to how the route manifest is created.
if (id.endsWith(BUILD_CLIENT_ROUTE_QUERY_STRING)) return; | ||
if (!code.includes("defineRoute")) return; // temporary back compat | ||
|
||
if (options?.ssr) return; // TODO: why is `ctx` undefined otherwise? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markdalgleish I guess we never ran into this before just out of luck, but seems like ctx
is undefined
when ssr
is set to true
which causes a bunch of issues. Seems surprising to me, so might be missing something
not a blocker here since we only need to check these things once during client build
05391a4
to
6272e89
Compare
6272e89
to
b2998db
Compare
No description provided.