Repository navigation
[bundledDev] React Fast Refresh endpoint returns index.html instead of JavaScript #1482
Description
Describe the bug
When using Vite 8's experimental bundledDev mode together with @vitejs/plugin-react, the /@react-refresh endpoint returns the bundled application index.html instead of the React Fast Refresh runtime JavaScript.
This is reproducible in a minimal Vite + React project without Module Federation.
The response is successful from an HTTP perspective (200 OK), but the content type and response body are incorrect for a JavaScript runtime endpoint. This causes integrations that import the React Refresh runtime to
receive HTML instead of JavaScript.
In our Module Federation setup, a React Remote's refresh proxy imports the Host's /@react-refresh URL. When the Host uses bundledDev, that import receives index.html and fails with:
TypeError: Failed to fetch dynamically imported module:
http://127.0.0.1:5173/@react-refresh
The Module Federation integration is not required to reproduce the Vite endpoint behavior; it only exposes the incompatibility in an integration scenario.
Reproduction
https://github.com/dmchoi77/vite-bundleddev-react-refresh-repro
Steps to reproduce
-
Clone the reproduction repository:
git clone https://github.com/dmchoi77/vite-bundleddev-react-refresh-repro.git cd vite-bundleddev-react-refresh-repro -
Install the dependencies:
npm install
-
Start the Vite development server:
npm run dev
-
In another terminal, request the React Fast Refresh endpoint:
curl -i http://127.0.0.1:5173/@react-refresh
-
Compare the response with
bundledDevdisabled:- Change
bundledDev: truetobundledDev: falseinvite.config.js. - Restart the development server.
- Run the same
curlcommand again.
- Change
Actual result
With experimental.bundledDev: true, the endpoint returns the application
HTML document:
HTTP/1.1 200 OK
Content-Type: text/html
The response body contains index.html, including the bundled entry script:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite bundledDev React refresh repro</title>
<script type="module" crossorigin src="/assets/index.js"></script>
</head>It does not contain the React Fast Refresh runtime JavaScript.
Expected result
The /@react-refresh endpoint should return the React Fast Refresh runtime as
JavaScript when @vitejs/plugin-react is enabled.
If React Fast Refresh is intentionally unsupported in bundledDev mode, the
endpoint should instead expose an explicit documented behavior or error so
that integrations can detect the limitation without receiving a successful
HTML fallback response.
For comparison, the same reproduction with experimental.bundledDev: false
returns the expected JavaScript response:
HTTP/1.1 200 OK
Content-Type: text/javascript
System Info
npmPackages:
@vitejs/plugin-react: 6.0.2 => 6.0.2
vite: 8.2.0 => 8.2.0Used Package Manager
npm
Logs
The endpoint response with bundledDev: true:
HTTP/1.1 200 OK
Vary: Origin
Content-Type: text/html
Cache-Control: no-cache
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite bundledDev React refresh repro</title>
<script type="module" crossorigin src="/assets/index.js"></script>
The related Module Federation integration error is:
TypeError: Failed to fetch dynamically imported module:
http://127.0.0.1:5173/@react-refresh
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Activity
ArnaudBarre commentedon Oct 4, 2026
@sapphi-red how do you think we should fix this? I was testing if
\0@react-refresh(works but it doesn't seem too)I suppose the nature of bundle dev forces us to setup a middleware to re-expose this (as done in the linked PR)?
sapphi-red commentedon Oct 5, 2026
I'm not sure if that works. The refresh runtime will be bundled so even if we exposed
/@react-refreshpath, that will be a separate duplicate module.We need to wait for the plugin guide for the bundled-dev so that the module federation plugin can explore how to handle this.