Skip to content

fix: HMR for query - #14587

Merged
Rich-Harris merged 4 commits into
mainfrom
remote-hmr
Oct 2, 2025
Merged

fix: HMR for query#14587
Rich-Harris merged 4 commits into
mainfrom
remote-hmr

Conversation

@Rich-Harris

Copy link
Copy Markdown
Member

At present, if you have something like this...

<script>
  import { foo } from './data.remote';
</script>

<p>{await foo()}</p>

...nothing immediately changes if you change the return value of foo — you have to reload the page to see the new data. This is unsatisfying.

With this PR, hot updates are accepted by the transformed remote module, and upon creating the replacement query we refresh anything that's currently referenced in an effect. The end result is HMR for queries.

Unfortunately this approach doesn't extend to prerender, because prerender functions don't use state and thus cannot be reactively updated. We could change that, but we would only want to change it in dev, and it would be a whole thing. Maybe we'll want to do that at some point anyway though.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot

changeset-bot Bot commented Oct 2, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0f07994

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

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

@svelte-docs-bot

Copy link
Copy Markdown

Comment thread packages/kit/src/runtime/client/remote-functions/query.svelte.js
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
@Rich-Harris
Rich-Harris merged commit 04ba87e into main Oct 2, 2025
20 of 21 checks passed
@Rich-Harris
Rich-Harris deleted the remote-hmr branch October 2, 2025 21:12
This was referenced Oct 2, 2025
Copilot AI pushed a commit to Stadly/kit that referenced this pull request Mar 6, 2026
* accept hot updates

* update cached entries

* changeset

* Update packages/kit/src/runtime/client/remote-functions/query.svelte.js

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
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.

2 participants