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



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