fix(build): emit before-hydration chunk for client environment#15904
Merged
matthewp merged 3 commits intowithastro:mainfrom Mar 13, 2026
Merged
fix(build): emit before-hydration chunk for client environment#15904matthewp merged 3 commits intowithastro:mainfrom
matthewp merged 3 commits intowithastro:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 8eca66b The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
jlukic
added a commit
to Semantic-Org/Semantic-Next
that referenced
this pull request
Mar 13, 2026
This was referenced Mar 13, 2026
Merged
dadezzz
pushed a commit
to dadezzz/ice-notes
that referenced
this pull request
Mar 20, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [@astrojs/check](https://github.com/withastro/astro/tree/main/packages/language-tools/astro-check) ([source](https://github.com/withastro/astro/tree/HEAD/packages/language-tools/astro-check)) | [`0.9.7` → `0.9.8`](https://renovatebot.com/diffs/npm/@astrojs%2fcheck/0.9.7/0.9.8) |  |  | | [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`6.0.4` → `6.0.5`](https://renovatebot.com/diffs/npm/astro/6.0.4/6.0.5) |  |  | --- ### Release Notes <details> <summary>withastro/astro (@​astrojs/check)</summary> ### [`v0.9.8`](https://github.com/withastro/astro/blob/HEAD/packages/language-tools/astro-check/CHANGELOG.md#098) [Compare Source](https://github.com/withastro/astro/compare/@astrojs/check@0.9.7...@astrojs/check@0.9.8) ##### Patch Changes - [#​15892](withastro/astro#15892) [`a2f597d`](withastro/astro@a2f597d) Thanks [@​Princesseuh](https://github.com/Princesseuh)! - Fixes Astro not being able to find astro check sometimes - Updated dependencies \[[`7b4b254`](withastro/astro@7b4b254)]: - [@​astrojs/language-server](https://github.com/astrojs/language-server)@​2.16.5 </details> <details> <summary>withastro/astro (astro)</summary> ### [`v6.0.5`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#605) [Compare Source](https://github.com/withastro/astro/compare/astro@6.0.4...astro@6.0.5) ##### Patch Changes - [#​15891](withastro/astro#15891) [`b889231`](withastro/astro@b889231) Thanks [@​matthewp](https://github.com/matthewp)! - Fix dev routing for `server:defer` islands when adapters opt into handling prerendered routes in Astro core. Server island requests are now treated as prerender-handler eligible so prerendered pages using `prerenderEnvironment: 'node'` can load island content without `400` errors. - [#​15890](withastro/astro#15890) [`765a887`](withastro/astro@765a887) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes `astro:actions` validation to check resolved routes, so projects using default static output with at least one `prerender = false` page or endpoint no longer fail during startup. - [#​15884](withastro/astro#15884) [`dcd2c8e`](withastro/astro@dcd2c8e) Thanks [@​matthewp](https://github.com/matthewp)! - Avoid a `MaxListenersExceededWarning` during `astro dev` startup by increasing the shared Vite watcher listener limit when attaching content server listeners. - [#​15904](withastro/astro#15904) [`23d5244`](withastro/astro@23d5244) Thanks [@​jlukic](https://github.com/jlukic)! - Emit the `before-hydration` script chunk for the `client` Vite environment. The chunk was only emitted for `prerender` and `ssr` environments, causing a 404 when browsers tried to load it. This broke hydration for any integration using `injectScript('before-hydration', ...)`, including Lit SSR. - [#​15933](withastro/astro#15933) [`325901e`](withastro/astro@325901e) Thanks [@​ematipico](https://github.com/ematipico)! - Fixes an issue where `<style>` tags inside SVG components weren't correctly tracked when enabling CSP. - [#​15875](withastro/astro#15875) [`c43ef8a`](withastro/astro@c43ef8a) Thanks [@​matthewp](https://github.com/matthewp)! - Ensure custom prerenderers are always torn down during build, even when `getStaticPaths()` throws. - [#​15887](withastro/astro#15887) [`1861fed`](withastro/astro@1861fed) Thanks [@​ematipico](https://github.com/ematipico)! - Fixes an issue where the build incorrectly leaked server entrypoint into the client environment, causing adapters to emit warnings during the build. - [#​15888](withastro/astro#15888) [`925252e`](withastro/astro@925252e) Thanks [@​matthewp](https://github.com/matthewp)! - Fix a bug where `server:defer` could fail at runtime in prerendered pages for some adapters (including Cloudflare), causing errors like `serverIslandMap?.get is not a function`. - [#​15901](withastro/astro#15901) [`07c1002`](withastro/astro@07c1002) Thanks [@​delucis](https://github.com/delucis)! - Fixes JSON schema generation for content collection schemas that have differences between their input and output shapes. - [#​15882](withastro/astro#15882) [`759f946`](withastro/astro@759f946) Thanks [@​matthewp](https://github.com/matthewp)! - Fix `Astro.url.pathname` for the root page when using `build.format: "file"` so it resolves to `/index.html` instead of `/.html` during builds. </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My43Ni4yIiwidXBkYXRlZEluVmVyIjoiNDMuNzYuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: Renovate Bot <renovate@zarantonello.dev> Co-committed-by: Renovate Bot <renovate@zarantonello.dev>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Production builds don't emit the before-hydration script chunk to the client output, causing a 404 when islands attempt to load it. This breaks hydration for any integration using
injectScript('before-hydration')Changes
ASTRO_VITE_ENVIRONMENT_NAMES.clientto the environment guard inbuildStart()ofvite-plugin-scriptsThe before-hydration chunk is only emitted for
prerenderandssrenvironments, but notclient— which is the environment that produces browser-served JS.This was introduced in #14306 (Vite Environment API migration), where the original
!isSsrBuildcondition was changed to['prerender', 'ssr'].includes(this.environment.name)which mistakenly inverted the original intent.Testing
Existing tests only assert the attribute is present in HTML, not that the referenced file exists in the client output.
before-hydration-urlresolves in the build output (this test fails without bug fix)Docs
No docs changes needed — restores existing
injectScript('before-hydration', ...)behavior.