Skip to content

fix(astro): server islands not working in prerendered pages with server output#15767

Merged
matthewp merged 13 commits intomainfrom
si-with-node
Mar 12, 2026
Merged

fix(astro): server islands not working in prerendered pages with server output#15767
matthewp merged 13 commits intomainfrom
si-with-node

Conversation

@matthewp
Copy link
Contributor

@matthewp matthewp commented Mar 5, 2026

Changes

  • Fixes Astro v6 server islands not working with Node adapter #15753
  • A map is created in the manifest for server island names to their import paths. This was failing after splitting the build into ssr/prerender, because the map is created in ssr where islands might only be used in prerender pages.
  • Fix is to use a placeholder and update the mapping as a post-build hook after both builds are complete.

Testing

  • Added a new unit test in test/units/build/server-islands.test.js that runs an in-memory Astro build using virtual .astro modules (no fixture files on disk).
  • Test verifies the server island manifest is populated when server:defer is only used in prerendered pages.

Docs

N/A, bug fix

@changeset-bot
Copy link

changeset-bot bot commented Mar 5, 2026

🦋 Changeset detected

Latest commit: 67d9150

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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 5, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 5, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing si-with-node (67d9150) with main (ca76ff1)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (bc200b2) during the generation of this report, so ca76ff1 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

matthewp and others added 11 commits March 4, 2026 22:01
When server islands (server:defer) are only used in prerendered pages,
the SSR build environment never discovers them — it leaves empty map
placeholders in the manifest. The prerender build discovers the islands
later but the SSR output is already finalized.

Fix by deferring placeholder replacement during build: renderChunk leaves
placeholders intact when no islands are known yet, renderChunk saves
resolved filenames when processing them in the prerender env, and
generateBundle patches the SSR manifest chunk in-memory. A post-build
hook also patches the on-disk SSR output and copies island component
chunks from the prerender directory to the server output.
@matthewp matthewp added the pr preview Apply this label to a PR to generate a preview release label Mar 11, 2026
@github-actions github-actions bot removed the pr preview Apply this label to a PR to generate a preview release label Mar 11, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 11, 2026

npm i https://pkg.pr.new/astro@15767

commit: ebcc350

@louisescher
Copy link
Member

This fixed it for my site!

@matthewp matthewp marked this pull request as ready for review March 11, 2026 20:38
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a big one

@matthewp matthewp merged commit e0042f7 into main Mar 12, 2026
27 checks passed
@matthewp matthewp deleted the si-with-node branch March 12, 2026 12:05
@astrobot-houston astrobot-houston mentioned this pull request Mar 12, 2026
dadezzz pushed a commit to dadezzz/ice-notes that referenced this pull request Mar 17, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`6.0.3` → `6.0.4`](https://renovatebot.com/diffs/npm/astro/6.0.3/6.0.4) | ![age](https://developer.mend.io/api/mc/badges/age/npm/astro/6.0.4?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/astro/6.0.3/6.0.4?slim=true) |

---

### Release Notes

<details>
<summary>withastro/astro (astro)</summary>

### [`v6.0.4`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#604)

[Compare Source](https://github.com/withastro/astro/compare/astro@6.0.3...astro@6.0.4)

##### Patch Changes

- [#&#8203;15870](withastro/astro#15870) [`920f10b`](withastro/astro@920f10b) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Prebundle `astro/toolbar` in dev when custom dev toolbar apps are registered, preventing re-optimization reloads that can hide or break the toolbar.

- [#&#8203;15876](withastro/astro#15876) [`f47ac53`](withastro/astro@f47ac53) Thanks [@&#8203;ematipico](https://github.com/ematipico)! - Fixes `redirectToDefaultLocale` producing a protocol-relative URL (`//locale`) instead of an absolute path (`/locale`) when `base` is `'/'`.

- [#&#8203;15767](withastro/astro#15767) [`e0042f7`](withastro/astro@e0042f7) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes server islands (`server:defer`) not working when only used in prerendered pages with `output: 'server'`.

- [#&#8203;15873](withastro/astro#15873) [`35841ed`](withastro/astro@35841ed) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fix a dev server bug where newly created pages could miss layout-imported CSS until restart.

- [#&#8203;15874](withastro/astro#15874) [`ce0669d`](withastro/astro@ce0669d) Thanks [@&#8203;ematipico](https://github.com/ematipico)! - Fixes a warning when using `prefetchAll`

- [#&#8203;15754](withastro/astro#15754) [`58f1d63`](withastro/astro@58f1d63) Thanks [@&#8203;rururux](https://github.com/rururux)! - Fixes a bug where a directory at the project root sharing the same name as a page route would cause the dev server to return a 404 instead of serving the page.

- [#&#8203;15869](withastro/astro#15869) [`76b3a5e`](withastro/astro@76b3a5e) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Update the unknown file extension error hint to recommend `vite.resolve.noExternal`, which is the correct Vite 7 config key.

</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.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- 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:eyJjcmVhdGVkSW5WZXIiOiI0My41OS41IiwidXBkYXRlZEluVmVyIjoiNDMuNTkuNSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: Renovate Bot <renovate@zarantonello.dev>
Co-committed-by: Renovate Bot <renovate@zarantonello.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Astro v6 server islands not working with Node adapter

4 participants