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

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

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
28/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rollup, typescript, vite

調査の方向性

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.

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

説明

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
主要言語
TypeScript
スター
22.1k
フォーク
1.4k
平均マージ
1日 13時間
マージ済み PR(30日)
159

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

QwikDev/qwik のほかの issue

QwikDev/qwik の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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