Skip to content

Commit

Permalink
fix: only treat instance context exports as accessors (#9500)
Browse files Browse the repository at this point in the history
* failing test for #9499

* limit export handling to instance context

* changeset

---------

Co-authored-by: Rich Harris <[email protected]>
  • Loading branch information
Rich-Harris and Rich-Harris authored Nov 16, 2023
1 parent ede1edd commit c827b0c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sharp-gorillas-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: only treat instance context exports as accessors
2 changes: 1 addition & 1 deletion packages/svelte/src/compiler/phases/2-analyze/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ const runes_scope_tweaker = {
});
},
ExportNamedDeclaration(node, { next, state }) {
if (!node.declaration) {
if (!node.declaration || state.ast_type !== 'instance') {
return next();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<svelte:options runes />

<script context="module">
export const answer = 42;
</script>

<p>{answer}</p>

1 comment on commit c827b0c

@vercel
Copy link

@vercel vercel bot commented on c827b0c Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

svelte-5-preview – ./sites/svelte-5-preview

svelte-5-preview-svelte.vercel.app
svelte-octane.vercel.app
svelte-5-preview-git-main-svelte.vercel.app
svelte-5-preview.vercel.app

Please sign in to comment.