Conversation
Member
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 974d369c42
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
9aoy
commented
Jan 9, 2026
check hot
fi3ework
approved these changes
Jan 9, 2026
This was referenced Jan 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
In Rsbuild / Rspack / Webpack, updating a Vue SFC may trigger a JavaScript module hot update even when only non-JS parts (such as
<template>or<style>) have changed. This behavior causes component state to be reset and deviates from the expected Vue HMR semantics.Related issue: web-infra-dev/rsbuild#3217 (comment)
Root Cause
The issue is caused by changes in the generated sourcemap rather than changes in the emitted JavaScript code.
During rebuilds, a new sourcemap is generated on every update, even when the JavaScript output remains identical. Since the HMR mechanism determines module updates based on emitted assets (including sourcemaps), any change in the sourcemap is sufficient to mark the JS module as updated, resulting in an unnecessary hot update.
Current Approach
keeping the sourcemap stable when the JS output is unchanged.
When the loader detects that the generated JavaScript code has not changed, it reuses the previously generated sourcemap instead of producing a new one. By keeping the sourcemap unchanged, the JS module is no longer considered updated, preventing unnecessary JS HMR and preserving component state.
As a result, component state can be preserved during template or style-only updates.
This approach is similar to how unplugin-vue handles updates via the Vite's handleHotUpdate hook. Since the need to adjust hot update behavior mainly comes from Vue HMR scenarios, we believe it is more appropriate to handle this logic internally within vue-loader or unplugin-vue, rather than at a higher level.
Known Limitations
Reusing the previous sourcemap may lead to slightly inaccurate source mappings for
<template>and<style>sections. However, in practice, this has minimal impact on debugging and is considered an acceptable trade-off compared to the benefit of avoiding unnecessary JavaScript hot updates.