mirror of
https://github.com/withastro/astro.git
synced 2025-03-10 23:01:26 -05:00
Fix Server Islands in Vercel (#11491)
* Fix Server Islands in Vercel * Add a changeset * Get server islands pattern from the segments * Move getPattern so it can be used at runtime * Fix build
This commit is contained in:
parent
26d1dcaf23
commit
7d1c5357d0
5 changed files with 62 additions and 0 deletions
10
packages/integrations/vercel/test/fixtures/server-islands/astro.config.mjs
vendored
Normal file
10
packages/integrations/vercel/test/fixtures/server-islands/astro.config.mjs
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
import vercel from '@astrojs/vercel/serverless';
|
||||
import { defineConfig } from 'astro/config';
|
||||
|
||||
export default defineConfig({
|
||||
output: "server",
|
||||
adapter: vercel(),
|
||||
experimental: {
|
||||
serverIslands: true,
|
||||
}
|
||||
});
|
10
packages/integrations/vercel/test/fixtures/server-islands/package.json
vendored
Normal file
10
packages/integrations/vercel/test/fixtures/server-islands/package.json
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "@test/vercel-server-islands",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@astrojs/vercel": "workspace:*",
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
1
packages/integrations/vercel/test/fixtures/server-islands/src/components/Island.astro
vendored
Normal file
1
packages/integrations/vercel/test/fixtures/server-islands/src/components/Island.astro
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
<h1>I'm an island</h1>
|
12
packages/integrations/vercel/test/fixtures/server-islands/src/pages/index.astro
vendored
Normal file
12
packages/integrations/vercel/test/fixtures/server-islands/src/pages/index.astro
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
import Island from '../components/Island.astro';
|
||||
---
|
||||
<html>
|
||||
<head>
|
||||
<title>One</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>One</h1>
|
||||
<Island server:defer />
|
||||
</body>
|
||||
</html>
|
29
packages/integrations/vercel/test/server-islands.test.js
Normal file
29
packages/integrations/vercel/test/server-islands.test.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it } from 'node:test';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
describe('Server Islands', () => {
|
||||
/** @type {import('./test-utils.js').Fixture} */
|
||||
let fixture;
|
||||
|
||||
before(async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/server-islands/',
|
||||
});
|
||||
await fixture.build();
|
||||
});
|
||||
|
||||
it('server islands route is in the config', async () => {
|
||||
const config = JSON.parse(
|
||||
await fixture.readFile('../.vercel/output/config.json')
|
||||
);
|
||||
let found = null;
|
||||
for(let route of config.routes) {
|
||||
if(route.src?.includes('_server-islands')) {
|
||||
found = route;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert.notEqual(found, null, 'Default server islands route included');
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue