Open matthewp opened 1 week ago
Latest commit: 324f74e55d13fe8b91d0d5c4eef830fe849a38a6
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
!preview server-islands
Snapshots have been released for the following packages:
@astrojs/markdown-remark@experimental--server-islands
@astrojs/underscore-redirects@experimental--server-islands
astro@experimental--server-islands
@astrojs/vercel@experimental--server-islands
@astrojs/node@experimental--server-islands
@astrojs/rss@experimental--server-islands
@astrojs/markdoc@experimental--server-islands
@astrojs/mdx@experimental--server-islands
🦋 warn ===============================IMPORTANT!===============================
🦋 warn Packages will be released under the experimental--server-islands tag
🦋 warn ----------------------------------------------------------------------
🦋 info npm info astro
🦋 info npm info @astrojs/prism
🦋 info npm info @astrojs/rss
🦋 info npm info create-astro
🦋 info npm info @astrojs/db
🦋 info npm info @astrojs/alpinejs
🦋 info npm info @astrojs/lit
🦋 info npm info @astrojs/markdoc
🦋 info npm info @astrojs/mdx
🦋 info npm info @astrojs/node
🦋 info npm info @astrojs/partytown
🦋 info npm info @astrojs/preact
🦋 info npm info @astrojs/react
🦋 info npm info @astrojs/sitemap
🦋 info npm info @astrojs/solid-js
🦋 info npm info @astrojs/svelte
🦋 info npm info @astrojs/tailwind
🦋 info npm info @astrojs/vercel
🦋 info npm info @astrojs/vue
🦋 info npm info @astrojs/web-vitals
🦋 info npm info @astrojs/internal-helpers
🦋 info npm info @astrojs/markdown-remark
🦋 info npm info @astrojs/studio
🦋 info npm info @astrojs/telemetry
🦋 info npm info @astrojs/underscore-redirects
🦋 info npm info @astrojs/upgrade
🦋 info astro is being published because our local version (0.0.0-server-islands-20240621194657) has not been published on npm
🦋 warn @astrojs/prism is not being published because version 3.1.0 is already published on npm
🦋 info @astrojs/rss is being published because our local version (0.0.0-server-islands-20240621194657) has not been published on npm
🦋 warn create-astro is not being published because version 4.8.0 is already published on npm
🦋 warn @astrojs/db is not being published because version 0.11.6 is already published on npm
🦋 warn @astrojs/alpinejs is not being published because version 0.4.0 is already published on npm
🦋 warn @astrojs/lit is not being published because version 4.3.0 is already published on npm
🦋 info @astrojs/markdoc is being published because our local version (0.0.0-server-islands-20240621194657) has not been published on npm
🦋 info @astrojs/mdx is being published because our local version (0.0.0-server-islands-20240621194657) has not been published on npm
🦋 info @astrojs/node is being published because our local version (0.0.0-server-islands-20240621194657) has not been published on npm
🦋 warn @astrojs/partytown is not being published because version 2.1.1 is already published on npm
🦋 warn @astrojs/preact is not being published because version 3.5.0 is already published on npm
🦋 warn @astrojs/react is not being published because version 3.6.0 is already published on npm
🦋 warn @astrojs/sitemap is not being published because version 3.1.6 is already published on npm
🦋 warn @astrojs/solid-js is not being published because version 4.4.0 is already published on npm
🦋 warn @astrojs/svelte is not being published because version 5.6.0 is already published on npm
🦋 warn @astrojs/tailwind is not being published because version 5.1.0 is already published on npm
🦋 info @astrojs/vercel is being published because our local version (0.0.0-server-islands-20240621194657) has not been published on npm
🦋 warn @astrojs/vue is not being published because version 4.5.0 is already published on npm
🦋 warn @astrojs/web-vitals is not being published because version 0.2.1 is already published on npm
🦋 warn @astrojs/internal-helpers is not being published because version 0.4.0 is already published on npm
🦋 info @astrojs/markdown-remark is being published because our local version (0.0.0-server-islands-20240621194657) has not been published on npm
🦋 warn @astrojs/studio is not being published because version 0.1.0 is already published on npm
🦋 warn @astrojs/telemetry is not being published because version 3.1.0 is already published on npm
🦋 info @astrojs/underscore-redirects is being published because our local version (0.0.0-server-islands-20240621194657) has not been published on npm
🦋 warn @astrojs/upgrade is not being published because version 0.3.1 is already published on npm
🦋 info Publishing "astro" at "0.0.0-server-islands-20240621194657"
🦋 info Publishing "@astrojs/rss" at "0.0.0-server-islands-20240621194657"
🦋 info Publishing "@astrojs/markdoc" at "0.0.0-server-islands-20240621194657"
🦋 info Publishing "@astrojs/mdx" at "0.0.0-server-islands-20240621194657"
🦋 info Publishing "@astrojs/node" at "0.0.0-server-islands-20240621194657"
🦋 info Publishing "@astrojs/vercel" at "0.0.0-server-islands-20240621194657"
🦋 info Publishing "@astrojs/markdown-remark" at "0.0.0-server-islands-20240621194657"
🦋 info Publishing "@astrojs/underscore-redirects" at "0.0.0-server-islands-20240621194657"
🦋 success packages published successfully:
🦋 astro@0.0.0-server-islands-20240621194657
🦋 @astrojs/rss@0.0.0-server-islands-20240621194657
🦋 @astrojs/markdoc@0.0.0-server-islands-20240621194657
🦋 @astrojs/mdx@0.0.0-server-islands-20240621194657
🦋 @astrojs/node@0.0.0-server-islands-20240621194657
🦋 @astrojs/vercel@0.0.0-server-islands-20240621194657
🦋 @astrojs/markdown-remark@0.0.0-server-islands-20240621194657
🦋 @astrojs/underscore-redirects@0.0.0-server-islands-20240621194657
🦋 Creating git tags...
🦋 New tag: astro@0.0.0-server-islands-20240621194657
🦋 New tag: @astrojs/rss@0.0.0-server-islands-20240621194657
🦋 New tag: @astrojs/markdoc@0.0.0-server-islands-20240621194657
🦋 New tag: @astrojs/mdx@0.0.0-server-islands-20240621194657
🦋 New tag: @astrojs/node@0.0.0-server-islands-20240621194657
🦋 New tag: @astrojs/vercel@0.0.0-server-islands-20240621194657
🦋 New tag: @astrojs/markdown-remark@0.0.0-server-islands-20240621194657
🦋 New tag: @astrojs/underscore-redirects@0.0.0-server-islands-20240621194657
Astro.self
is failing with the following error:
Error: Could not find server component name
at Object.render (/project/node_modules/.pnpm/astro@0.0.0-server-islands-20240621194657_@types+node@20.14.8_typescript@5.5.2/node_modules/astro/dist/runtime/server/render/server-islands.js:19:15)
at Module.renderChild (/project/node_modules/.pnpm/astro@0.0.0-server-islands-20240621194657_@types+node@20.14.8_typescript@5.5.2/node_modules/astro/dist/runtime/server/render/any.js:31:17)
This alternative gives the expected result for a recursive component:
---
import Self from './Foo.astro'; // Name of the file where this is on
import * as timers from 'node:timers/promises';
await timers.setTimeout(1000);
const now = Date();
---
<p>
{now}
</p>
{!Astro.props.stop && <Self stop server:defer />}
Does that work normally? I was trying to use Astro.self
but you are importing yourself (if I understand correctly). I have never done that before, that works in normal code?
Yes, without server:defer
both using Astro.self
and importing yourself works.
Server island is not triggered if it is added to the document from a client island:
---
import Foo from '../components/Foo.astro';
import Preact from '../components/Preact.tsx';
---
<Preact client:only="preact">
<Foo server:defer />
</Preact>
The script is added to the page but nothing happens:
(Haven't tested with other frameworks, only preact)
The inverse, a client:only
inside of a server:defer
, works fine
Can the example be extended to several pages (e.g. online shop items 1, 2 and 3)? This would allow you to see how the server-islands behave when changing pages and consider how you could eliminate the (probable) flickering, e.g. at the count.
Great work here! however it would be better if there's some sort of client persistence/caching mechanism. It'd be too server consuming to load the server island on every navigation.
I suggest adding a client:persist
directive.
@Mouaz that will work if you use the <ViewTransitions />
router already, I believe.
API Bashing
Create a new Astro project as normal:
After that has been created, install the preview release:
To use server islands you need to set your
output
to'hybrid'
or'server'
:Then add
server:defer
to any component. You can provide fallback HTML that will be rendered on the initial request withslot="fallback"
:Changes
server:defer
directive to allow deferred islands that are loaded from the server after the page loads.Testing
TODO
Docs
TODO