Skip to content

Commit e63f5a2

Browse files
authored
Merge branch 'next' into arpan-withastro#12252-mdx-islands
2 parents 5c1def6 + af867f3 commit e63f5a2

File tree

198 files changed

+3282
-1216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+3282
-1216
lines changed

.changeset/brown-bulldogs-share.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes an issue where an incorrect usage of Astro actions was lost when porting the fix from v4 to v5

.changeset/clean-moles-rest.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes a bug where legacy content types were generated for content layer collections if they were in the content directory

.changeset/pre.json

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"poor-frogs-dream",
9595
"poor-seals-clap",
9696
"pretty-walls-camp",
97+
"proud-games-repair",
9798
"quick-ads-exercise",
9899
"quick-onions-leave",
99100
"rotten-phones-scream",
@@ -110,6 +111,7 @@
110111
"strange-sheep-film",
111112
"strong-months-grab",
112113
"sweet-timers-smash",
114+
"tall-waves-impress",
113115
"tame-pumpkins-swim",
114116
"tame-rats-cross",
115117
"ten-students-repair",

.changeset/proud-games-repair.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Adds an error when `Astro.rewrite()` is used to rewrite an on-demand route with a static route when using the `"server"` output.
6+
7+
This is a forbidden rewrite because Astro can't retrieve the emitted static route at runtime. This route is served by the hosting platform, and not Astro itself.

.changeset/proud-terms-swim.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Adds experimental reponsive image support

.changeset/tall-waves-impress.md

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
'astro': minor
3+
---
4+
5+
Changes the default behavior for Astro Action form requests to a standard POST submission.
6+
7+
In Astro 4.x, actions called from an HTML form would trigger a redirect with the result forwarded using cookies. This caused issues for large form errors and return values that exceeded the 4 KB limit of cookie-based storage.
8+
9+
Astro 5.0 now renders the result of an action as a POST result without any forwarding. This will introduce a "confirm form resubmission?" dialog when a user attempts to refresh the page, though it no longer imposes a 4 KB limit on action return value.
10+
11+
## Customize form submission behavior
12+
13+
If you prefer to address the "confirm form resubmission?" dialog on refresh, or to preserve action results across sessions, you can now [customize action result handling from middleware](https://5-0-0-beta.docs.astro.build/en/guides/actions/#advanced-persist-action-results-with-a-session).
14+
15+
We recommend using a session storage provider [as described in our Netlify Blob example](https://5-0-0-beta.docs.astro.build/en/guides/actions/#advanced-persist-action-results-with-a-session). However, if you prefer the cookie forwarding behavior from 4.X and accept the 4 KB size limit, you can implement the pattern as shown in this sample snippet:
16+
17+
```ts
18+
// src/middleware.ts
19+
import { defineMiddleware } from 'astro:middleware';
20+
import { getActionContext } from 'astro:actions';
21+
22+
export const onRequest = defineMiddleware(async (context, next) => {
23+
// Skip requests for prerendered pages
24+
if (context.isPrerendered) return next();
25+
26+
const { action, setActionResult, serializeActionResult } = getActionContext(context);
27+
28+
// If an action result was forwarded as a cookie, set the result
29+
// to be accessible from `Astro.getActionResult()`
30+
const payload = context.cookies.get('ACTION_PAYLOAD');
31+
if (payload) {
32+
const { actionName, actionResult } = payload.json();
33+
setActionResult(actionName, actionResult);
34+
context.cookies.delete('ACTION_PAYLOAD');
35+
return next();
36+
}
37+
38+
// If an action was called from an HTML form action,
39+
// call the action handler and redirect with the result as a cookie.
40+
if (action?.calledFrom === 'form') {
41+
const actionResult = await action.handler();
42+
43+
context.cookies.set('ACTION_PAYLOAD', {
44+
actionName: action.name,
45+
actionResult: serializeActionResult(actionResult),
46+
});
47+
48+
if (actionResult.error) {
49+
// Redirect back to the previous page on error
50+
const referer = context.request.headers.get('Referer');
51+
if (!referer) {
52+
throw new Error('Internal: Referer unexpectedly missing from Action POST request.');
53+
}
54+
return context.redirect(referer);
55+
}
56+
// Redirect to the destination page on success
57+
return context.redirect(context.originPathname);
58+
}
59+
60+
return next();
61+
})
62+
```

benchmark/bench/codspeed.js

+46-32
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,62 @@ import path from 'node:path';
22
import { withCodSpeed } from '@codspeed/tinybench-plugin';
33
import { Bench } from 'tinybench';
44
import { exec } from 'tinyexec';
5-
import { renderPages } from '../make-project/render-default.js';
65
import { astroBin } from './_util.js';
76

87
export async function run({ memory: _memory, render, stress: _stress }) {
98
const options = {
109
iterations: 10,
1110
};
1211
const bench = process.env.CODSPEED ? withCodSpeed(new Bench(options)) : new Bench(options);
13-
let app;
14-
bench.add(
15-
'Rendering',
16-
async () => {
12+
await exec(astroBin, ['build'], {
13+
nodeOptions: {
14+
cwd: render.root,
15+
stdio: 'inherit',
16+
},
17+
});
18+
19+
const entry = new URL('./dist/server/entry.mjs', `file://${render.root}`);
20+
const { manifest, createApp } = await import(entry);
21+
const streamingApp = createApp(manifest, true);
22+
const nonStreamingApp = createApp(manifest, false);
23+
bench
24+
.add('Rendering: streaming [true], .astro file', async () => {
1725
console.info('Start task.');
18-
const result = {};
19-
for (const fileName of renderPages) {
20-
const pathname = '/' + fileName.slice(0, -path.extname(fileName).length);
21-
const request = new Request(new URL(pathname, 'http://exmpale.com'));
22-
const response = await app.render(request);
23-
const html = await response.text();
24-
if (!result[pathname]) result[pathname] = [];
25-
result[pathname].push(html);
26-
}
26+
const request = new Request(new URL('http://exmpale.com/astro'));
27+
await streamingApp.render(request);
2728
console.info('Finish task.');
28-
return result;
29-
},
30-
{
31-
async beforeAll() {
32-
// build for rendering
33-
await exec(astroBin, ['build'], {
34-
nodeOptions: {
35-
cwd: render.root,
36-
stdio: 'inherit',
37-
},
38-
});
29+
})
30+
.add('Rendering: streaming [true], .md file', async () => {
31+
console.info('Start task.');
32+
const request = new Request(new URL('http://exmpale.com/md'));
33+
await streamingApp.render(request);
34+
console.info('Finish task.');
35+
})
36+
.add('Rendering: streaming [true], .mdx file', async () => {
37+
console.info('Start task.');
38+
const request = new Request(new URL('http://exmpale.com/mdx'));
39+
await streamingApp.render(request);
40+
console.info('Finish task.');
41+
})
3942

40-
const entry = new URL('./dist/server/entry.mjs', `file://${render.root}`);
41-
const { manifest, createApp } = await import(entry);
42-
app = createApp(manifest);
43-
app.manifest = manifest;
44-
},
45-
},
46-
);
43+
.add('Rendering: streaming [false], .astro file', async () => {
44+
console.info('Start task.');
45+
const request = new Request(new URL('http://exmpale.com/astro'));
46+
await nonStreamingApp.render(request);
47+
console.info('Finish task.');
48+
})
49+
.add('Rendering: streaming [false], .md file', async () => {
50+
console.info('Start task.');
51+
const request = new Request(new URL('http://exmpale.com/md'));
52+
await nonStreamingApp.render(request);
53+
console.info('Finish task.');
54+
})
55+
.add('Rendering: streaming [false], .mdx file', async () => {
56+
console.info('Start task.');
57+
const request = new Request(new URL('http://exmpale.com/mdx'));
58+
await nonStreamingApp.render(request);
59+
console.info('Finish task.');
60+
});
4761

4862
await bench.run();
4963
console.table(bench.table());

benchmark/packages/adapter/src/server.ts

-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ applyPolyfills();
77

88
class MyApp extends App {
99
#manifest: SSRManifest | undefined;
10-
#streaming: boolean;
1110
constructor(manifest: SSRManifest, streaming = false) {
1211
super(manifest, streaming);
1312
this.#manifest = manifest;
14-
this.#streaming = streaming;
1513
}
1614

1715
async render(request: Request) {

examples/basics/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"astro": "astro"
1111
},
1212
"dependencies": {
13-
"astro": "^5.0.0-beta.7"
13+
"astro": "^5.0.0-beta.8"
1414
}
1515
}

examples/blog/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"@astrojs/mdx": "^4.0.0-beta.3",
1414
"@astrojs/rss": "^4.0.9",
1515
"@astrojs/sitemap": "^3.2.1",
16-
"astro": "^5.0.0-beta.7"
16+
"astro": "^5.0.0-beta.8"
1717
}
1818
}

examples/component/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"scripts": {},
1717
"devDependencies": {
18-
"astro": "^5.0.0-beta.7"
18+
"astro": "^5.0.0-beta.8"
1919
},
2020
"peerDependencies": {
2121
"astro": "^4.0.0 || ^5.0.0"

examples/container-with-vitest/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"test": "vitest run"
1212
},
1313
"dependencies": {
14-
"astro": "^5.0.0-beta.7",
14+
"astro": "^5.0.0-beta.8",
1515
"@astrojs/react": "^3.6.2",
1616
"react": "^18.3.1",
1717
"react-dom": "^18.3.1",

examples/framework-alpine/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"@astrojs/alpinejs": "^0.4.0",
1414
"@types/alpinejs": "^3.13.10",
1515
"alpinejs": "^3.14.3",
16-
"astro": "^5.0.0-beta.7"
16+
"astro": "^5.0.0-beta.8"
1717
}
1818
}

examples/framework-multiple/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
"dependencies": {
1313
"@astrojs/preact": "^3.5.3",
1414
"@astrojs/react": "^3.6.2",
15-
"@astrojs/solid-js": "^4.4.2",
15+
"@astrojs/solid-js": "^4.4.3",
1616
"@astrojs/svelte": "^6.0.0-beta.2",
1717
"@astrojs/vue": "^5.0.0-beta.1",
1818
"@types/react": "^18.3.12",
1919
"@types/react-dom": "^18.3.1",
20-
"astro": "^5.0.0-beta.7",
20+
"astro": "^5.0.0-beta.8",
2121
"preact": "^10.24.3",
2222
"react": "^18.3.1",
2323
"react-dom": "^18.3.1",
2424
"solid-js": "^1.9.3",
25-
"svelte": "^4.2.19",
25+
"svelte": "^5.1.16",
2626
"vue": "^3.5.12"
2727
}
2828
}

examples/framework-multiple/src/components/svelte/SvelteCounter.svelte

+11-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
A counter written with Svelte
33
-->
44
<script lang="ts">
5-
let count = 0;
5+
import type { Snippet } from 'svelte';
6+
7+
interface Props {
8+
children?: Snippet
9+
}
10+
11+
let { children }: Props = $props();
12+
let count = $state(0);
613
714
function add() {
815
count += 1;
@@ -14,10 +21,10 @@ A counter written with Svelte
1421
</script>
1522

1623
<div class="counter">
17-
<button on:click={subtract}>-</button>
24+
<button onclick={subtract}>-</button>
1825
<pre>{count}</pre>
19-
<button on:click={add}>+</button>
26+
<button onclick={add}>+</button>
2027
</div>
2128
<div class="counter-message">
22-
<slot />
29+
{@render children?.()}
2330
</div>

examples/framework-preact/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"@astrojs/preact": "^3.5.3",
1414
"@preact/signals": "^1.3.0",
15-
"astro": "^5.0.0-beta.7",
15+
"astro": "^5.0.0-beta.8",
1616
"preact": "^10.24.3"
1717
}
1818
}

examples/framework-react/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@astrojs/react": "^3.6.2",
1414
"@types/react": "^18.3.12",
1515
"@types/react-dom": "^18.3.1",
16-
"astro": "^5.0.0-beta.7",
16+
"astro": "^5.0.0-beta.8",
1717
"react": "^18.3.1",
1818
"react-dom": "^18.3.1"
1919
}

examples/framework-solid/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"astro": "astro"
1111
},
1212
"dependencies": {
13-
"@astrojs/solid-js": "^4.4.2",
14-
"astro": "^5.0.0-beta.7",
13+
"@astrojs/solid-js": "^4.4.3",
14+
"astro": "^5.0.0-beta.8",
1515
"solid-js": "^1.9.2"
1616
}
1717
}

examples/framework-svelte/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"astro": "astro"
1111
},
1212
"dependencies": {
13-
"@astrojs/svelte": "^6.0.0-beta.2",
14-
"astro": "^5.0.0-beta.7",
15-
"svelte": "^4.2.19"
13+
"@astrojs/svelte": "^6.0.0",
14+
"astro": "^5.0.0-beta.8",
15+
"svelte": "^5.1.16"
1616
}
1717
}

examples/framework-svelte/src/components/Counter.svelte

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<script lang="ts">
2-
let count = 0;
2+
import type { Snippet } from 'svelte';
3+
4+
interface Props {
5+
children?: Snippet
6+
}
7+
8+
let { children }: Props = $props();
9+
let count = $state(0);
310
411
function add() {
512
count += 1;
@@ -11,12 +18,12 @@
1118
</script>
1219

1320
<div class="counter">
14-
<button on:click={subtract}>-</button>
21+
<button onclick={subtract}>-</button>
1522
<pre>{count}</pre>
16-
<button on:click={add}>+</button>
23+
<button onclick={add}>+</button>
1724
</div>
1825
<div class="message">
19-
<slot />
26+
{@render children?.()}
2027
</div>
2128

2229
<style>

examples/framework-vue/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@astrojs/vue": "^5.0.0-beta.1",
14-
"astro": "^5.0.0-beta.7",
14+
"astro": "^5.0.0-beta.8",
1515
"vue": "^3.5.12"
1616
}
1717
}

examples/hackernews/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
},
1212
"dependencies": {
1313
"@astrojs/node": "^9.0.0-alpha.1",
14-
"astro": "^5.0.0-beta.7"
14+
"astro": "^5.0.0-beta.8"
1515
}
1616
}

0 commit comments

Comments
 (0)