Skip to content

Commit 33a159c

Browse files
fix: allow store as initial value for props in ssr (#12885)
1 parent c09dece commit 33a159c

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

.changeset/smart-poets-care.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: allow store as initial value for props in ssr

packages/svelte/src/compiler/phases/3-transform/server/visitors/VariableDeclaration.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ export function VariableDeclaration(node, context) {
3939
}
4040
}
4141
});
42-
declarations.push(b.declarator(id, b.id('$$props')));
42+
declarations.push(
43+
b.declarator(/** @type {Pattern} */ (context.visit(id)), b.id('$$props'))
44+
);
4345
continue;
4446
}
4547

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { test } from '../../test';
2+
3+
export default test({});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script lang="ts">
2+
import { writable } from 'svelte/store';
3+
const page = writable(1);
4+
const { value = $page } = $props();
5+
</script>
6+
7+
{value}

0 commit comments

Comments
 (0)