ciscoheat / sveltekit-superforms

Making SvelteKit forms a pleasure to use!
https://superforms.rocks
MIT License
2.13k stars 62 forks source link

SvelteDebug props Svelete5 #306

Closed GimpMaster closed 7 months ago

GimpMaster commented 8 months ago

Description I just tried this great project out in my Svelte5 sample app. I realize Svelte5 isn't out yet but I'm getting this error

SuperDebug.svelte:18:2 Cannot use export let in runes mode — use $props instead

I looked and noticed you have a Svelte5-Comp branch but I didn't see any changes to address this. Is there a work around for this?

Thanks

ciscoheat commented 8 months ago

Hello, there's another issue #300 about svelte 5, that I don't know when it's going to be fixed, so I cannot say anything about svelte 5 compatibility yet.

GimpMaster commented 8 months ago

Interesting. I was able to get working what I needed. Just that SuperDebug doesn’t work. Perhaps I’m not using Proxy or something.

Either way I’m excited to use superforms going forward. I can tell you put a lot of thought into it. I built something very similar for react and was glad to see I could just use this instead of porting my form manager over.

ciscoheat commented 8 months ago

Glad to hear you like it. :) I haven't dived deep into Svelte 5 yet, but maybe setting runes mode to false for SuperDebug will help: https://svelte-5-preview.vercel.app/docs/runes#how-to-opt-in

GimpMaster commented 8 months ago

I could be wrong but it seems like you would have to place this inside SvelteDebug

or I make a wrapper component. Still very new to svelte

ciscoheat commented 8 months ago

Will add this to the v2 release, since it is quite close.

GimpMaster commented 8 months ago

I will so I found a work around. The issues comes because I have the force runes mode in my svelte.config.ts.

Unfortunately this forces all node_modules to also be in runes mode. However you can pass a function to the config and exclude certain files or folders.

When I get to my computer I’ll post the code

GimpMaster commented 8 months ago

For those reading this here is where the issue comes from in svelte.config.js

    // Force to use runes for entire project INCLUDING node_modules unfortunately
    compilerOptions: {
        runes: true
    },

    vitePlugin: {
        dynamicCompileOptions({ filename }) {
            if (filename.includes('node_modules')) {
                return { runes: undefined }; // or false, check what works
            }
        }
    },

the dynamicCompileOptions is a work around where you can have it set runes mode back to undefined for those files.

ciscoheat commented 7 months ago

Great, will add this as a note in a future Svelte 5 upgrade page. Thanks for trying it out!

ciscoheat commented 7 months ago

Will leave it here, as it probably will be fixed soon (if not already).