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

feat!: migrate to Svelte 5 #145

Merged
merged 21 commits into from
Feb 7, 2025
Merged

Conversation

ampled
Copy link
Contributor

@ampled ampled commented Nov 9, 2024

Description

This is my attempt to kickstart svelte 5 support. It's probably enough to just allow svelte 5 as a peerDependency considering svelte 5 has backwards compatibility, but I guess it's nice to have this as a starting point for a full migration for projects that use runes mode only.

All tests are passing, though I had to add a line to remove comments from rendered output before comparing it to expected output.

Changes

  • Migrated all Svelte components using 1st party migration script, then cleaning up by hand
  • Added recommended svelte testing plugin to vite-config following Testing Library setup guide
  • Updated packages required for svelte 5 and getting tests running

Solves #78 and #127 (make components optional)

Copy link

vercel bot commented Nov 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
svelte-portabletext ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 3:38pm

@TheOnlyTails
Copy link

Would be amazing to see this merged!

@ampled
Copy link
Contributor Author

ampled commented Dec 10, 2024

@TheOnlyTails

Would be amazing to see this merged!

Until then, you can use this: https://www.npmjs.com/package/@eirikk/portabletext-2-svelte-5

Follow the instructions in the README to not have to rewrite any imports

@rdunk rdunk self-assigned this Jan 28, 2025
@mikehwagz
Copy link

Anything I can do to help get this merged? It is disappointing that this has taken so long considering Svelte 5 has been out now for a considerable amount of time.

@rdunk
Copy link
Member

rdunk commented Feb 6, 2025

Hello, we're releasing some significant updates for Svelte shortly. I'll get this reviewed and merged by the end of the week. Thanks for your patience.

Copy link
Member

@rdunk rdunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this, I've done an initial pass and it all looks pretty good to me.

I've just made some suggestions to primarily reduce intermediate $derived values, but I don't think this is critical. I'm by no means an expert in Svelte's reactivity system so there could be good reason for them, let me know what you think either way and I'll get this approved, merged and released asap.

Also, I've run benchmarks against these suggested changes (I'll add the benchmark code in another PR) as I wondered if the intermediate $derived values were performance optimisations, but I haven't been able to discern any meaningful difference. So my suggestions are largely addressing perceived readability, this is subjective so I'll leave it up to you whether or not you want to accept them.

@rdunk rdunk changed the title Svelte 5 migration feat: migrate to Svelte 5 Feb 6, 2025
@rdunk rdunk changed the title feat: migrate to Svelte 5 feat!: migrate to Svelte 5 Feb 6, 2025
ampled and others added 3 commits February 7, 2025 11:23
Co-authored-by: Rupert Dunk <rupert@rupertdunk.com>
Co-authored-by: Rupert Dunk <rupert@rupertdunk.com>
Co-authored-by: Rupert Dunk <rupert@rupertdunk.com>
ampled and others added 3 commits February 7, 2025 11:32
Co-authored-by: Rupert Dunk <rupert@rupertdunk.com>
Co-authored-by: Rupert Dunk <rupert@rupertdunk.com>
ampled and others added 3 commits February 7, 2025 11:36
Co-authored-by: Rupert Dunk <rupert@rupertdunk.com>
Co-authored-by: Rupert Dunk <rupert@rupertdunk.com>
Co-authored-by: Rupert Dunk <rupert@rupertdunk.com>
@ampled
Copy link
Contributor Author

ampled commented Feb 7, 2025

I've just made some suggestions to primarily reduce intermediate $derived values, but I don't think this is critical. I'm by no means an expert in Svelte's reactivity system so there could be good reason for them, let me know what you think either way and I'll get this approved, merged and released asap.

Great! I accepted all suggestions. All the $derived values were directly translated from the existing code, taking old "reactive values" like $: value = portableText.value and converting them to let {value} = $derived(portableText) so no issues with improving on this re: readability ⭐

@rdunk
Copy link
Member

rdunk commented Feb 7, 2025

Awesome, thank you 🙇 . If you wouldn't mind rebuilding the package-lock.json on your branch to resolve the conflicts I'll get this merged and released.

@ampled ampled removed their assignment Feb 7, 2025
@rdunk rdunk merged commit 6f17aaf into portabletext:main Feb 7, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants