Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to svelte 5 #12364

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/framework-multiple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"solid-js": "^1.9.3",
"svelte": "^4.2.19",
"svelte": "^5.1.9",
"vue": "^3.5.12"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
A counter written with Svelte
-->
<script lang="ts">
let count = 0;
let count = $state(0);

function add() {
count += 1;
Expand All @@ -14,9 +14,9 @@ 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 />
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"dependencies": {
"@astrojs/svelte": "^5.7.2",
"astro": "^4.16.8",
"svelte": "^4.2.19"
"svelte": "^5.1.9"
}
}
6 changes: 3 additions & 3 deletions examples/framework-svelte/src/components/Counter.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
let count = 0;
let count = $state(0);

function add() {
count += 1;
Expand All @@ -11,9 +11,9 @@
</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 />
Expand Down
2 changes: 1 addition & 1 deletion examples/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"@astrojs/node": "^8.3.4",
"@astrojs/svelte": "^5.7.2",
"astro": "^4.16.8",
"svelte": "^4.2.19"
"svelte": "^5.1.9"
}
}
3 changes: 1 addition & 2 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
2 changes: 1 addition & 1 deletion 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
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.9",
"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 } = $props();
let count = $state(0);

function add() {
count += 1;
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.4",
"solid-js": "^1.9.3",
"svelte": "^4.2.19",
"svelte": "^5.1.9",
"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 @@ -18,7 +18,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"solid-js": "^1.9.3",
"svelte": "^4.2.19",
"svelte": "^5.1.9",
"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 } = $props();
let count = $state();

function add() {
count += 1;
Expand All @@ -13,9 +13,9 @@
</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 />
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.9",
"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 } = $props();
let count = $state();

function add() {
count += 1;
Expand All @@ -14,9 +13,9 @@
</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 />
</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.9",
"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 } = $props();
let count = $state();

function add() {
count += 1;
Expand All @@ -14,9 +13,9 @@
</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 />
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/nested-in-solid/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.9",
"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 } = $props();
let count = $state();

function add() {
count += 1;
Expand All @@ -14,9 +13,9 @@
</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 />
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/nested-in-svelte/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.9",
"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 } = $props();
let count = $state();

function add() {
count += 1;
Expand All @@ -14,9 +13,9 @@
</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 />
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/nested-in-vue/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.9",
"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 } = $props();
let count = $state();

function add() {
count += 1;
Expand All @@ -14,9 +13,9 @@
</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 />
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/nested-recursive/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.9",
"vue": "^3.5.12"
},
"scripts": {
Expand Down
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 } = $props();
let count = $state();

function add() {
count += 1;
Expand All @@ -14,9 +13,9 @@
</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 />
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/fixtures/svelte-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"@astrojs/mdx": "workspace:*",
"@astrojs/svelte": "workspace:*",
"astro": "workspace:*",
"svelte": "^4.2.19"
"svelte": "^5.1.9"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
export let id: string;
export let count: number = 0;
let { id, count } = $props<{ id: number, count: number }>();

function add() {
count += 1;
Expand All @@ -12,9 +11,9 @@
</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 id={`${id}-message`} class="message">
<slot />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script>
export let id;
let { id } = $props();
</script>
<div {id}>Slot goes here:<slot /></div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
export let id: string;
let { id } = $props<{ id: string }>();
</script>

<div {id}>Framework client:only component</div>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script>
let isNavOpen = false;
let isNavOpen = $state(false);
const toggleNav = () => (isNavOpen = !isNavOpen);
</script>

<button id="toggle" on:click={toggleNav}>
<button id="toggle" onclick={toggleNav}>
{#if isNavOpen}
<slot name="open" />
{:else}
Expand Down
Loading
Loading