Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svelte 5: Forcing runes mode causes issues with generated code. #11022

Closed
brunnerh opened this issue Nov 12, 2023 · 2 comments · Fixed by #11028
Closed

Svelte 5: Forcing runes mode causes issues with generated code. #11022

brunnerh opened this issue Nov 12, 2023 · 2 comments · Fixed by #11028
Labels

Comments

@brunnerh
Copy link
Member

brunnerh commented Nov 12, 2023

Describe the bug

Setting compilerOptions: { runes: true } causes errors like this:

CompileError: Cannot use `export let` in runes mode — use $props instead
    at new CompileError (/home/projects/sveltejs-kit-template-default-alrzrc/node_modules/svelte/src/compiler/errors.js:544:3)
    at Module.error (/home/projects/sveltejs-kit-template-default-alrzrc/node_modules/svelte/src/compiler/errors.js:582:8)
    at ExportNamedDeclaration (/home/projects/sveltejs-kit-template-default-alrzrc/node_modules/svelte/src/compiler/phases/2-analyze/validation.js:646:14)
    at go (/home/projects/sveltejs-kit-template-default-alrzrc/node_modules/svelte/src/compiler/phases/visitors.js:62:5)
    at visitor (/home/projects/sveltejs-kit-template-default-alrzrc/node_modules/svelte/src/compiler/phases/visitors.js:77:4)
    at go (/home/projects/sveltejs-kit-template-default-alrzrc/node_modules/svelte/src/compiler/phases/visitors.js:62:5)
    at visitor (/home/projects/sveltejs-kit-template-default-alrzrc/node_modules/svelte/src/compiler/phases/visitors.js:77:4)
    at Object.next (/home/projects/sveltejs-kit-template-default-alrzrc/node_modules/zimmerframe/src/walk.js:119:21)
    at go (/home/projects/sveltejs-kit-template-default-alrzrc/node_modules/svelte/src/compiler/phases/visitors.js:58:29)
    at next (/home/projects/sveltejs-kit-template-default-alrzrc/node_modules/svelte/src/compiler/phases/visitors.js:68:7)

Found by Swarleys on Discord.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-alrzrc?file=svelte.config.js

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
    Memory: 5.07 GB / 31.92 GB
  Binaries:
    Node: 18.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.2.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.6.9 - ~\AppData\Local\pnpm\pnpm.EXE
  Browsers:
    Chrome: 119.0.6045.105
    Edge: Spartan (44.19041.3570.0), Chromium (119.0.2151.58)
    Internet Explorer: 11.0.19041.3570

Severity

annoyance

Additional Information

No response

@Jerboas86
Copy link

I think it is the expected behavior. You ask the compiler to enforce runes syntax at the project level. Doing that, you are not allowed to use svelte 4 reactivity syntax

When you opt in to runes mode, the non-runes features listed in the 'What this replaces' sections are no longer available.

see docs

@brunnerh
Copy link
Member Author

It's not the user code causing the problem and SvelteKit being a first-party framework probably should be able to take that flag into account.

If it causes an unreasonable amount of work to generate code in one format or the other (depending on flag), SvelteKit could at least throw an error that explains the situation, guiding the user.

Generated root.svelte file that has the prop exports:

<!-- This file is generated by @sveltejs/kit — do not edit it! -->
<script>
	import { setContext, afterUpdate, onMount, tick } from 'svelte';
	import { browser } from '$app/environment';

	// stores
	export let stores;
	export let page;

	export let constructors;
	export let components = [];
	export let form;
	export let data_0 = null;
	export let data_1 = null;

...

dummdidumm added a commit that referenced this issue Nov 13, 2023
- fixes #11027 (not the underlying issue, but the problem within SvelteKit)
- fixes #11022
dummdidumm added a commit that referenced this issue Nov 14, 2023
- fixes #11027 (not the underlying issue, but the problem within SvelteKit)
- fixes #11022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants