carta icon indicating copy to clipboard operation
carta copied to clipboard

Svelte 5

Open boylett opened this issue 1 year ago • 1 comments

Are there plans for Svelte 5 support? :)

boylett avatar Aug 20 '24 18:08 boylett

Hi! I've not tried Svelte 5 yet. I think it was supposed to be backward compatible(?)

BearToCode avatar Aug 21 '24 07:08 BearToCode

Yes and no. They do have some breaking changes that they can't get around, although I haven't seen those impact this library (yet). They also need library authors to create a separate branch for Svelte 5 changes, particularly since eventually the changes will become breaking.

It'll be advantageous to move to Svelte 5 as it addresses some shortcomings for the environment, although some people find it controversial, I suppose ("Oh no! It's become ReactJS!").

Currently, I am trying to use this library with Svelte 5, and while it works, I'm constantly having to apply --force or --legacy-peer-deps to work with my project.

FWIW, this site might clarify some things, now that Svelte 5 has reached release candidate phases.

tvanriper avatar Oct 08 '24 09:10 tvanriper

I checked out the resources you provided and then added svelte ^5.0.0 to the package.json of almost all packages. Only the component plugin requires some changes and a new version would need to be published.

Feel free to answer here or open new issues for anything going wrong in the new Svelte version!

BearToCode avatar Oct 17 '24 17:10 BearToCode

@BearToCode hi! Long time no see 🤗 Svelte 5 is officially alive! 🥳 https://svelte.dev/blog/svelte-5-is-alive

mithi avatar Oct 26 '24 06:10 mithi

I also want to add that by using the new CLI command sv migrate, upgrading to Svelte 5 might be painless. The migration guide gives you an overview of the changes.

katriellucas avatar Nov 03 '24 23:11 katriellucas

Any updates on this?

DJMogens avatar Feb 16 '25 14:02 DJMogens

Any updates on this?

Carta should work fine with Svelte 5. I tried using that in a project of mine and everything seemed ok. Did you experience any issue?

BearToCode avatar Feb 16 '25 19:02 BearToCode

I had a problem with the components plugin, as it instanciates the components in a legacy matter, treating it as a class.

I have to set a compatibility flag to the compiler for it to work.

https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes

DJMogens avatar Feb 17 '25 08:02 DJMogens

Just tried to run the migration script, and most packages are pretty much unaffected:

Here is a screenshot of the files modified by running it in each of the packages (excluding the package.json modifications) Image

It migrates things like:

Image

Image

DJMogens avatar Feb 17 '25 11:02 DJMogens

You're right, the component plugin still doesn't work in Svelte 5. A quick fix could be made to make it work, but it's probably better to upgrade the whole project at the same time. I saw that @mtsgrd also opened a PR to upgrade (#146 ). I'll look into it as soon as I can, but it will probably take some time. Meanwhile, you said that you can temporarily work with it using a compiler flag, right?

Aside from the changes generated, the following will also have to be updated:

https://github.com/BearToCode/carta/blob/4637d26fcddc1b673a66092e904ddf99d840d4c0/packages/plugin-component/src/lib/svelte.ts#L131C1-L134C6

to something like:

mount(component.component, {
	target: wrapper,
	props
});

But I haven't tried it yet.

BearToCode avatar Feb 18 '25 21:02 BearToCode