Skip to content

fix: keep React Fast Refresh working for views with a config export (#5576) (CP: 25.2) - #6033

Merged
platosha merged 2 commits into
25.2from
cherry-pick-5576-to-25.2-1786717295323
Aug 17, 2026
Merged

fix: keep React Fast Refresh working for views with a config export (#5576) (CP: 25.2)#6033
platosha merged 2 commits into
25.2from
cherry-pick-5576-to-25.2-1786717295323

Conversation

@vaadin-bot

Copy link
Copy Markdown
Collaborator

No description provided.

…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

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.22%. Comparing base (6159674) to head (3a99c1b).

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              
Flag Coverage Δ
unittests 86.22% <100.00%> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

Copy link
Copy Markdown

@platosha
platosha merged commit a147771 into 25.2 Aug 17, 2026
14 checks passed
@platosha
platosha deleted the cherry-pick-5576-to-25.2-1786717295323 branch August 17, 2026 13:59
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.

3 participants