change the react refresh url from `/@refresh-runtime`

オープン
#1,015 コメント 2 件 リアクション 3 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
react, typescript, vite
領域
tooling, web-dev

調査の方向性

まず packages/plugin-react、packages/plugin-react-swc、packages/plugin-react-oxc の refresh-runtime の処理を調べ、次に Sec-Fetch-Dest ヘッダーなしで /@{username} のような SSR ルートとの競合を再現します。完了条件は、確認したプラグイン全体で React refresh リクエストがアプリケーションのルートと競合しなくなり、dev モードでもクライアント側の JavaScript が引き続き読み込まれることです。

索引モデルが issue の本文から書いたものです。

説明

pending triage plugin: react
Related plugins
Description

in our application (tanstack start), there is an ssr route on /@{username} to show a user's profile, and the vite react plugin uses /@react-refresh without any trailing data. this causes the routes to conflict.

we never noticed this, because on localhost the browser sends Sec-Fetch-Dest: script, which vite uses to resolve the conflict. but in my current bug search, i am using the site from my phone in dev-mode, using the non-localhost http://169.254.x.x, which will not send these headers. the app now fails to run any client-side javascript since the script fetches "404 user not found" as HTML.

Suggested solution
  • change /@refresh-runtime to something else harder to collide with
    • perhaps /node_modules/@vitejs/plugin-react/dist/refresh-runtime.js to better reflect where the file is coming from
    • changeable with a configuration (my initial thought but i think the detailed path is better
Alternative

perhaps it should be configurable in vite to add a full prefix to the specifiers.

Additional context

i have a workaround (deleting the profile page temporarily) but would love this for coworkers that may need to perform a similar type of debug.

Validations
主要言語
TypeScript
スター
1.2k
フォーク
287
平均マージ
1日 19時間
マージ済み PR(30日)
21

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

vitejs/vite-plugin-react のほかの issue

vitejs/vite-plugin-react の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。