WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@Rich-Harris
Copy link
Member

Alternative to #17374. I think this is a more correct fix — it makes the $.hmr block effect a no-op when it isn't running as a result of a hot.accept callback, rather than excluding all block effects from re-running after the first await is encountered during traversal.

It also makes the HMR implementation simpler, both in terms of the generated code...

if (import.meta.hot) {
	A = $.hmr(A, () => A[$.HMR].source);

	import.meta.hot.accept((module) => {
		module.default[$.HMR].source = A[$.HMR].source;
		$.set(A[$.HMR].source, module.default[$.HMR].original);
	});
}
if (import.meta.hot) {
	A = $.hmr(A);

	import.meta.hot.accept((module) => {
		A[$.HMR](module.default);
	});
}

...and the dance that needs to happen inside $.hmr.

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
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

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

@changeset-bot
Copy link

changeset-bot bot commented Dec 20, 2025

🦋 Changeset detected

Latest commit: 0625ec8

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

This PR includes changesets to release 1 package
Name Type
svelte 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

@github-actions
Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@17380

@dominikg
Copy link
Member

/ecosystem-ci run vite-plugin-svelte

@svelte-ecoystem-ci
Copy link

📝 Ran ecosystem CI on 92fcc14: Open

vite-plugin-svelte

@dominikg
Copy link
Member

vite-plugin-svelte contains an e2e test for hmr modificactions but the components in there are not using await so this bug wasn't caught there.

Updating the test components there would help if ecosystem-ci was triggered in PRs, otherwise the svelte repo would need hmr tests itself where a devserver is started, files edited and result of hmr is asserted.

v-p-s tests can only be updated after a svelte release so its not ideal for testing changes to the generated hmr code. For this case i think it would be best if the svelte repo itself had an e2e test that edits files in a "kitchensink" app and tests all behaviors for hmr.

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.

4 participants