Skip to content

Bring the Svelte bindings, template and docs up to par - #6712

Open
krisajenkins wants to merge 15 commits into
kris/template-client-buildsfrom
kris/svelte-template-updates
Open

krisajenkins wants to merge 15 commits into
kris/template-client-buildsfrom
kris/svelte-template-updates

Conversation

@krisajenkins

Copy link
Copy Markdown
Contributor

Stacked on #6711, which is stacked on #6709. Review only the last eleven commits, which touch the Svelte bindings and their tests, templates/svelte-ts and the Svelte docs.

Description of Changes

This brings the Svelte bindings up to the same level as the React bindings they were ported from. It also fixes problems in the svelte-ts template and the Svelte docs that a new user would run into early on. Each commit stands on its own, and its message gives the full reasoning.

Bindings (spacetimedb/svelte)

  • Adds useProcedure. React, Vue and Solid already have it, and the reference claims Svelte "provides the same hooks as React". It queues calls made before the connection exists, the same way useReducer does.
  • createSpacetimeDBProvider and useSpacetimeDB now return a Readable<ConnectionState>, not a Writable. Before, a component could write to $conn, and every hook under that provider would believe it until the ConnectionManager overwrote the value.
  • useTable reads the latest connection state from the subscription it already holds, instead of calling get() on every transaction. It also matches events by event.id, as React does.
  • Adds tests/svelte_bindings.test.ts. Before this, only useTable's reconnect behaviour was tested.

Template (templates/svelte-ts)

  • build now runs svelte-check before vite build. Until now, type errors in the template never failed a build, and with the smoketest PR they now fail CI as well. The tooling is also updated: Vite 7, vite-plugin-svelte 6, verbatimModuleSyntax, and no vitePreprocess.
  • The template's own components are compiled in runes mode, so a legacy-syntax component fails the build instead of silently falling back to Svelte 4 semantics. Components under node_modules are left alone.
  • The page shows a loading state until the first subscription results arrive, instead of saying "No people yet".
  • Reducer failures are shown on the page instead of being dropped as an unhandled rejection.
  • The people list is keyed, by row object, because person has no primary key.
  • Root.svelte has a comment saying why the provider has to live in a component.

Docs

  • The Svelte section of the TypeScript reference imported a SpacetimeDBProvider that doesn't exist. It now documents createSpacetimeDBProvider, useSpacetimeDB, useTable, useReducer and useProcedure.
  • The Svelte quickstart, and the template README generated from it, now explain Root.svelte and that the hooks return stores.

API and ABI breaking changes

createSpacetimeDBProvider and useSpacetimeDB in spacetimedb/svelte now return Readable<ConnectionState> instead of Writable<ConnectionState>. Code that only reads the store, as the template and docs do, is unaffected. Code that calls set or update on it, or assigns to $conn, no longer compiles. Those writes were never honoured, because the ConnectionManager overwrites the value on its next update.

Rollback safety impact

n/a

Expected complexity level and risk

  1. The changes are small and limited to the Svelte bindings, the svelte-ts template and the docs. The template's stricter build script means the template smoketest will now fail on Svelte type errors, which is the intent.

Testing

Added 19 Svelte binding tests covering the following behaviors:

  • useSpacetimeDB and useTable throw a helpful error outside a provider (2 tests).
  • The provider shares one read-only store with its children. Making the store writable made the test fail.
  • The provider reports the identity and token once connected.
  • reconnect(builder) replaces the connection.
  • The provider releases the connection, deferred, when destroyed. Never releasing it made the test fail.
  • useReducer and useProcedure (4 tests each):
    • Queue calls made before connecting, and send them once connected.
    • Call straight through when connected.
    • Reject a queued call when the server call fails.
    • Stop sending queued calls once destroyed. Dropping the onDestroy unsubscribe made the test fail.
  • useTable becomes ready with the subscribed rows.
  • useTable updates its rows once per transaction while firing callbacks per row. Recomputing rows for every row made the test fail.
  • useTable filters rows and callbacks by the where clause. Skipping the membership check made the test fail.
  • useTable reports an in-filter change as an update.
  • useTable unsubscribes and stops listening when destroyed. Keeping the table listeners made the test fail.

The full bindings-typescript unit suite (538 tests), the type-check run, lint and the build all pass. In the template, svelte-check reports 0 errors and vite build succeeds. A planted type error and a planted export let component each fail the build.

The template was run in headless Chrome against a local server:

  • An empty table shows "Loading…" and then "No people yet".
  • A table with two rows shows "Loading…" and then both names, never "No people yet".
  • A module whose add reducer rejects one name shows "Couldn't add boom: names cannot be boom".

Every docs snippet was type-checked with svelte-check against the built package.

…t projects.

Say you scaffold a project with 'spacetime init --template react-ts' (or
any of the twelve TypeScript client templates), change your module, and
want fresh bindings. package.json has an obvious-looking 'generate'
script, so you run 'npm run generate'. It fails:

    "generate": "pnpm --dir spacetimedb install && cargo run -p gen-bindings -- --out-dir src/module_bindings --module-path spacetimedb && prettier --write src/module_bindings"

gen-bindings is a tool in the SpacetimeDB repository's Cargo workspace.
The templates use it to regenerate their checked-in bindings, and the
repo's own CI calls it through this script ('pnpm generate' in
chat-react-ts, and in react-ts via bindings-typescript). Outside the repo
there is no such crate, and usually no Cargo at all. The script that
actually works for users, 'spacetime:generate', sits a line below it, but
the broken one has the name people reach for.

Nobody caught it because it works for everyone who maintains the
templates: inside the monorepo the script runs fine. 'spacetime init'
copies each template's package.json unchanged apart from the name and the
spacetimedb version, and the template smoketests only install and publish.

Renaming the script in every template would mean changing the repo's CI
and SDK scripts that call it. Instead, update_package_json, which already
rewrites each template's package.json during init, now drops any script
that invokes gen-bindings. The monorepo keeps its workflow, and scaffolded
projects get only scripts that can run.

A new test runs update_package_json over every embedded template's
package.json. It checks that each gen-bindings script is removed and
every other script is kept unchanged. It also fails if no template uses
gen-bindings any more, so the marker can't go stale silently. Removing the
call makes it fail, naming money-exchange-react-ts. Scaffolding svelte-ts
with the rebuilt CLI produces a package.json without 'generate' and with
its other scripts intact.
Suppose someone changes the TypeScript SDK in a way that breaks a client
template: a hook's return type changes, say, so the Vue template's App.vue
no longer type-checks. CI runs a smoketest for every template, so surely
that template's test fails? It doesn't. For TypeScript templates the test
publishes the server module, runs 'pnpm install' for the client, and
stops:

    // TODO: some templates don't pass tsc yet, re-enable once they're fixed.
    // run_pnpm(&["exec", "tsc", "--noEmit"], project_path)?;

So no client code is ever compiled. That isn't hypothetical: building
every TypeScript template the way the smoketest scaffolds it shows that
vue-ts already doesn't type-check (vue-tsc rejects three expressions in
App.vue), tanstack-ts's build can't find an entry module, and bun-ts's
build can't start. All three are green in CI today. Users meet these on
their first 'npm run build'.

The commented-out tsc call wouldn't have caught all of them anyway. Plain
tsc doesn't understand .vue or .svelte files, so it can't check the
frameworks where type errors hide in templates.

The test now runs each template's own build script ('pnpm run
--if-present build'). That uses whatever checker the template's
framework uses (tsc -b, vue-tsc, svelte-check, ng build, next build), and
--if-present covers deno-ts, which has no build script. The three
templates that fail today are listed in TYPESCRIPT_CLIENT_BUILD_KNOWN_FAILURES
with the reason for each. Their builds are skipped, with a log line, until
someone fixes them and deletes the entry. A new unit test fails if an
entry no longer names a TypeScript template, so the list can't quietly
outlive a rename.

Checked by scaffolding all 19 TypeScript templates with the CLI, pointing
them at the local SDK and running their builds: 15 build, deno-ts has no
build script, and the three listed fail. Then, with the real smoketests:
svelte-ts passes with its build running; vue-ts passes with its build
skipped; deno-ts passes via --if-present; and with vue-ts removed from the
list its smoketest fails, quoting vue-tsc's errors.
…ncy.

The template smoketest now builds each TypeScript template's client, and
vue-ts was on its known-failures list because vue-tsc rejected App.vue:

    src/App.vue(52,29): error TS2339: Property 'length' does not exist on type 'Readonly<Ref<readonly { readonly name: string; }[], ...>>'.

That reads like a bug in the template, or in the Vue bindings' useTable
types. If so, every Vue user would hit it on their first build. They
don't: the same template type-checks cleanly inside the repo, and the
error only appears in the project the smoketest scaffolds.

The difference is how that project gets the SDK. The smoketest points
'spacetimedb' at crates/bindings-typescript, and pnpm symlinks a local
directory dependency. The SDK's type declarations then resolve their
optional framework peers from the monorepo's node_modules, so in the
scaffolded vue-ts project the SDK sees vue 3.5.26 while the app has its
own fresh vue 3.5.45. Vue brands Ref with a unique symbol, so a Ref
declared against one copy isn't recognised as a Ref by the other, and
vue-tsc can't unwrap 'people' in the template. A user installing the
published package gets one copy of vue, resolved from their project.

So the smoketest wasn't testing what users get. It now also sets
dependenciesMeta.spacetimedb.injected, which makes pnpm copy the SDK into
the project and resolve its peers there, as a registry install would. The
helper comment explains why. vue-ts comes off the known-failures list.

Injecting the SDK also turns an old race into a reliable failure. Every
TypeScript test called build_typescript_sdk(), which runs pnpm install
and pnpm build in crates/bindings-typescript, and the local runner runs
16 tests at once. One test's build clears dist while another test's
pnpm install is copying it, so a parallel run fails at random: pnpm
reports missing files under dist, or a template can't import
spacetimedb/server. With a symlink the race was easy to miss, because a
project only read dist once the build had finished. CI's partitions run
with -j 1, so CI never saw it.

So the runner now builds the SDK once, before any test starts, both for
a local run and for CI's run-archive, and sets
SPACETIME_SMOKETEST_TS_SDK_PREBUILT for the tests, which makes
build_typescript_sdk() return early. templates.rs drops its own copy of
that build and uses the library's. A test run directly with cargo test
still builds the SDK itself, as before.

- The runner finds pnpm with which, so Windows resolves pnpm.cmd.
- It builds relative to the current directory rather than the library's
  workspace_root(), which is fixed at compile time, because CI runs the
  runner in a different job from the one that built it.

Checked with the template smoketests for all 19 TypeScript templates, one
at a time as CI runs them (-j 1): all pass, vue-ts now builds its client,
and only bun-ts and tanstack-ts are still skipped. With the runner's
default of -j 16, the whole templates:: suite (less the C++ and C#
templates, which can't run on this machine) also passes: 23 tests in
69s, where before the fix six TypeScript templates failed.
…st again.

The template smoketest builds each TypeScript template's client, but it has
been skipping tanstack-ts as a known failure:

    ("tanstack-ts", "`vite build` can't resolve an entry module (index.html)"),

That failure came from the template asking for Vite 7 while
@tanstack/react-start 1.169.0 and later need Vite 8. On Vite 7, TanStack
Start's plugin doesn't register its build environments, so Vite falls back
to looking for an index.html the template was never meant to have. Master's
dependency update (25567d1) has since moved the template to vite ^8.3.8,
@vitejs/plugin-react ^6.3.0 and react-start ^1.169.7, which fixes the build.
But nothing told the smoketest, so it would go on skipping a build that now
works, and a future regression would go unnoticed.

This removes tanstack-ts from TYPESCRIPT_CLIENT_BUILD_KNOWN_FAILURES, leaving
only bun-ts.

Verified: in-repo, `pnpm run build` in templates/tanstack-ts succeeds on
Vite 8.
The React, Vue and Solid bindings all export a useProcedure hook, and the
TypeScript client reference says the Svelte integration 'provides the same
hooks as React'. It didn't: spacetimedb/svelte exported useTable and
useReducer but nothing for procedures. A Svelte app that wanted to call a
procedure had to reach into useSpacetimeDB(), call getConnection(), handle
the null case itself before the socket was up, and look the procedure up by
accessor name by hand. That is exactly the boilerplate the hooks exist to
remove, and nothing pointed Svelte users at the gap.

The new hook mirrors useReducer in the same package: calls made before a
connection exists are queued and flushed (resolving with the procedure's
return value) as soon as the connection store reports one, and the store
subscription is dropped in onDestroy so an unmounted component stops
flushing.
Three small problems in spacetimedb/svelte, each found by putting it next to
the React bindings it was ported from.

First, createSpacetimeDBProvider() and useSpacetimeDB() returned a Writable
store. Nothing in the bindings ever expected anyone but the ConnectionManager
to write it, but the type invited it: a component could write

    const conn = useSpacetimeDB();
    $conn = { ...$conn, isActive: true };

and every useTable/useReducer under that provider would believe the
connection was live until the manager's next update overwrote the lie. The
store is now exposed through svelte/store's readonly(), so the type is
Readable<ConnectionState> and that assignment no longer compiles. readonly()
has been in svelte/store since 3.56, so the declared ^4 || ^5 peer range
still holds. Code that only reads $conn, which is all the template and docs
do, is unaffected.

Second, useTable called get(connectionStore) every time it recomputed rows,
which happens once per transaction touching the table. The Svelte docs warn
against get() on hot paths because each call subscribes and immediately
unsubscribes. useTable already holds a live subscription to that store, so
it now keeps the latest state from that subscription and reads it directly.

Third, useTable decided whether a row callback belonged to a transaction it
had already re-rendered for by comparing event objects by identity, while
React compares event.id. The SDK creates one event object per transaction,
so the two are equivalent today; the Svelte code now uses the id, like
React, so it doesn't silently depend on that.

Also, useReducer carried a private copy of the ParamsType helper; it now
imports the one in sdk/type_utils.ts, like React's useReducer and the new
Svelte useProcedure.

The cross-framework reconnect tests in
tests/framework_table_reconnect.test.ts still pass against useTable. The
changes were also checked with a scratch harness that mounts real Svelte 5
components under jsdom against a fake connection: rows recompute once per
transaction id, onInsert fires per row, swapping the connection drops the
old listeners and subscription and rebinds to the new one, and unmounting
removes all listeners. svelte-check and vite build of templates/svelte-ts
pass against the rebuilt package.
Someone setting up a Svelte client from the reference would copy its first
line:

    import { SpacetimeDBProvider, useSpacetimeDB, useTable, useReducer } from 'spacetimedb/svelte';

and get a compile error, because spacetimedb/svelte has no
SpacetimeDBProvider. Svelte has no component-wrapping provider like React's;
the export is createSpacetimeDBProvider(), a function you call in a root
component's <script> so it can use Svelte context. The section never showed
it, so the reader was left with a broken import and no example of the one
piece of setup that differs from every other framework. The svelte-ts
template does it right, which is presumably why nobody noticed: people
starting from the template never read this.

The section also said Svelte 'provides the same hooks as React' while
showing only useTable, and its {#each} block was unkeyed, which the Svelte
docs advise against for lists that change.

The section now mirrors the React one: the real import line,
createSpacetimeDBProvider with a Root.svelte example and a note on why it
can't live in main.ts, useSpacetimeDB as a readable store including
reconnect(builder), useTable with a keyed {#each} and a note that its query
is fixed when the component is created, and useReducer/useProcedure with
their pre-connection queueing.

Every snippet was type-checked with svelte-check against the built package,
adapted to the template's person table.
…ing.

Picture someone who has just run 'spacetime dev --template svelte-ts'. They
rename a column in their module, regenerate bindings, and run the build to
see what broke. With the React template, 'tsc -b && vite build' would list
every stale reference. With the Svelte template the build passes: its build
script was plain 'vite build', which strips TypeScript without checking it.
svelte-check was in devDependencies, but no script ever ran it. The errors
only surface at runtime, in the browser, as undefined fields. Nothing failed
in CI either, because the template smoketest installs and publishes but
doesn't type-check client code. So the template had a type checker and
never used it.

The rest of the tooling had drifted from current Svelte practice too:

- vite was on ^6.4.1 while React and most other templates are on ^7.1.5,
  with @sveltejs/vite-plugin-svelte ^5 to match.
- svelte.config.js ran vitePreprocess(). Since Svelte 5, type-only
  TypeScript compiles without a preprocessor, and Vite's own svelte-ts
  scaffold ships an empty config.
- tsconfig.json lacked verbatimModuleSyntax, which the Svelte TypeScript
  docs recommend, and didn't load Svelte's ambient types.
- .gitignore listed .svelte-kit, though this isn't a SvelteKit project.

This adds a 'check' script and makes 'build' run svelte-check first. It
calls svelte-check directly rather than via 'pnpm run' so the script still
works for anyone who scaffolds the template with npm. It also:

- bumps vite to ^7.1.5, @sveltejs/vite-plugin-svelte to ^6.2.4 (the newest
  line that supports vite 7) and svelte-check to ^4.7.8. svelte's floor
  moves to ^5.46.4, the version already locked; 5.58.0 is inside the repo's
  minimum release age.
- empties svelte.config.js.
- turns on verbatimModuleSyntax and adds 'svelte' to types. The generated
  module_bindings already comply.
- drops .svelte-kit from .gitignore.

The lockfile was updated with an install filtered to this template. Besides
the template's own upgrades, pnpm deduplicated vitest's vite peer onto the
7.3.2 already in the lockfile and bumped magic-string a patch.

Verified with svelte-check (0 errors), vite build, the vite dev server, and
by planting errors: a type error now fails the build, and a non-type import
of a type-only export is now rejected. The bindings-typescript unit tests
pass apart from the two wasm test files, which need a wasm artefact that
isn't built locally.
Someone who has just scaffolded the Svelte template opens the README to find
their way around. The project tree shows src/App.svelte and module_bindings,
and nothing else. But the first thing they'll want to change is which
database they connect to, and that lives in src/Root.svelte, a file the
README never mentions. They'll find it eventually. They'll then wonder why
it exists at all, since every other framework template sets up its
connection in main.ts, and may try to move it there. That fails at runtime,
because createSpacetimeDBProvider uses Svelte context and only works while
a component is being created.

The README also never says that the hooks return Svelte stores. A Svelte 5
developer expects runes, so seeing $people and $conn in App.svelte looks
like legacy syntax rather than the intended API. And 'Next steps' pointed at
the top of a long TypeScript reference rather than its Svelte section, and
left out the chat tutorial that the React README links to.

The README is generated from the Svelte quickstart page by
tools/templates/generate-template-readmes.ts, so the changes are made in
docs/docs/00100-intro/00200-quickstarts/00160-svelte.md and the README is
regenerated from it:

- The project tree lists main.ts, Root.svelte and App.svelte, each with
  its role, and the text says where the connection is configured.
- A new 'Use your data in Svelte' step explains why Root.svelte exists,
  says the hooks return stores read with $, and shows a short type-checked
  example using the template's own person table and add reducer.
- 'Next steps' links to the Svelte section of the TypeScript reference, and
  to the chat tutorial, noting that its client is React but its module and
  SDK calls carry over.

The example was checked with svelte-check inside the template. Running the
generator also rewrites nine other templates' READMEs that have drifted from
their quickstarts; those changes are not part of this commit.
The Svelte bindings have one test file, framework_table_reconnect.test.ts,
and it only asks one question of every framework: does useTable keep its
subscription and rows across a reconnect? Everything else in
spacetimedb/svelte had no tests: createSpacetimeDBProvider, useSpacetimeDB,
useReducer, the new useProcedure, and the parts of useTable that aren't
about reconnecting (where-clause filtering, the insert/delete/update
callbacks, and updating the rows store once per transaction rather than
once per row). The last few commits changed several of those, and they
could only be checked with a throwaway harness outside the repo. The next
person to touch them won't have that harness.

The new tests/svelte_bindings.test.ts follows the existing file's approach:
svelte is mocked with a minimal component lifecycle (one shared context map
per test, and onDestroy callbacks collected per component), and the
provider and useTable run against a real DbConnection over the websocket
test adapter. The test app has no procedures, and useReducer and
useProcedure only depend on getConnection() and the accessor map, so those
two run against a hand-driven connection store. The tests cover:

- useSpacetimeDB and useTable throwing helpful errors outside a provider.
- The provider sharing one read-only store with its children, reporting
  the identity and token once connected, replacing the connection on
  reconnect(builder), and releasing it, deferred, when destroyed.
- useReducer and useProcedure queueing calls made before connecting,
  passing return values and errors through, calling straight through when
  connected, and dropping the queue once destroyed.
- useTable becoming ready with the subscribed rows, emitting once per
  transaction while firing callbacks per row, mapping updates across the
  where clause to onInsert/onDelete/onUpdate, and unsubscribing and going
  quiet when destroyed.

Each test was checked by breaking the behaviour it covers: making the
store writable, dropping the onDestroy unsubscribe in useReducer or
useProcedure, recomputing rows per row, skipping membership
classification, keeping table listeners after destroy, and never releasing
the connection. Each break fails exactly the test aimed at it. The full
unit suite passes (502 tests) apart from the two wasm test files, which
need a locally built artefact.
The template's list of people is an unkeyed {#each}:

    {#each $people as person}
      <li>{person.name}</li>
    {/each}

Without a key, Svelte matches list items to rows by position. When someone
is inserted or deleted anywhere but the end, every item after that point is
handed a different person and patched to match, instead of one item being
added or removed. On this two-field list that's invisible, but the template
is what people copy, and as soon as an item holds state of its own (an
input, a transition, a focused button) it ends up attached to the wrong
person. The Svelte docs recommend keying lists for exactly this reason.

The reason it wasn't keyed is that the person table has no primary key, and
adding one would change the module shared by every TypeScript template and
the quickstart docs. That turns out not to be necessary. The SDK's client
cache keeps one object per row until the row changes: rows without a
primary key are stored under their encoded bytes, and a repeated insert from
an overlapping subscription bumps a refcount and keeps the existing object.
So the row object itself is a stable, unique key, and for a table with no
primary key it is exactly the right identity: such a row is never updated,
only deleted and re-inserted.

The list is now keyed by the row object, with a comment saying why that
works.
Suppose you start from this template and give the add reducer some
validation, which is the first thing most people do:

    if (name === '') throw new SenderError('name is required');

Then you submit a name the reducer rejects. The input clears as if it
worked, no one is added to the list, and nothing on the page says why.
The template called the reducer like this:

    addReducer({ name: name });
    name = '';

addReducer returns a promise, which rejects with the server's error (or
with a DisconnectedError if the connection drops), and the template threw
it away. The only trace is an unhandled-rejection line in the browser
console. It wasn't noticed because the template's own reducer can't fail,
so the path was never exercised.

addPerson now awaits the call and shows the error under the form, naming
the person it couldn't add, since the input has already been cleared for
the next entry. The next submit clears the message.

Checked against a local server with a copy of the module whose add reducer
throws SenderError for one name: the page shows "Couldn't add boom: names
cannot be boom", the list is unchanged, and the next successful add clears
the message.
Open the template app against a database that already has people in it.
Before the list appears, the page says "People (0)" and "No people yet.
Add someone above!", and then a moment later the people pop in. Recording
the page text on a reload with two rows in the table shows it:

    Status: Disconnected  People (0)  No people yet. Add someone above!
    Status: Connected     People (0)  No people yet. Add someone above!
    Status: Connected     People (2)  Alice, Bob

The app tells the user, wrongly, that the table is empty, for as long as
connecting and subscribing take. On localhost that's a flicker; over a real
network it's long enough to read. The template only looked at the rows,
and an empty array means both "nothing loaded yet" and "loaded, and
empty".

useTable already returns a second store, isReady, which is true once the
subscription's first results have been applied. The template now uses it:
while the list is empty and not ready, it shows "Loading…" and leaves the
count off the heading. Rows that are already loaded stay on screen if
isReady drops, for example during a reconnect, because the check only
applies to an empty list.

Checked in headless Chrome against a local server, recording every state of
the page: an empty table goes Loading… to "No people yet", a table with
two rows goes Loading… to the two names, and "No people yet" never shows
in between.
Svelte 5 decides per component whether to use runes. A component that
uses no runes is compiled in legacy (Svelte 4) mode, where `export let`
declares props and every top-level `let` is reactive. So someone who
starts from this template and adds a component written from an older
tutorial or an AI suggestion, say:

    <script lang="ts">
    export let label = 'legacy';
    </script>

gets no error and no warning: it builds and runs. The app now mixes two
reactivity models, and that component quietly loses runes-only features
such as $props, snippets and $derived. Nothing tells you which mode a file
is in, so this is easy to miss. The template's own components all use
runes, so it never came up.

svelte.config.js now forces runes mode for the app's own components. The
Svelte docs warn against setting compilerOptions.runes to true, because it
also applies to components inside node_modules, which may have been
written for legacy mode. So this uses vite-plugin-svelte's
dynamicCompileOptions instead, and leaves files under node_modules alone.
Svelte's docs say runes will be the default in Svelte 6.

The check happens in vite build, not svelte-check, which doesn't read the
vitePlugin options. The template's build script runs both, so it still
fails. Checked with a scratch component like the one above: before this
change the build succeeds; after it, the build fails with "Cannot use
`export let` in runes mode — use `$props()` instead".
A new user's first instinct is often to move the connection setup out of
Root.svelte and into main.ts, next to mount(), where setup code usually
goes. That breaks: createSpacetimeDBProvider stores the connection in
Svelte context, and setContext can only be called while a component is
being initialised, so outside a component it throws. The template's README
explains this, but people reading the code directly don't see that.

Root.svelte now has a two-line comment at the call, saying what the
provider does and why it has to be in a component.

This branch has not been deployed

No deployments
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.

1 participant