language-tools
language-tools copied to clipboard
Could component mode be detected and shown?
Description
During the transition to Svelte 5, if the mode is not globally enforced, unintentionally being in one mode or the other could be undesirable. E.g. legacy mode leads to coarse grained reactivity which can cause issues and just has worse performance.
Seen unintended mode switches happen when people refactored the last variable using a rune into a separate file.
Proposed solution
If mode is detectable, show mode via CodeLens at the top of the file.
Ideally this would be configurable, e.g. via an array specifying the modes one is interested in. Something like:
{
"svelte.showComponentMode": ["legacy", "runes"],
}
Alternatives
There might be other ways of making users aware of the mode or mode switches happening. E.g. on switch a notification could be shown, but this seems too intrusive.
Additional Information, eg. Screenshots
No response
Now we have a command to migrate components into rune mode maybe we can also make this component mode codelens a button for migrating. Kind of like the one in the REPL. Either replace the "LEGCAY MODE" with "Migrate to rune" or a separate one for migration.
I'll implement the code lens for the legacy/runes mode indicator. The migration lens not for now, because it might have false positives (i.e. not do anything or fail)
@dummdidumm It seems like the mode lens overwrites the component references lens (#2378), could those be combined?
@dummdidumm How can I disable the indicator? There's an option like svelte.disableRuneModeIndicator?
I added an option, will release early next week