You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(transform): fold static JSX past opaque spreads and styled() chains (#3699)
* fix(transform): rewrite JSX elements whose every spread is style-only
A spread the extractor already folded into the element's styles still
counted as a runtime spread, so an element like
`<styled.div {...baseStyle} css={x} />` bailed even though nothing dynamic
was left. Recognize the resolved identifier and member spreads and let the
element rewrite.
`StyleSpread::Open` now carries the span of the spread that produced it, so
a later pass can tell which source spread is opaque rather than only that
one is.
* feat(transform): fold the static half of an element with an opaque spread
`<styled.button {...props} type="button" css={x} />` bailed entirely because
of the spread, so every style source on it was resolved per render. The
factory and the spread now stay — style-prop splitting and DOM filtering
still happen for whatever the spread turns out to hold — while every style
Panda can see collapses into one className.
Requires a bare identifier spread, exactly one opaque spread, no style
source ahead of it, and no explicit className, so the precedence the
factory gives them is reproducible. The class read is optional-chained
because a nullish spread is a legal no-op in JSX.
* feat(transform): fold a same-file styled() chain to its host element
`const Button = styled('button', { base: … })` renders through forwardRef,
which costs a component level per instance even when the class never
changes. When the chain is base-only and rooted in an intrinsic tag, every
`<Button>` folds to `<button className="…">` and the definition is left for
the bundler to drop.
A tag folds only when it resolves to the symbol the chain declared, so a
local binding that shadows the module-level one is untouched — the same
check the imported-tag branch beside it already makes.
Variants, an options argument, a non-local base, `let`/`var`, or a
declaration inside a function all keep the runtime chain.
0 commit comments