mirror of
https://github.com/withastro/astro.git
synced 2025-01-22 10:31:53 -05:00
Fix server islands for prerender-only sites (#12982)
This commit is contained in:
parent
80c6801b4f
commit
429aa75475
3 changed files with 13 additions and 15 deletions
5
.changeset/orange-suits-suffer.md
Normal file
5
.changeset/orange-suits-suffer.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fixes an issue where server islands do not work in projects that use an adapter but only have prerendered pages. If an adapter is added, the server island endpoint will now be added by default.
|
|
@ -718,12 +718,13 @@ export async function createRouteManifest(
|
|||
}
|
||||
if (dev || settings.buildOutput === 'server') {
|
||||
injectImageEndpoint(settings, { routes }, dev ? 'dev' : 'build');
|
||||
// Ideally we would only inject the server islands route if server islands are used in the project.
|
||||
// Unfortunately, there is a "circular dependency": to know if server islands are used, we need to run
|
||||
// the build but the build relies on the routes manifest.
|
||||
// This situation also means we cannot update the buildOutput based on whether or not server islands
|
||||
// are used in the project. If server islands are detected after the build but the buildOutput is
|
||||
// static, we fail the build.
|
||||
}
|
||||
|
||||
// If an adapter is added, we unconditionally inject the server islands route.
|
||||
// Ideally we would only inject the server islands route if server islands are used in the project.
|
||||
// Unfortunately, there is a "circular dependency": to know if server islands are used, we need to run
|
||||
// the build but the build relies on the routes manifest.
|
||||
if (dev || settings.config.adapter) {
|
||||
injectServerIslandRoute(settings.config, { routes });
|
||||
}
|
||||
await runHookRoutesResolved({ routes, settings, logger });
|
||||
|
|
|
@ -260,10 +260,6 @@ describe('routing - createRouteManifest', () => {
|
|||
});
|
||||
|
||||
assert.deepEqual(getManifestRoutes(manifest), [
|
||||
{
|
||||
route: '/_server-islands/[name]',
|
||||
type: 'page',
|
||||
},
|
||||
{
|
||||
route: '/_image',
|
||||
type: 'endpoint',
|
||||
|
@ -314,10 +310,7 @@ describe('routing - createRouteManifest', () => {
|
|||
});
|
||||
|
||||
assert.deepEqual(getManifestRoutes(manifest), [
|
||||
{
|
||||
route: '/_server-islands/[name]',
|
||||
type: 'page',
|
||||
},
|
||||
|
||||
{
|
||||
route: '/_image',
|
||||
type: 'endpoint',
|
||||
|
@ -457,7 +450,6 @@ describe('routing - createRouteManifest', () => {
|
|||
});
|
||||
|
||||
assert.deepEqual(getManifestRoutes(manifest), [
|
||||
{ type: 'page', route: '/_server-islands/[name]' },
|
||||
{ type: 'endpoint', route: '/_image' },
|
||||
{ type: 'endpoint', route: '/blog/a-[b].233' },
|
||||
{ type: 'redirect', route: '/posts/a-[b].233' },
|
||||
|
|
Loading…
Reference in a new issue