vite-plugin-react: Could not Fast Refresh. Learn more at https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports

Describe the bug

I am Working on a Mono Repo which has thousands line of code. Previously we were on Vite Version 4.4.9 and during that the plugin was working as expected we were not any hmr invalidate but after upgrading to Vite 5. Now once i update file which exports all messages that is used by all other files now my terminal is bombarded with thousands of hmr invalidate messages. Sample is attached. Could you help why started hapening now and how can we move to older behaviour. As fixing all files to decouple util function exports and React Components exports is not possible as code base more than 20,000+ files

Could not Fast Refresh ("getCascadingArchivalSelectionError" export is incompatible). Learn more at https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports 3:11:59 PM [vite] hmr update /File1.tsx, /File2.tsx 3:11:59 PM [vite] hmr invalidate /File2.utils.tsx Could not Fast Refresh ("getReplicationTargetSelectionError" export is incompatible). Learn more at https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports

Reproduction

NA

Steps to reproduce

Starting Dev server using vite --host

react({ jsxImportSource: '@emotion/react', babel: { plugins: ['@emotion/babel-plugin'], }, }),

System Info

System:
    OS: macOS 15.3
    CPU: (12) arm64 Apple M3 Pro
    Memory: 516.44 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.9.0 
    Yarn: 1.22.17 
    npm: 10.8.3 
    pnpm: 9.12.1 
  Browsers:
    Chrome: 132.0.6834.160
    Safari: 18.3
  npmPackages:
    @vitejs/plugin-react: 4.3.4 => 4.3.4
    @vitejs/plugin-react-swc: 3.3.0 => 3.3.0
    rollup: 4.30.1 => 4.30.1
    vite: 5.4.13 => 5.4.13

Used Package Manager

pnpm

Logs

No response

Validations

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

@AlokTakshak good news I finally took some time to try out fast refresh for hooks and it didn’t work as expected, but at least I opened a PR to avoid triggering these bad udpates for JSX hooks

So yeah this is the same issue as https://github.com/vitejs/vite-plugin-react/issues/354. You’re the third person to report, I guess it’s time to put work on that issue