fix: keep React Fast Refresh working for views with a config export (#5576) (CP: 25.2) - #6033
Merged
Merged
Conversation
…5576) * fix: keep React Fast Refresh working for views with a config export @vitejs/plugin-react v6 adds its refresh footer in a plugin that runs after the file-router's pre-enforced transform, so the previous regex injection into that footer never matched and editing a view with a static `config: ViewConfig` export caused a full page reload instead of HMR. Replace the injection with the refresh runtime's `window.__getReactRefreshIgnoredExports` hook: each view file registers its module id so the `config` export is skipped during refresh boundary validation. Config changes still propagate through the regenerated file-routes.ts module. Fixes #5159 * refactor: deliver the React Refresh ignore hook via a virtual module Incorporates the improvements from #5316: - Install window.__getReactRefreshIgnoredExports once through a virtual module imported by every view file, instead of duplicating the installer in each transformed view. View files keep registering their exact module ids, so private (_-prefixed) and non-route files under the views directory retain stock Fast Refresh semantics. - Skip the production-mode name preservation for anonymous default exports, where the regex captured the function/class keyword and produced invalid code, and support named default class exports. - Test the installed hook behavior (scoping, chaining with a pre-existing hook) in a vm context, and cover the production-mode transform. --------- Co-authored-by: Marco Collovati <marco@vaadin.com> Co-authored-by: Anton Platonov <platosha@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 25.2 #6033 +/- ##
==========================================
+ Coverage 85.94% 86.22% +0.27%
==========================================
Files 129 129
Lines 8822 8834 +12
Branches 1345 1354 +9
==========================================
+ Hits 7582 7617 +35
+ Misses 1216 1193 -23
Partials 24 24
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
platosha
approved these changes
Aug 17, 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.



No description provided.