Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Retain $ServerOnly templates while HMR is active

未关闭
#308 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
babel, typescript, vite

调研方向

使用 pnpm install 和 pnpm dev 通过链接的 repro 重现该失败,然后编辑 src/App.tsx。从计算 needHmr 的客户端转换路径开始,将其编译器选项与显式的 omitServerOnlyTemplates 设置进行比较。完成的标准是 HMR 在没有模板错误的情况下更新 DOM,同时显式的用户设置仍然具有优先权。

由索引模型根据 Issue 内容生成。

描述

Summary

When an SSR application uses $ServerOnly on a component's root JSX element, the initial render and hydration succeed, but the first HMR update throws and leaves stale DOM.

[email protected] now defaults omitServerOnlyTemplates to true. During a client HMR re-evaluation, Solid Refresh calls the component outside the initial hydration pass, but the compiled component only calls getNextElement() and has no retained template.

Because vite-plugin-solid already determines needHmr, could it default omitServerOnlyTemplates to false for client transforms while HMR is active? An explicit user setting should presumably continue to win.

Reproduction

https://github.com/birkskyum/repro-solid-server-only-hmr

git clone https://github.com/birkskyum/repro-solid-server-only-hmr.git
cd repro-solid-server-only-hmr
pnpm install
pnpm dev
  1. Open http://localhost:4174.
  2. Change edit me! in src/App.tsx and save.
Actual

The DOM does not update, and the HMR evaluation throws:

TypeError: template is not a function
  at getNextElement (.../solid-js/web/dist/dev.js)
  at _$getNextElement (src/App.tsx)
  at HMRComp.createMemo.name [as fn] (@solid-refresh)
Expected

The component hot-updates normally.

Control / proposed direction

The exact same edit succeeds when the compiler option is set explicitly:

solid({
  ssr: true,
  solid: { omitServerOnlyTemplates: false },
})

This appears to be needed only for the client transform when HMR is enabled; server and production transforms can keep omitting the template.

Versions

Downstream report: https://github.com/solidjs/solid-start/issues/1930

Relevant dom-expressions change: https://github.com/ryansolid/dom-expressions/commit/3774c790a9c3c8e2b2f2984f36be002ac612df34

主要语言
TypeScript
星标
520
派生
70
平均合并
16 小时 4 分钟
30 天内合并 PR
34

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

solidjs/solid-vite-plugin 的其他 Issue

查看 solidjs/solid-vite-plugin 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。