-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
(router) improve static pages #885
Comments
@tylerlaws0n here's the first write-up. |
@dai-shi Are you suggesting that the static page with a dynamic layout should always become implicitly dynamic to account for the dynamic layout's ability to change? I think it might help to talk through a scenario where you'd want this mixing of build modes between the layout and the page itself. Without coming into this problem yet myself, I would think that these two things should simply not be mixed. I feel like if you dynamically update the static page, that is unexpected behavior. And if you statically render a dynamic layout, that is also unexpected. I am probably missing something though since I don't have a full picture on what the idea is, so if you could correct me where I am missing info that would be helpful. Thanks! |
I'm not suggesting it in this issue, but it's how it works as of now.
What about static layout and dynamic page? Feels like a common case.
No problem! It's understandable. (Actually, by going through this task with you, I'm expecting to discuss some other (not implemented yet) features with you in the future. |
This use case makes a lot of sense and definitely should be supported. With my last message, I was focused on "static page + dynamic layout" which still feels like an error case to me.
Sounds good, looking forward to that! |
static layout + dynamic page is more common, but dynamic layout+ static page is also possible. I don't think we need to prohibit it if we can support it easily. |
@dai-shi do any of our examples currently show the dynamic layout + static page pattern currently? If no, I can start this issue by just spinning up an example for us to reference and test. |
I'm not sure, but maybe not. Yeah, sounds good. |
you can see the time change as navigating the site which shows that the layout is indeed dynamic The rest of the home page stays unchanged and can be cached Example for dai-shi#885
Added the example for now... I'll follow up with improvements separately if that's ok. This helps to test and see the current behavior though. |
edit: I see now that you suggested this in the solution section: As we now have buildData #860, we can store RSC text for "static" RSC, even if the SSR is dynamic. |
I understand the problem and proposed fix now though. I can take this on alongside work on the query params. |
you can see the time change as navigating the site which shows that the layout is indeed dynamic The rest of the home page stays unchanged and can be cached Example for #885 --------- Co-authored-by: Tyler <[email protected]>
@dai-shi Correct me here if I am misunderstanding, but this code: https://github.com/dai-shi/waku/blob/main/packages/waku/src/router/define-router.ts#L242-L252 and similar snippets in both So the improvement for this issue is to:
Questions:
|
1&2 are the current behavior, right?
The full path is cached, already in a file. so we don't need it in
It's HOWEVER:
I would like to change this 1:1 relationship. It's one of the reasons behind |
We would like to redesign `defineRouter`. This is why we have `unstable_` prefix. #885 (comment) > similar snippets in both `defineRouter` and `createPages` are currently assuming 1:1 relationship from path to component id. That's the exactly one of the reasons. It shouldn't be 1:1. It can be anything, and it can cache each. This will change waku/router/client too including "shouldSkipList". Starting with a rough idea.
Background
The two rendering types "static" and "dynamic" are very complicated because there are two aspects RSC and SSR.
This
isStatic
is for RSC:waku/packages/waku/src/server.ts
Line 16 in 9ca5161
This `isStatic is for SSR:
waku/packages/waku/src/server.ts
Line 12 in 9ca5161
Currently, isStatic for SSR will be true if all of isStatic for RSC are true.
Expectation
If we mark a "page" or a "layout" to be "static", our expectation is that the rendering only happens just once. (For PRD, only at the build time, and for DEV only the first time and again after hot reload.)
Actual problem
If we mix "static" and "dynamic" for RSC, the page for SSR will be "dynamic" which is expected, but then RSC's "static" isn't truly static.
In the
01_template
, modify _layout.tsx to be "dynamic", while keeping "static" in pages.tsx. Now, HomePage in page.tsx renders more than expected. In addition to the build time, it renders on production. It only behaves like "static" on client routing thanks toshouldSkip
mechanism.Solution
buildData
feat(build): introduce buildData in platformObject #860, we can store RSC text for "static" RSC, even if the SSR is dynamic.buildData
in fs-router, so the similar implementation wouldn't be too difficult for PRD.Challenges
shouldSkip
should be revisited as it's too complicated. (It's a separate issue and more important than this one.)The text was updated successfully, but these errors were encountered: