-
Notifications
You must be signed in to change notification settings - Fork 32
Feat/svelte Add support for svelte and sveltekit #209
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
base: main
Are you sure you want to change the base?
Conversation
…ponent-based approach
Merge main to feat/svelte
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@thomasballinger, could you please review and share your feedback? 🙂 |
Whoa, great work here! This will take a bit to review, but it's a good direction. I'll get back to you by tomorrow night with direction here. Have you tried this in one of your own projects yet? |
Yes, I've embedded it in my SvelteKit app, and it works well so far. I also have a Figma plugin that runs as a plain Svelte app, and I plan to integrate it there soon. |
Packaging and installing seem to be a bigger problem. Current Error:Sveltekit specific imports in the sveltekit package
throwing errors after being packaged into a tarball and installed. But if I install the library via a Symlink, it works fine. As far as I have researched, the problem appears to be that if we bundle our .svelte.ts files into .js, then importing '$app/' and '$env/' will break, because these modules only exist within the SvelteKit build pipeline. |
Yes I can manage this bit! This matches my understanding, that .svelte code can't be bundled. That's fine, it's alright that the packaging process will look different for the svelte-specific bits here. We'll want this to be a separate entry point anyway. It may be easiest to create a new package for the Svelte auth stuff (which we can package more traditionally for a Svelte library, more similar to https://github.com/get-convex/convex-svelte with lib etc.) and we expose the parts of convex-auth that are necessary in that code. I haven't had a change to look into this yet, hoping to by tomorrow morning. But without looking at the bundling issues specifically that's my bet for the smoothest path forward: using Convex Auth with Svelte would require installing two packages, @convex-dev/auth and @convex-dev/svelte-auth. |
Add support for svelte and sveltekit
createRouteMatcher(["/product(.*)"])
becomescreateRouteMatcher(["/product{*rest}"])
I have tested the SvelteKit version as part of the test-sveltekit project, and it's working there. I also want to test it as part of my real project to find more edge cases and test the Svelte version more thoroughly. But I want to create the pull request now because I think it's in a good state for a discussion, and you can share your thoughts.
I especially think it makes sense to discuss the API as it's not a 100% match, and it is also influenced by the fact that convex-svelte already diverges from the React client API.
Also, I noticed that it could make sense to invest some time in deduplicating code for shared code used by React and Svelte (Mutex, routeMatcher, Playwright, etc.).
And one small question: During debugging, I recognized that I must create the client with
verbose: true
to activate verbose logging. Did you intend to do it via a prop rather than an env variable? I experience the env variable as quite useful for activating and deactivating verbose logging quite easily, especially if I want to activate it for a short period on deployed instances.Happy to hear your thoughts and feedback!
Solves convex-auth for svelte/sveltekit #89
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.