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 to shouldSkip mechanism.
Solution
As we now have buildData #860, we can store RSC text for "static" RSC, even if the SSR is dynamic.
We use buildData in fs-router, so the similar implementation wouldn't be too difficult for PRD.
Challenges
In DEV, it would be nice if the behavior is identical to PRD, but we need to delete the RSC text cache (hm, where do we store it?) after hot reload.
shouldSkip should be revisited as it's too complicated. (It's a separate issue and more important than this one.)
We may have more types than "static" and "dynamic" in the future, but we can reconsider our design at that time. (Trial-and-error is welcome.)
Background
The two rendering types "static" and "dynamic" are very complicated because there are two aspects RSC and SSR.
This
isStatic
is for RSC: https://github.com/dai-shi/waku/blob/9ca5161cfba93e402641249a494642a912d25795/packages/waku/src/server.ts#L16This `isStatic is for SSR: https://github.com/dai-shi/waku/blob/9ca5161cfba93e402641249a494642a912d25795/packages/waku/src/server.ts#L12
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
#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.)