Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#599 1 comentário 1 reação 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@0froq já está trabalhando nisso.

Desde 27/10/2026.

  • #620 de @0froq — aberto

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
66/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
typescript, vite

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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).

Linguagem predominante
TypeScript
Estrelas
580
Forks
56
Merge médio
11h 28min
PRs com merge (30d)
150

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de voidzero-dev/void

Todas as issues de voidzero-dev/void

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.