Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Nov 15, 2024
2 parents 4364bff + 5509117 commit 671f50c
Show file tree
Hide file tree
Showing 85 changed files with 555 additions and 694 deletions.
78 changes: 46 additions & 32 deletions benchmark/bench/codspeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,62 @@ import path from 'node:path';
import { withCodSpeed } from '@codspeed/tinybench-plugin';
import { Bench } from 'tinybench';
import { exec } from 'tinyexec';
import { renderPages } from '../make-project/render-default.js';
import { astroBin } from './_util.js';

export async function run({ memory: _memory, render, stress: _stress }) {
const options = {
iterations: 10,
};
const bench = process.env.CODSPEED ? withCodSpeed(new Bench(options)) : new Bench(options);
let app;
bench.add(
'Rendering',
async () => {
await exec(astroBin, ['build'], {
nodeOptions: {
cwd: render.root,
stdio: 'inherit',
},
});

const entry = new URL('./dist/server/entry.mjs', `file://${render.root}`);
const { manifest, createApp } = await import(entry);
const streamingApp = createApp(manifest, true);
const nonStreamingApp = createApp(manifest, false);
bench
.add('Rendering: streaming [true], .astro file', async () => {
console.info('Start task.');
const result = {};
for (const fileName of renderPages) {
const pathname = '/' + fileName.slice(0, -path.extname(fileName).length);
const request = new Request(new URL(pathname, 'http://exmpale.com'));
const response = await app.render(request);
const html = await response.text();
if (!result[pathname]) result[pathname] = [];
result[pathname].push(html);
}
const request = new Request(new URL('http://exmpale.com/astro'));
await streamingApp.render(request);
console.info('Finish task.');
return result;
},
{
async beforeAll() {
// build for rendering
await exec(astroBin, ['build'], {
nodeOptions: {
cwd: render.root,
stdio: 'inherit',
},
});
})
.add('Rendering: streaming [true], .md file', async () => {
console.info('Start task.');
const request = new Request(new URL('http://exmpale.com/md'));
await streamingApp.render(request);
console.info('Finish task.');
})
.add('Rendering: streaming [true], .mdx file', async () => {
console.info('Start task.');
const request = new Request(new URL('http://exmpale.com/mdx'));
await streamingApp.render(request);
console.info('Finish task.');
})

const entry = new URL('./dist/server/entry.mjs', `file://${render.root}`);
const { manifest, createApp } = await import(entry);
app = createApp(manifest);
app.manifest = manifest;
},
},
);
.add('Rendering: streaming [false], .astro file', async () => {
console.info('Start task.');
const request = new Request(new URL('http://exmpale.com/astro'));
await nonStreamingApp.render(request);
console.info('Finish task.');
})
.add('Rendering: streaming [false], .md file', async () => {
console.info('Start task.');
const request = new Request(new URL('http://exmpale.com/md'));
await nonStreamingApp.render(request);
console.info('Finish task.');
})
.add('Rendering: streaming [false], .mdx file', async () => {
console.info('Start task.');
const request = new Request(new URL('http://exmpale.com/mdx'));
await nonStreamingApp.render(request);
console.info('Finish task.');
});

await bench.run();
console.table(bench.table());
Expand Down
2 changes: 0 additions & 2 deletions benchmark/packages/adapter/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ applyPolyfills();

class MyApp extends App {
#manifest: SSRManifest | undefined;
#streaming: boolean;
constructor(manifest: SSRManifest, streaming = false) {
super(manifest, streaming);
this.#manifest = manifest;
this.#streaming = streaming;
}

async render(request: Request) {
Expand Down
4 changes: 2 additions & 2 deletions examples/framework-multiple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@astrojs/preact": "^3.5.3",
"@astrojs/react": "^3.6.2",
"@astrojs/solid-js": "^4.4.2",
"@astrojs/solid-js": "^4.4.3",
"@astrojs/svelte": "^6.0.0-beta.2",
"@astrojs/vue": "^5.0.0-beta.1",
"@types/react": "^18.3.12",
Expand All @@ -22,7 +22,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"solid-js": "^1.9.3",
"svelte": "^4.2.19",
"svelte": "^5.1.16",
"vue": "^3.5.12"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
A counter written with Svelte
-->
<script lang="ts">
let count = 0;
import type { Snippet } from 'svelte';
interface Props {
children?: Snippet
}
let { children }: Props = $props();
let count = $state(0);
function add() {
count += 1;
Expand All @@ -14,10 +21,10 @@ A counter written with Svelte
</script>

<div class="counter">
<button on:click={subtract}>-</button>
<button onclick={subtract}>-</button>
<pre>{count}</pre>
<button on:click={add}>+</button>
<button onclick={add}>+</button>
</div>
<div class="counter-message">
<slot />
{@render children?.()}
</div>
2 changes: 1 addition & 1 deletion examples/framework-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/solid-js": "^4.4.2",
"@astrojs/solid-js": "^4.4.3",
"astro": "^5.0.0-beta.8",
"solid-js": "^1.9.2"
}
Expand Down
4 changes: 2 additions & 2 deletions examples/framework-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/svelte": "^6.0.0-beta.2",
"@astrojs/svelte": "^6.0.0",
"astro": "^5.0.0-beta.8",
"svelte": "^4.2.19"
"svelte": "^5.1.16"
}
}
15 changes: 11 additions & 4 deletions examples/framework-svelte/src/components/Counter.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<script lang="ts">
let count = 0;
import type { Snippet } from 'svelte';
interface Props {
children?: Snippet
}
let { children }: Props = $props();
let count = $state(0);
function add() {
count += 1;
Expand All @@ -11,12 +18,12 @@
</script>

<div class="counter">
<button on:click={subtract}>-</button>
<button onclick={subtract}>-</button>
<pre>{count}</pre>
<button on:click={add}>+</button>
<button onclick={add}>+</button>
</div>
<div class="message">
<slot />
{@render children?.()}
</div>

<style>
Expand Down
4 changes: 2 additions & 2 deletions examples/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
},
"dependencies": {
"@astrojs/node": "^9.0.0-alpha.1",
"@astrojs/svelte": "^6.0.0-beta.2",
"@astrojs/svelte": "^6.0.0",
"astro": "^5.0.0-beta.8",
"svelte": "^4.2.19"
"svelte": "^5.1.16"
}
}
5 changes: 2 additions & 3 deletions examples/ssr/src/components/AddToCart.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script>
import { addToUserCart } from '../api';
export let id = 0;
export let name = '';
let { id, name } = $props()
function notifyCartItem(id) {
window.dispatchEvent(new CustomEvent('add-to-cart', {
Expand Down Expand Up @@ -49,6 +48,6 @@ button:hover {
text-transform: uppercase;
}
</style>
<button on:click={addToCart}>
<button click={addToCart}>
<span class="pretext">Add to cart</span>
</button>
4 changes: 2 additions & 2 deletions examples/ssr/src/components/Cart.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
export let count = 0;
let { count } = $props()
let items = new Set();
function onAddToCart(ev) {
Expand Down Expand Up @@ -27,7 +27,7 @@
font-size: 24px;
}
</style>
<svelte:window on:add-to-cart={onAddToCart}/>
<svelte:window onadd-to-cart={onAddToCart}/>
<a href="/cart" class="cart">
<span class="material-icons cart-icon">shopping_cart</span>
<span class="count">{count}</span>
Expand Down
8 changes: 8 additions & 0 deletions packages/astro/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,14 @@
- Updated dependencies [[`83a2a64`](https://github.com/withastro/astro/commit/83a2a648418ad30f4eb781d1c1b5f2d8a8ac846e)]:
- @astrojs/[email protected]

## 4.16.13

### Patch Changes

- [#12436](https://github.com/withastro/astro/pull/12436) [`453ec6b`](https://github.com/withastro/astro/commit/453ec6b12f8c021e0bd0fd0ea9f71c8fc280f4b1) Thanks [@martrapp](https://github.com/martrapp)! - Fixes a potential null access in the clientside router

- [#12392](https://github.com/withastro/astro/pull/12392) [`0462219`](https://github.com/withastro/astro/commit/0462219612183b65867aaaef9fa538d89f201999) Thanks [@apatel369](https://github.com/apatel369)! - Fixes an issue where scripts were not correctly injected during the build. The issue was triggered when there were injected routes with the same `entrypoint` and different `pattern`

## 4.16.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/client-only/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"solid-js": "^1.9.3",
"svelte": "^4.2.19",
"svelte": "^5.1.16",
"vue": "^3.5.12"
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

<script>
export let id;
let children;
let count = 0;
let { id, children } = $props();
let count = $state(0);
function add() {
count += 1;
Expand All @@ -14,11 +13,11 @@
</script>

<div {id} class="counter">
<button class="decrement" on:click={subtract}>-</button>
<button class="decrement" onclick={subtract}>-</button>
<pre>{ count }</pre>
<button class="increment" on:click={add}>+</button>
<button class="increment" onclick={add}>+</button>
<div class="children">
<slot />
{@render children?.()}
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"react-dom": "^18.3.1",
"sass": "^1.80.6",
"solid-js": "^1.9.3",
"svelte": "^4.2.19",
"svelte": "^5.1.16",
"vue": "^3.5.12"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
export let shouldThrow = true;
let { shouldThrow } = $props();
if (shouldThrow) {
throw new Error('SvelteRuntimeError');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"solid-js": "^1.9.3",
"svelte": "^4.2.19",
"svelte": "^5.1.16",
"vue": "^3.5.12"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<script>
export let id;
let count = 0;
let { id, children } = $props();
let count = $state(0);
function add() {
count += 1;
Expand All @@ -13,12 +13,12 @@
</script>

<div {id} class="counter">
<button class="decrement" on:click={subtract}>-</button>
<button class="decrement" onclick={subtract}>-</button>
<pre>{ count }</pre>
<button class="increment" on:click={add}>+</button>
<button class="increment" onclick={add}>+</button>
</div>
<div class="counter-message">
<slot />
{@render children?.()}
</div>

<style>
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/nested-in-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"solid-js": "^1.9.3",
"svelte": "^4.2.19",
"svelte": "^5.1.16",
"vue": "^3.5.12"
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

<script>
export let id;
let children;
let count = 0;
let { id, children } = $props();
let count = $state(0);
function add() {
count += 1;
Expand All @@ -14,11 +13,11 @@
</script>

<div {id} class="counter">
<button class="decrement" on:click={subtract}>-</button>
<button class="decrement" onclick={subtract}>-</button>
<pre id={`${id}-count`}>{ count }</pre>
<button id={`${id}-increment`} class="increment" on:click={add}>+</button>
<button id={`${id}-increment`} class="increment" onclick={add}>+</button>
<div class="children">
<slot />
{@render children?.()}
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/nested-in-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"solid-js": "^1.9.3",
"svelte": "^4.2.19",
"svelte": "^5.1.16",
"vue": "^3.5.12"
}
}
Loading

0 comments on commit 671f50c

Please sign in to comment.