Describe the bug
Vite merges scripts together from .svelte files that the Svelte compiler treats as separate scripts:
Reproduction
npm init svelte@next my-app
cd my-app
Add to src/routes/index.svelte:
<script context="module">
let top;
</script>
<script>
export let top;
</script>
And then run npm run dev or npm run build
System Info
Used Package Manager
npm
Logs
html:src/routes/index.svelte:59:12: error: "top" has already been declared
Validations
Describe the bug
Vite merges scripts together from
.sveltefiles that the Svelte compiler treats as separate scripts:vite/packages/vite/src/node/optimizer/scan.ts
Line 247 in 79c2a49
Reproduction
Add to
src/routes/index.svelte:And then run
npm run devornpm run buildSystem Info
Used Package Manager
npm
Logs
html:src/routes/index.svelte:59:12: error: "top" has already been declaredValidations