You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Runes mode enforcement is currently too hamfisted #987
This currently just checks for the existence of node_modules in the filename path for determining if the compiler should use runes mode.
As a result:
It does not respect any existing <svelte:options runes={false}> in .svelte files
edit: corrected, see comments
It unintentionally forces runes mode for generated files in the .svelte-kit folder
edit: partially incorrect due to (1) being incorrect
It unintentionally skips a path like src/lib/leafnode_modules, or all paths if the username happens to be node_modules
A more complete solution could be instead to scope the changes to the src folder, and also skip .svelte files that contain <svelte:options as a "I know what I'm doing" hint.
Example function:
However, I think sv cli is not the right place to apply this anyway, because if e.g. we want to update the function, that requires all users with generated configs to manually change their config; it is an inherently fragile execution of the concept.
Even the function I provided would be fragile against the user configuring a custom kit.files.src path.
I was thinking that <svelte:options in .svelte files is taking precedence to dynamicCompileOptions. It's not the case? I'll check that.
In .svelte-kit, we have generated/root.svelte with <svelte:options runes={true} />, can we have other files? I'll investagate
You are right, your isOutOfSrc look more robust.
Yes, if it start to be a complexe thing, I fully agree, it should not be in sv.
Here originally, the intent was: "Hey, in new projects, default to rune". It seems to not be that straight forward to do that, and we should fix it somewhere.
A separate issue is entirely visual with the VS Code extension not resolving the dynamicCompileOptions, e.g. if I remove the svelte:options directive, it compiles as runes mode, but vs code extension thinks it's legacy mode:
I'll raise a separate issue for that in the right repo.
For (2), I think it should be just root.svelte, which always begins with <svelte:options runes={true} />, so given (1) appears to be a non-issue, it should be fine?
My suggestion in (3) actually looks more fragile with the fact that (1) is already properly respecting the svelte:options directive:
kit.files.src is still a valid option to change
hardcoding src would not respect kit.files.src
it is difficult to dynamically resolve kit.files.src while we are in the middle of declaring the very same config file which is used to resolve it
I think it may make more sense instead to:
retain the project root relative check (so that user named node_modules does not impact our resolution)
check it is the entire folder name and not just a substring (so leafnode_modules does not get impacted, as strange of a naming scheme that may be)
import.meta.dirname was experimentally added in node v21.2.0, v20.11.0, but was only marked stable in v24.0.0, v22.16.0 - do we need to use something else to resolve the dirname?
If we still wanted to exclude .svelte-kit specifically, we run into the issue that kit.outDir is both supported and configurable, so I think it's more pragmatic to ensure any files in there do have the svelte:option runes={true|false} declared (which we already do with root.svelte)
Activity
jycouet commentedon Mar 13, 2026
Thx for looking into this @GrygrFlzr
On your points
<svelte:optionsin.sveltefiles is taking precedence todynamicCompileOptions. It's not the case? I'll check that..svelte-kit, we havegenerated/root.sveltewith<svelte:options runes={true} />, can we have other files? I'll investagateisOutOfSrclook more robust.Yes, if it start to be a complexe thing, I fully agree, it should not be in
sv.Here originally, the intent was: "Hey, in new projects, default to rune". It seems to not be that straight forward to do that, and we should fix it somewhere.
I'll report back later today ✌️
GrygrFlzr commentedon Mar 13, 2026
For (1), you are correct, it looks like
<svelte:options>does take precedence already:Properly uses legacy mode.
A separate issue is entirely visual with the VS Code extension not resolving the
dynamicCompileOptions, e.g. if I remove thesvelte:optionsdirective, it compiles as runes mode, but vs code extension thinks it's legacy mode:I'll raise a separate issue for that in the right repo.
For (2), I think it should be just
root.svelte, which always begins with<svelte:options runes={true} />, so given (1) appears to be a non-issue, it should be fine?My suggestion in (3) actually looks more fragile with the fact that (1) is already properly respecting the
svelte:optionsdirective:kit.files.srcis still a valid option to changesrcwould not respectkit.files.srckit.files.srcwhile we are in the middle of declaring the very same config file which is used to resolve itI think it may make more sense instead to:
node_modulesdoes not impact our resolution)leafnode_modulesdoes not get impacted, as strange of a naming scheme that may be)e.g.
Or the non-regex version:
import.meta.dirnamewas experimentally added in node v21.2.0, v20.11.0, but was only marked stable in v24.0.0, v22.16.0 - do we need to use something else to resolve the dirname?If we still wanted to exclude
.svelte-kitspecifically, we run into the issue thatkit.outDiris both supported and configurable, so I think it's more pragmatic to ensure any files in there do have thesvelte:option runes={true|false}declared (which we already do withroot.svelte)sacrosanctic commentedon Mar 17, 2026
no, we're already using this in eslint.config.js
sacrosanctic commentedon Mar 20, 2026
@GrygrFlzr the PR didn't close this issue since I wasn't sure if all the concerns were addressed. Can you follow up?
GrygrFlzr commentedon Mar 21, 2026
Yep, looks fine for the sv cli side, thank you.