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

Will the library support Svelte 5? #318

Open
0x5374656c6c6172 opened this issue Feb 19, 2024 · 17 comments
Open

Will the library support Svelte 5? #318

0x5374656c6c6172 opened this issue Feb 19, 2024 · 17 comments

Comments

@0x5374656c6c6172
Copy link

No description provided.

@carbogninalberto
Copy link
Collaborator

We will make it happen at some point if @ItalyPaleAle approves it!

@ItalyPaleAle
Copy link
Owner

Yes support for Svelte 5 is definitely a goal. I'll look into it when the Svelte 5 project becomes a bit more stable

(And of course, PRs are welcome :) )

@tgf9
Copy link

tgf9 commented May 18, 2024

Svelte recently published their Svelte 5 release candidate.

Svelte 5 is now in the Release Candidate phase. This means that the design of the framework is largely settled, with no anticipated breaking changes between now and the stable release, and that the most egregious bugs have been stomped.

https://svelte.dev/blog/svelte-5-release-candidate

And Rich offered a few pointers on migrating libs in the Svelte5 RC release announcement

@carbogninalberto
Copy link
Collaborator

From this page @tgf9 you can also monitor the actual status: https://svelte-5-preview.vercel.app/status

We are already working on the migration to make it available as soon as v5 is ready 👍

@ItalyPaleAle
Copy link
Owner

Should have something ready in the next few days :)

I believe the router should still work with v5 for now, temporarily, thanks to the backwards-compatibility

@oneezy
Copy link

oneezy commented Sep 13, 2024

Should have something ready in the next few days :)

any updates on this?

@carbogninalberto
Copy link
Collaborator

carbogninalberto commented Oct 20, 2024

Svelte 5 has been officially released, we are looking forward to supporting it in the next few weeks!

@carbogninalberto
Copy link
Collaborator

carbogninalberto commented Oct 24, 2024

I just looked into it, if you upgrade right now to svelte 5 it will work fine, I didn't find any issue this thanks to the backward compatibility, but if you want to be sure wait a little bit until I prepare the PR :)

Quick note:
if you absolutely need to upgrade to access the new features like the snippets, for a while set this in your vite.config.js:

compilerOptions: {
  compatibility: {
    componentApi: 4
  }
},

Stay tuned!

@nyhr
Copy link

nyhr commented Oct 29, 2024

Svelte 5 is not compatible with svelte-spa-router/wrap

'Type 'Component<$$ComponentProps, {}, "">' is not assignable to type 'ComponentType'.
Type 'Component<$$ComponentProps, {}, "">' is not assignable to type 'new (options: ComponentConstructorOptions<Record<string, any>>) => SvelteComponent<Record<string, any>, any, any>'.
Type 'Component<$$ComponentProps, {}, "">' provides no match for the signature 'new (options: ComponentConstructorOptions<Record<string, any>>): SvelteComponent<Record<string, any>, any, any>'

@ItalyPaleAle
Copy link
Owner

Hey folks, thanks for your patience. I've been incredibly busy with my day job and I'm currently on vacation. I'm hoping to get this done in the next week.

@SaadiSave
Copy link

SaadiSave commented Oct 30, 2024

@carbogninalberto Could you please explain how you got it working on Svelte 5? I am trying this, but it does not work:

BlogPost.svelte

<script lang="ts">
    import { onMount } from "svelte"
    import preprocessPost from "../lib/preprocess-post"

    let { path: string } = $props()

    let content = $state("")

    onMount(async () => {
        const post = await fetch(path)

        content = await post.text()

        content = preprocessPost(content)
    })
</script>

{@html content}

App.svelte

<script lang="ts">
  import BlogPost from "./components/BlogPost.svelte"
  import Router from "svelte-spa-router"
  import posts from "./lib/posts"

  const routes = {
      '/blog/:path': BlogPost,
  }
</script>

<ul>
    {#each posts as post}
        <li><a href="#/blog/{post.path}">{post.title}</a></li>
    {/each}
</ul>

<Router routes={routes} />

I am trying to bind path and use it to dynamically load a blog post

@carbogninalberto
Copy link
Collaborator

carbogninalberto commented Nov 1, 2024

on this line update from:

<li><a href="#/blog/{post.path}">{post.title}</a></li>

to

<li><a href="/#/blog/{post.path}">{post.title}</a></li>

or

<li><a href="/blog/{post.path}" use:link>{post.title}</a></li>

@betim
Copy link

betim commented Nov 4, 2024

export let params = {} works as long as runes are not used. The moment $state() or any rune is present then it breaks.

A workaround:

// http://localhost:5173/#/admin/order/20
let params = window.location.href.split("/");
let id = params[params.length - 1];

Hopefully gets resolved soon.

@carbogninalberto
Copy link
Collaborator

I have looked into the support for svelte 5 it will take a bit longer because there are some parts of the code that need a refactor.

I will open the PR soon.

@mateothegreat
Copy link

mateothegreat commented Nov 17, 2024

I was a full invested svelte-spa-router user until 5 dropped and didn't have a choice but to do my part and throw up https://github.com/mateothegreat/svelte5-router for the community. Hope it unblocks somebody.

Thank you for all your hard work in keeping this lib alive -- it definitley inspired me <3

@brandonkal
Copy link

@mateothegreat that is not appear to be a hash-based router so it is not comparable

@dvcol
Copy link

dvcol commented Nov 22, 2024

@brandonkal If you really need a svelte 5 native hash router, I wrote something a few month back.

It's jsut a side project however, so I would be wary of using it in prod.
For serious projects, I'd wait for @doregex's PR.

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

No branches or pull requests