Conversation
Rollup can emit server-island placeholders with either single or double quotes, which caused map injection to be skipped in some adapter builds. Match placeholders quote-agnostically and add a regression test that verifies the maps are materialized in output.
🦋 Changeset detectedLatest commit: ce7e29a 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 |
astro
create-astro
@astrojs/cloudflare
@astrojs/preact
@astrojs/check
@astrojs/language-server
astro-vscode
commit: |
| const RESOLVED_SERVER_ISLAND_MANIFEST = '\0' + SERVER_ISLAND_MANIFEST; | ||
|
|
||
| export const serverIslandPlaceholderMap = "'$$server-islands-map$$'"; | ||
| const serverIslandPlaceholderMap = "'$$server-islands-map$$'"; |
There was a problem hiding this comment.
If you're looking for a solution that is vite 8 friendly, use template literals.
Turns out that oxc/rolldown do a bunch of normalisation with strings, and sometimes it transforms them
There was a problem hiding this comment.
Oh wait, that doesn't matter here, this code isn't loaded by Vite.
There was a problem hiding this comment.
It actually does... 😅
I had to apply this change 1cae171
It's just a FYI, no need to change it here. I wanted to let you know
|
@CaiJimmy no, will keep this one. |
|
Thanks! I just tested with the current stable version of Astro 6 and can confirm that it does not generate the |
|
@CaiJimmy can you try with: npm i https://pkg.pr.new/astro@fbf9d83 |
|
@matthewp I can confirm that now preview environment working correctly with But Is there any way to expose more error stack information here? |
|
With |
|
@CaiJimmy I think I know the dev issue here. It's unrelated to this change so I'll look into that as a separate PR. |
|
Thank you! I'm currently testing this new version on my website, and found that there is some issue with importing third party libraries (using the top level The example server island would be something like this: ---
import { encodeBase64 } from "@oslojs/encoding";
const data: Uint8Array = new TextEncoder().encode("hello world");
const encoded = encodeBase64(data);
---
<p>Encoded: {encoded}</p>The resulting file after running build keeps
Inside Error when running preview: I believe (?) this is not related with https://docs.astro.build/en/guides/integrations-guide/cloudflare/#some-dependencies-might-need-to-be-pre-compiled, because it's using the ES6 export and import syntax. I have updated the repo with a minimal reproducible example: https://github.com/CaiJimmy/astro-v6-prerender Should I create a separate issue for this? Seems like a bundle problem. |
|
@CaiJimmy No, I think that might be related to this fix. I'll try and get another test for this scenario and it fixed here. |
|
@CaiJimmy here's new ones for you to try: |
|
Thanks! With /// island_CllqxkrA.mjs
globalThis.process ??= {};
globalThis.process.env ??= {};
import { A as AstroError, ao as InvalidComponentArgs, ap as encodeBase64, l as maybeRenderHead, D as renderTemplate } from "./transition_BffVS1kO.mjs";However, when it's set to /// island_C0XpBDl0.mjs
globalThis.process ??= {}; globalThis.process.env ??= {};
import { A as AstroError, ao as InvalidComponentArgs, l as maybeRenderHead, D as renderTemplate } from './transition_BPFN3ezl.mjs';
import { encodeBase64 } from '@oslojs/encoding';The test was done using this example: https://github.com/CaiJimmy/astro-v6-prerender |
|
@CaiJimmy What is incorrect about the second example there? @oslo/encoding is not bundled because dependencies are not bundled by default in Node.js. Does this cause a problem? |
Yes, because this dependency is used by the Server Island script, which will be executed in the Worker environment. It wouldn't be a problem if the pre-render page itself used it because it would be executed in a normal Node environment. |
|
Right ok, that's interesting. You are hitting the hardest part of this refactor 😅. I've been trying to avoid flipping the order that the environments run, but I might need to do that. Let me try it out. |
|
@CaiJimmy can you try this one? |
|
Thanks! I have tested it, and it is now compiling and bundling the dependencies correctly. I have also tested this version on my website and found that Server Island requests are returning empty responses in Thanks again for the fix! Edit: here is the minimal reproducible example: https://github.com/CaiJimmy/astro-v6-prerender/blob/main/src/pages/island.astro Solid.js component (I haven't tested yet other frameworks) inside a Astro Server Island component is not rendered: ---
import A from "./A";
---
<A content={'test'} />export default function A({ content }: { content?: string }) {
return (
<div>
<p>Content: {content}</p>
</div>
);
}Empty response is returned by the server (it's a 200 response, no error in console):
Edit2: I have tested with React, and it has the same issue. |
Server islands used only on prerendered pages produce broken chunk filenames. Patch swaps build order (prerender first, then SSR) and uses quote-agnostic placeholder matching. Tracks: withastro/astro#15888 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Fixes 15903. |
|
@CaiJimmy I think I'm going to release this as I'm confident it fixes most of the server island issues people are facing. Once that's out if you could file a new issue about nested client island inside I'll get that resolved separately. |
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>
Server islands used only on prerendered pages produce broken chunk filenames. Patch swaps build order (prerender first, then SSR) and uses quote-agnostic placeholder matching. Tracks: withastro/astro#15888 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>



Changes
serverIslandMap?.getis not a function in pre-rendered page #15886Testing
serverIslandMap/serverIslandNameMapmaps.Docs