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

@void/react: a non-island component under an _-prefixed directory in pages/ ships every page module to the browser

Fechada
#575 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Um pull request relacionado já foi integrado.

  • #603 de @dvkam — integrado

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
72/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
react, typescript, vite
Domínio
backend, build-system

Direção de pesquisa

Read packages/react/src/plugin-pages.ts and compare its hasNonIslandPages() path handling with the scanner in scan.ts; the report says the Solid plugin has the same check. Reproduce with the provided _ui/frame.tsx example and inspect dist/client/assets after vp build. Done when files below underscore-prefixed directories are excluded from client bundles, with a regression test covering the case.

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

Descrição

Version: void / @void/react 1.2.1 (also 1.1.12); main at a6de7829.

Repro

  1. pnpm create void (React, static output: output: 'static' in void.config.ts).
  2. pages/index.island.tsx:
    import { Frame } from './_ui/frame';
    export default function Home() { return <Frame><h1>Hello</h1></Frame>; }
    
  3. pages/_ui/frame.tsx, a shared server-only component that is not a page or an island:
    export const SECRET_COPY = 'server-only text';
    export function Frame({ children }: { children: React.ReactNode }) {
      return <main data-x={SECRET_COPY}>{children}</main>;
    }
    
  4. vp build, then ls dist/client/assets and grep -l 'server-only text' dist/client/assets/*.js.

Expected: an island-only app emits no pages-client bundle, and frame.tsx (not a route, because the route scanner skips _ segments) never reaches dist/client.

Actual: pages-client-*.js plus a chunk for every page module and every import (frame-*.js) are emitted to dist/client/assets, and the server-only strings are in them. In our app that is 18 files and 351 KB instead of 5 files and 33 KB, and 42 strings that were meant to stay server-side.

Cause: packages/react/src/plugin-pages.ts hasNonIslandPages() skips only basenames that start with _:

if (name.startsWith('_') || name.startsWith('layout.')) continue;

entry.name for pages/_ui/frame.tsx is frame.tsx. The pages scanner (scan.ts) skips any segment that starts with _ (except _layouts), so the two disagree. The Solid plugin has the same check.

Suggested fix: test every path segment relative to dir, as the scanner does:

const rel = relative(dir, join(entry.parentPath, name));
if (rel.split(sep).some((s) => s.startsWith('_')) || name.startsWith('layout.')) continue;

This is adjacent to #559, which adds the .server. exclusion to the same line.

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.