You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let extension hooks that only change stylesheets keep Vue hydration (rethink how hooks declare their effects) #804
On a Vue page, Citry turns hydration off when any extension defines on_dependencies, on_js_loaded, prepare_browser_render or browser_plugin, or when a component overrides on_dependencies (_hydration_page_reason in packages/py/citry/citry/_vue/serialization.py). Vue then replaces the server HTML instead of adopting it. The page works, but it renders twice in the browser and may flicker. The docs for extensions do not mention this cost.
The rule exists because such a hook can add browser behavior the server renderer does not know about, for example a Vue plugin installed through early_scripts, so adopting the server HTML could mismatch. It is a correctness rule: the CSP, security_javascript and nonce checks run separately.
The cost shows up for hooks that only change stylesheets, such as compiling SCSS. citry-django needs this to compile SCSS for components rendered as separate Vue apps on a Django page.
The obvious fix is an opt-in flag on Extension ("this hook only changes stylesheets"). Before adding it, rethink how extensions declare what their hooks do: more per-hook flags is the wrong direction. Options to weigh:
let Citry see what a hook changed (compare scripts before and after the hook) instead of trusting a declaration;
split stylesheet changes into their own hook that never affects hydration;
a single structured declaration of a hook's effects instead of separate flags.
Either way, document the hydration cost on the extensions page.
Activity