[⚡] [V2] every useComputed$ gets its own tiny chunk, and resume imports all of them at load

Abierto
#9,367 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
28/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
rollup, typescript, vite

Línea de trabajo

Start with EAGER_CTX_NAMES and the rolldown group logic in packages/qwik-vite/src/plugins/plugin.ts, then the signal QRL resolution in inflate.ts. The reporter's draft PR #9366 already proposes placing computeds with their creating entry, so review that before proposing another approach. Done means the chunking decision is settled and the resume path no longer issues one dynamic import per computed, which needs maintainer agreement on the design.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Which component is affected?

Qwik Core (optimizer / build)

Describe the bug

Hey 👋

In a production build with the default smart entry strategy, every useComputed$ segment ends up in its own tiny chunk (70 to 500 bytes), because the rolldown group for the "eager contexts" returns null for them:

https://github.com/QwikDev/qwik/blob/main/packages/qwik-vite/src/plugins/plugin.ts (EAGER_CTX_NAMES, with the comment "Eager contexts stay with their parent, not a segment chunk" and a TODO about useComputed$)

Since 7f51ab522 the runtime resolves the QRL of every serialized computed signal while resuming (inflate.ts), so a page pays one dynamic import() per computed at load, before any of them is needed. In v1 a computed's code was only loaded when it had to recompute, so the split cost nothing there.

On a page of mine with 38 computeds at load this showed up as the biggest part of the resume task: importSymbol took 52 ms self time (4x CPU throttle) against 7 ms for the same app on Qwik 1.x, and the page had a 122 to 134 ms long task right after qresume (Lighthouse mobile, chords page, text heavy, about 620 DOM nodes).

I opened a draft PR that treats a computed like useTask$ (it ships with the chunk of the entry that created it): https://github.com/QwikDev/qwik/pull/9366

Numbers, same app and same data, Lighthouse mobile, 3 runs each:

TBT long task after resume
main as is 88 to 106 ms 122 to 134 ms
with the PR 58 to 68 ms 100 to 103 ms

(For comparison the same page on Qwik 1.x has about 5 ms TBT, the rest of the gap is state deserialization at resume.) The same 38 computed symbols still run at load.

How to see it

Build any app with a few useComputed$ in components that are server rendered and look at dist/build: one chunk per computed, each exporting a single s_... symbol. Then load the page and look at the network tab right after resume.

I can put together a small repro repo if that helps.

System Info
  Binaries:
    Node: 24.16.0
  npmPackages:
    @qwik.dev/core: 2.0.0-rc.4 (+ main)
    vite: 8.x
Lenguaje dominante
TypeScript
Estrellas
22.1k
Forks
1.4k
Merge medio
1 d 13 h
PR fusionados (30 d)
159

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de QwikDev/qwik

Todos los issues de QwikDev/qwik

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.