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 <rich.harris@vercel.com>
pull/9507/head
Rich Harris 1 year ago committed by GitHub
parent ede1edd314
commit c827b0c772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: only treat instance context exports as accessors

@ -680,7 +680,7 @@ const runes_scope_tweaker = {
});
},
ExportNamedDeclaration(node, { next, state }) {
if (!node.declaration) {
if (!node.declaration || state.ast_type !== 'instance') {
return next();
}

@ -0,0 +1,9 @@
import { test } from '../../test';
export default test({
html: `<p>42</p>`,
async test({ assert, target, window, component }) {
assert.equal(component.answer, undefined);
}
});

@ -0,0 +1,7 @@
<svelte:options runes />
<script context="module">
export const answer = 42;
</script>
<p>{answer}</p>
Loading…
Cancel
Save