Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Client setup seam: run app code before the generated entry's hydrate (start.clientSetup)

未關閉
#419 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
25/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
typescript, vite

研究方向

This is a design decision, not a ready-to-code task: the issue asks for a start.clientSetup option or a <ClientEntry /> component, and the maintainers have not chosen between them. Start with the code that generates the client entry and the existing start.instrument server hook, which the issue uses as the model. Done means a maintainer agrees on the API and the generated entry runs the setup module before hydrate.

由索引模型根據 Issue 內容生成。

描述

@solidjs/vite-plugin 3.0.0-next.50, solid-js 2.0.0-rc.15.

The generated client entry calls hydrate straight away, and there is no place for app code that has to run in the browser before hydration. Our real cases:

  • Installing a server-function transport wrapper that detects a response from another build (version skew) and reloads. It must be in place before the first render fires the page's reads.
  • A request-header hook on that transport, for example a tenant selector header the server functions need.
  • Registering the vite:preloadError listener before any lazy route chunk loads.
  • Reading a third-party global that a classic <script> in <body> defines (Telegram's telegram-web-app.js). Today the generated entry is an async module in <head>, so its order relative to that script is not guaranteed. #411 / solidjs/solid#4002 fixed hydration itself here, but not setup code that reads globals.

Because of this we keep authored entry-client.tsx / entry-server.tsx pairs only to run three lines before hydrate. That means we also carry the Document + hydrate(…, document) boilerplate that the generated entries would give us.

Suggestion (either works for us):

  1. start.clientSetup: './src/client-setup.ts'. The generated client entry does await import(setup) (or a static import placed first) before hydrate. This mirrors start.instrument on the server.
  2. A <ClientEntry /> component that the document places where it wants (for example at the end of <body>), with the setup module option above.

Option 1 alone would let us delete both authored entries.

主要語言
TypeScript
星號
522
分支
73
平均合併
1 天 4 小時
30 天內合併 PR
35

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  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 摘要。