[bundledDev] React Fast Refresh endpoint returns index.html instead of JavaScript
维护者通常 1 天内回复
还没有人认领这个 Issue。
- #1481 来自 @yousefissa —— 已关闭,未合并
评估
- 难度
- 4/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- react, typescript, vite
- 领域
- frontend
调研方向
Start with the linked reproduction and its vite.config.js, then run the documented curl request to /@react-refresh with bundledDev enabled and disabled. Check how the endpoint response differs; done means it returns the React Fast Refresh runtime as JavaScript, or reports an explicit documented limitation rather than returning index.html.
由索引模型根据 Issue 内容生成。
描述
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.0
Used 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.
- 主要语言
- TypeScript
- 星标
- 1.2k
- 派生
- 287
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 21
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
vitejs/vite-plugin-react 的其他 Issue
-
plugin-rsc: a client reference's CSS is linked before the CSS of the chunks it imports (build)可能已有人在做 @wozhenbang2004 于 7 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
vitejs/vite-plugin-react#1570 ·
维护者通常 1 天内回复
-
[plugin-rsc] With two dev servers in one process, loadModule runs in the last server's environment未关闭
难度 4/5 3-5 天 新手友好度 57/100
vitejs/vite-plugin-react#1589 ·
维护者通常 1 天内回复
-
pending triage
难度 4/5 3-5 天 新手友好度 35/100
vitejs/vite-plugin-react#1581 ·
维护者通常 1 天内回复
-
[plugin-rsc] Build exits 0, but the app fails at runtime: a server action imported only by browser code is missing from the RSC build可能已有人在做 @NeilPant 于 4 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
vitejs/vite-plugin-react#1578 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 42/100
vitejs/vite-plugin-react#1577 ·
维护者通常 1 天内回复
查看 vitejs/vite-plugin-react 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
ardia-browser/ardia#4778 ·
维护者通常 1 天内回复
-
[M09] Silence parser misreads ffmpeg times in scientific notation (6.25e-05 → 6.25 s)可能已有人在做 @G-darshan-32 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
clipy-recorder/clipy#164 · 1 条评论 ·
-
bug from-app needs-triage
难度 2/5 1-3 小时 新手友好度 72/100
nightly-labs/openbot#18462 ·
维护者通常 1 天内回复
-
Fast and light shell approval "Always allow" button shows raw English backticks and scrambles commands in Arabic可能已有人在做 @tylerbea 今天认领。 未关闭agent-ui bug p3
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[Bug] Windows: Ctrl+C / Ctrl+V not working in chat input box可能已有人在做 @PranavTJ-05 今天认领。 未关闭comp/desktop desktop/chat desktop/shell os/windows P2 type/bug
难度 2/5 1-3 小时 新手友好度 76/100
NousResearch/hermes-agent#161023 · 2 条评论 ·
维护者通常 1 天内回复