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
How client hydration works in Astro is, a script is created in order to hydrate a component, and that script is inserted directly inline into a page. The script looks like this:
During the build all of these scripts get bundled together into a single script for the page. However, this requires scanning the generated HTML.
In order to support SSR we want to avoid needing to scan HTML. Instead we should inline the scripts again, using web-compatible URLs and bundle just the entrypoints. Doing so would allow us to get the bundling we need without needing to scan and replace HTML post-render.
Rough Proposal
In 1.0 stop using HTML scanning in the static-site generator.
Discover the entrypoints that need to be bundled within the compiler (this partially happens today)
Create an importmap.json that contains the mapping of the entrypoint keys to their hashed bundled version.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
How client hydration works in Astro is, a script is created in order to hydrate a component, and that script is inserted directly inline into a page. The script looks like this:
In 0.21 we still inline a script like this, but that script then gets turned into an external proxy script that Vite handles. It looks like this:
During the build all of these scripts get bundled together into a single script for the page. However, this requires scanning the generated HTML.
In order to support SSR we want to avoid needing to scan HTML. Instead we should inline the scripts again, using web-compatible URLs and bundle just the entrypoints. Doing so would allow us to get the bundling we need without needing to scan and replace HTML post-render.
Rough Proposal
importmap.json
that contains the mapping of the entrypoint keys to their hashed bundled version.Beta Was this translation helpful? Give feedback.
All reactions