Skip to content

Rune mode not set when referencing external files using runes #16199

Open
@rogerfar

Description

@rogerfar

Describe the bug

If you store state in another file, for example:

class StoreClass
{
	 #store = $state(['Item 1', 'Item 2']);

	get store() {
		return this.#store;
	}

	remove() {
		this.#store = this.#store.slice(1);
	}
}

const store = new StoreClass();
export default store;

And you consume it in your component:

<script>
	import store from './Store.svelte.ts';

	const remove = () =>{
		store.remove();
	}

	//$inspect(store.store);
</script>

{#each store.store as item (item)}
	{item}<br/>
{/each}

<button onclick={() => remove()}>Remove item</button>

It will not remove the items when clicking Remove item.

BUT, if you uncomment $inspect(store.store);, it will work.

Reproduction

Broken in:
https://svelte.dev/playground/a89f6d819f524ca78055fb90c63c51ea?version=5.34.5
https://svelte.dev/playground/a89f6d819f524ca78055fb90c63c51ea?version=5.34.4

Works in:
https://svelte.dev/playground/a89f6d819f524ca78055fb90c63c51ea?version=5.34.3

Logs

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700
    Memory: 27.36 GB / 63.79 GB
  Binaries:
    Node: 22.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 11.4.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (137.0.3296.68)
    Internet Explorer: 11.0.19041.5794

Severity

blocking all usage of svelte

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions