Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

@void/react: client environment has no optimizeDeps.entries for pages, causing a dev re-optimization reload on first load

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

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

@0froq がすでに取り組んでいます。

2026年10月27日 から。

  • #620 @0froq による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
66/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript, vite

調査の方向性

Start with react/src/plugin-pages.ts around lines 190–218 and 274, then trace how the dev config sets optimizeDeps for the client and worker environments. Reproduce with a cold node_modules/.vite cache and DEBUG=vite:deps vp dev; the issue includes a workaround and measurements. Done when page dependencies and void/pages-prefetch are optimized on the first load without a client reload.

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

説明

Summary

In dev, @void/react gives the worker environment a pages/** scan entry but gives the client environment none. Vite's client scanner therefore finds no dependencies, discovers them while serving the first page, re-bundles, and forces a full page reload ((client) optimized dependencies changed. reloading).

  • Version: void / @void/react 1.2.1 (latest). main at 65ab6032 has the same code.
  • packages/react/src/plugin-pages.ts#L190-L218: the client env only gets include: CLIENT_OPTIMIZE_DEPS (React); entries: [pagesOptimizeEntries] is set only under environments[WORKER_ENVIRONMENT_NAME] (L214).
  • The worker entry was added in ba979d5c ("Fix worker crash in dev on initial load"); its comment explains the worker case only. Nothing in the docs mentions optimizeDeps.
  • A second, related gap: the generated client entry imports void/pages-prefetch (L274). It is a virtual module, so the scanner can't see that import either, and void/pages-prefetch is discovered late even when page entries are scanned.

Repro

  1. A Pages app with a few page components that import third-party UI packages (e.g. @base-ui/react/*, @tanstack/react-query).
  2. rm -rf node_modules/.vite && DEBUG=vite:deps vp dev
  3. Open a page in the browser.

Observed (DEBUG=vite:deps):

(client) Scan completed in 12.74ms: no dependencies found
new dependencies were found while crawling that weren't detected by the scanner
new dependencies found: void/pages-prefetch, @base-ui/react/merge-props, ..., motion/react
(client) optimized dependencies changed. reloading

Measurements (one app, headless Chromium, cold node_modules/.vite, 3 runs per row, numbers summed over the whole load including the reload)

client config requests JS modules client reload median time to hydration
as shipped 238 / 231 233 / 226 yes (3/3) 3981 / 4207 ms
+ entries only 239 / 233 234 / 228 yes (3/3, only void/pages-prefetch late) 4048 / 4091 ms
+ entries + include: ['void/pages-prefetch'] 217 / 211 214 / 208 no (0/3) 3453 / 3180 ms

(two routes per cell)

Workaround

// vite.config.ts
export default defineConfig({
  optimizeDeps: {
    entries: ['pages/**/*.{js,jsx,ts,tsx}', '!pages/**/*.server.{js,jsx,ts,tsx}'],
    include: ['void/pages-prefetch'],
  },
  // ...
});

Suggested fix

In the dev config hook of plugin-pages.ts, also pass the page entries (excluding *.server.* companions) to the client optimizeDeps.entries, and add void/pages-prefetch to the client include (it is imported only by the virtual client entry).

主要言語
TypeScript
スター
580
フォーク
56
平均マージ
11時間 28分
マージ済み PR(30日)
150

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

voidzero-dev/void のほかの issue

voidzero-dev/void の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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