[2.0 rc.14] Feature request: prerender(view), running a view's reads to preload them without creating its elements or running its effects
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 12/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- javascript, typescript
- 领域
- frontend, performance
调研方向
The payload names no files or tests. Start with the workaround in the body, which renders the view into a detached host inside a Loading boundary, to see which reads it triggers. Then look at how hydration runs component code once to trace dependencies, since the author suggests it as a starting point. Done means a design the maintainers accept, since the runtime or compiler support needed is their call.
由索引模型根据 Issue 内容生成。
描述
Summary
Preloading on hover or intent usually means listing what the next view will read, which repeats its component tree. Rendering the view itself discovers its reads, but the only way to do that today is a full client render into a detached element, kept from committing by a <Loading> that never resolves. That builds every element of the view only to discard them, gives no signal when all its reads have settled, and needs owner and context plumbing by hand. A primitive that runs a view's components and reads, and nothing else, would make render-driven preloading cheap and explicit.
Today
The current way, and the undocumented behaviour it depends on, is #3974:
function preview(view: () => JSX.Element, owner: Owner | null) {
const host = document.createElement("div");
return runWithOwner(owner, () =>
render(() => {
const gate = createMemo(() => new Promise<never>(() => {}));
return (
<Loading fallback={null}>
{gate()}
{view()}
</Loading>
);
}, host),
);
}
Measured in headless Chromium under vite dev, previewing a list with one detail per row, each element's ref logging its creation: the list's read started at 0 ms and both detail reads at 103 ms, as soon as the list answered. The ul and both p elements were created (their ref callbacks ran), but the host stayed empty and no createEffect or onSettled ran. Every element of the previewed tree is built and thrown away, and nothing reports when the detail reads finished.
Proposal
const run = prerender(() => <Page />); // under the current owner and context
run.settled; // resolves when every read in the tree, including ones found as data arrived, has settled or failed
run.dispose(); // stop early; loads already started still finish
- Runs component bodies, memos and async reads (memos, stores, projections,
lazy()andlazyModule()), following the tree level by level as data arrives, as a pending boundary does. - Creates no elements, render effects or effects, and commits nothing.
- Keeps its pending state out of
isPendingand transitions, its holds out of the hold diagnostics, and its errors away from any<Errored>; a failed read stays failed in its source, for the real view to retry. - Disposes itself once
settledresolves.
The compiled client output creates elements in component bodies, so skipping them likely needs runtime or compiler support; how is the maintainers' call. Hydration already runs component code once to trace dependencies (with promises held), which may be a starting point.
Related: #3213 (RFC for <Activity>, keeping hidden UI and its state; this request is narrower: no DOM and nothing kept, only the reads), #1008 (<Offscreen>), #1877 (a low-level primitive to pause effects in offscreen branches), #3941 (lazyModule(), preloading code), and React's <Activity mode="hidden">, which pre-renders hidden trees to load their data and code.
(submitted by Claude Opus 5.5 on behalf of rvlzzr)
- 主要语言
- TypeScript
- 星标
- 36.1k
- 派生
- 1.1k
- 平均合并
- 9 小时 56 分钟
- 30 天内合并 PR
- 336
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/solid 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
[diagnostics rc.14 / next] Browser bridge drops shared references, so `expectNoSilentHolds` throws on any capture with a `LONG_HOLD`可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 3/5 半天 新手友好度 32/100
维护者通常 1 天内回复
-
[2.0 rc.14 / next] SSR: async memo retries run under another concurrent render's context可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 52/100
维护者通常 1 天内回复
-
hydrate() run mid-parse leaves dead server nodes beside fresh client copies (async entry script)未关闭
难度 4/5 3-5 天 新手友好度 20/100
维护者通常 1 天内回复
相似的 Issue
-
area:deploy task
难度 2/5 1-3 小时 新手友好度 72/100
wilanis/wilanis-js#1017 ·
维护者通常 1 天内回复
-
documentation v2
难度 2/5 1-3 小时 新手友好度 76/100
modelcontextprotocol/servers#5133 ·
维护者通常 1 天内回复
-
budget bug feature frontend good-issue medium needs-review OSCI'26 payments
难度 2/5 1-3 小时 新手友好度 75/100
SatyamPandey-07/WorkSphere#5990 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
lugassawan/swe-workbench#799 ·
维护者通常 1 天内回复
-
bug good first issue javascript
难度 2/5 1-3 小时 新手友好度 82/100
yukikotani231/sqlsift#326 ·
维护者通常 1 天内回复