Compile-time styling (StyleX) can't see styles declared in .rx: imports are aliased and top-level bindings live inside the module factory
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 35/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- typescript
- 領域
- build-system
研究方向
Read the @solidjs/vite-plugin frontend transform hook and the compiler output that aliases imports and moves top-level declarations into the module factory. Check whether the proposed module-scope form can be emitted for .rx and then seen by a compile-time styling plugin. Done means the issue’s question is resolved, with either a supported integration path or documentation of the sibling .ts workaround in guide/libraries.md.
由索引模型根據 Issue 內容生成。
描述
Compile-time styling libraries can't see styles written in .rx. StyleX is the case we hit; vanilla-extract, Panda and similar tools have the same constraint.
What happens
import pure { attrs, create } from "@stylexjs/stylex"
local = create({ hint: { color: "red" } })
export component Hint() {
<p {...attrs(local.hint)}>hint</p>
}
rxc check passes. In the browser: Unexpected 'stylex.create' call at runtime. Styles must be compiled by '@stylexjs/babel-plugin', and Solid halts the reactive system (REACTIVITY_HALTED).
Why
Two things stack:
- No plugin sees the lowered code in time.
@stylexjs/unpluginisenforce: 'pre'and only transforms JS-like ids..rxbecomes JS inside@solidjs/vite-plugin'stransform(thefrontendshook), after everypreplugin has already passed over the raw.rxtext. - Even if one did, the output isn't analyzable. Compile-time styling needs
create({...})at module top level, with literal arguments and the import binding used directly. The crate's output aliases every import (import { create as w$create }…const v$create = w$create) and moves every top-level declaration insideexport default function module(__rt) { … }, wherelocalis a__rt.memo.
Today's workaround (works)
Declare styles in a sibling .ts module and import the compiled object: import pure { s } from "./form.styles", then attrs(s.form, props.styles). Recipe functions from a StyleX design system (import pure { button } from "…/stylex/button") also work unchanged. We verified this end to end with SSR and hydration on Solid 2.0.0-rc.21, @solidjs/vite-plugin 3.0.0-next.57 and compiler/runtime 0.3.1.
Suggestion
- A module-scope form that lowers verbatim. For example, a top-level binding whose right-hand side is a call to an imported
purefunction with literal arguments (or an explicit keyword) is emitted outside the module factory, and the import it calls stays unaliased. Styling compilers could then process.rxoutput the way they process.tsx. - Plugin ordering, in
@solidjs/vite-plugin. Let other plugins see a frontend's lowered JS. For example, lower inload, or document a hook point a styling plugin can run after. This depends on the first point; on its own it doesn't help.
Is compile-time CSS-in-JS a goal for .rx? Or is the scoped <style> (spec/07 CSS-1…5) the intended answer, with a sibling .ts for StyleX? Either answer is useful; if the latter, a line in guide/libraries.md would save the next person the runtime crash.
- 主要語言
- TypeScript
- 星號
- 127
- 分支
- 7
- 平均合併
- 15 小時 42 分鐘
- 30 天內合併 PR
- 63
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
solidjs/reactivescript 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 84/100
solidjs/reactivescript#96 ·
維護者通常 1 天內回覆
-
Vite front end keeps serving a failed build after the missing/broken imported module is fixed可能已有人在做 @cgaaf 於 1 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 77/100
solidjs/reactivescript#84 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
solidjs/reactivescript#77 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
solidjs/reactivescript#74 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 62/100
solidjs/reactivescript#97 ·
維護者通常 1 天內回覆
查看 solidjs/reactivescript 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
TriliumNext/Trilium#12837 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 85/100
LibreChat-AI/LibreChat#18944 ·
維護者通常 1 天內回覆
-
bug root-cause:found
難度 2/5 1-3 小時 新手友好度 70/100
openchamber/openchamber#7620 · 1 則留言 ·
維護者通常 2 天內回覆
-
enhancement good first issue help wanted
難度 2/5 1-3 小時 新手友好度 82/100
Anatomik5/codetovideo#8 ·
-
[Bug] Windows Ghidra provider rejects a PATH-only JDK: bare `java.exe` probe fails with Win32 87未關閉
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆