Skip to content

Svelte 5: $ prefix is reserved for script with context=module #9786

@mquandalle

Description

@mquandalle

Describe the bug

The following code used in a Svelte 4 app throws an error on Svelte 5:

<script context="module">
	import { writable, derived } from "svelte/store";

	const a = writable(1)
	const b = derived([a], ([$a]) => $a * 2)
</script>
<div>hello world</div>

If I remove the context=module, the code works. I think this file shouldn't run in runes mode since it's not using runes.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE0WOQQqDMBBFrzIMLrQI0i6tCj2HcRF1hICakIy2Rbx7Ryrt8s-f93kbDmakgHm94awnwhwfzmGK_HZHCCuNTJKDXXx3XIrQeeMYOjszvbhUONl-GUlhpWbFZnLWM2zw9IZ1O1IKPXmzUg87DN5OoM7RLLD1gt0FE1D2AoOG8kfG1-RftFKcQ3GtmxTiOtJNAmUFkYYL3OS3yL5ulfiKlBkM9ZizX2hv9g_Pi9Ht6gAAAA==

Logs

No response

System Info

Svelte 5

Severity

annoyance

Metadata

Metadata

Assignees

Labels

bugcompilerChanges relating to the compiler

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions