language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Could component mode be detected and shown?

Open brunnerh opened this issue 1 year ago • 1 comments

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.

image

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

brunnerh avatar Jun 25 '24 11:06 brunnerh

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.

ezgif-5-9261a48225

jasonlyu123 avatar Oct 19 '24 03:10 jasonlyu123

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 avatar Oct 31 '24 17:10 dummdidumm

@dummdidumm It seems like the mode lens overwrites the component references lens (#2378), could those be combined?

brunnerh avatar Nov 08 '24 12:11 brunnerh

@dummdidumm How can I disable the indicator? There's an option like svelte.disableRuneModeIndicator?

adwher avatar Nov 09 '24 13:11 adwher

I added an option, will release early next week

dummdidumm avatar Nov 09 '24 14:11 dummdidumm