-
Notifications
You must be signed in to change notification settings - Fork 53
feat: add Svelte support #91
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
Conversation
a32fc79
to
558af77
Compare
🦋 Changeset detectedLatest commit: 1700b2d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
FYI — we've removed the tanstack/store to do a direct integration w/ the frameworks (more control means more speed). The vue code is a good example of how to directly integrate with framework reactive primitives. Would love to get a Svelte package out! https://github.com/TanStack/db/blob/main/packages/vue-db/src/useLiveQuery.ts |
Awesome. Ill take a look 👀 |
Needs some refactoring |
@teleskop150750 jump in! |
@KyleAMathews good to review! |
type MaybeGetter<T> = T | (() => T) | ||
|
||
function toValue<T>(value: MaybeGetter<T>): T { | ||
if (typeof value === `function`) { | ||
return (value as () => T)() | ||
} | ||
return value | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Svelte 5 with runes, the standard is to use getters when passing reactive state
65f7207
to
352ff73
Compare
"description": "Svelte integration for @tanstack/db", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"build": "svelte-package --input ./src --output ./dist --tsconfig ./tsconfig.build.json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not using the shared tanstackViteConfig
here as we want to use svelte-package
to correctly process .svelte.ts
and .svelte
files.
This is also what the TanStack Svelte 5 adapter does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prevents svelte-package
from generating declarations for @tanstack/db
while still allowing proper type resolution during dev and testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff! I'm no Svelte expert but Claude & Gemini gave their 👍 😆 & it looks good to me.
Adds Svelte support!