Skip to content

fix: ensure proper HMR updates for dynamic components#18079

Open
dummdidumm wants to merge 2 commits intomainfrom
fix-hmr-dynamic-component
Open

fix: ensure proper HMR updates for dynamic components#18079
dummdidumm wants to merge 2 commits intomainfrom
fix-hmr-dynamic-component

Conversation

@dummdidumm
Copy link
Copy Markdown
Member

The BranchManager in branches.js does create a temporary anchor when creating a new branch offscreen, and deletes it once the branch is committed. Normally this is fine, but the combination of HMR and dynamic components leads to a bug: Since svelte-component.js passes the temporary anchor along to the component it generates, which is the HMR wrapper, this wrapper will have an obsolete, disconnected anchor on updates, leading to the content disappearing.

The fix is to add a dev-only symbol which we set on the original (then obsolete) anchor to tell about the updated anchor that should be used for HMR updates.

Fixes sveltejs/kit#14699 Fixes #17211

The BranchManager in `branches.js` does create a temporary anchor when creating a new branch offscreen, and deletes it once the branch is committed. Normally this is fine, but the combination of HMR and dynamic components leads to a bug: Since `svelte-component.js` passes the temporary anchor along to the component it generates, which is the HMR wrapper, this wrapper will have an obsolete, disconnected anchor on updates, leading to the content disappearing.

The fix is to add a dev-only symbol which we set on the original (then obsolete) anchor to tell about the updated anchor that should be used for HMR updates.

Fixes sveltejs/kit#14699
Fixes #17211
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 7, 2026

🦋 Changeset detected

Latest commit: eea35e6

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

@svelte-docs-bot
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Playground

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

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.

Async: HMR Broken after navigate HMR breaks after client-side navigation when compilerOptions.experimental.async is enabled

1 participant