Skip to content

Commit c827b0c

Browse files
authored
fix: only treat instance context exports as accessors (#9500)
* failing test for #9499 * limit export handling to instance context * changeset --------- Co-authored-by: Rich Harris <[email protected]>
1 parent ede1edd commit c827b0c

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

.changeset/sharp-gorillas-impress.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: only treat instance context exports as accessors

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ const runes_scope_tweaker = {
680680
});
681681
},
682682
ExportNamedDeclaration(node, { next, state }) {
683-
if (!node.declaration) {
683+
if (!node.declaration || state.ast_type !== 'instance') {
684684
return next();
685685
}
686686

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
html: `<p>42</p>`,
5+
6+
async test({ assert, target, window, component }) {
7+
assert.equal(component.answer, undefined);
8+
}
9+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<svelte:options runes />
2+
3+
<script context="module">
4+
export const answer = 42;
5+
</script>
6+
7+
<p>{answer}</p>

0 commit comments

Comments
 (0)