Minor Changes
-
#13
a7e43feThanks @awilderink! - ## Universal componentsPlain
.tsxfiles without a"use client"directive or@jsxImportSourcepragma are now universal components. They automatically compile to the correct JSX runtime based on who imports them:- Imported from a server route: compiles with Atollic HTML JSX (string output)
- Imported from a React island: compiles with React JSX (
className, style objects) - Imported from a Solid island: compiles with Solid JSX (no transform needed)
Write
class,onClick, and stringstyleonce. It works everywhere.New exports
UniversalFC<P>- typed function component signature for universal componentsUniversalChildren- opaque children type alias
import type { UniversalFC } from "atollic"; const Button: UniversalFC<{ variant?: "primary" | "ghost" }> = (props) => ( <button class={props.variant}>{props.children}</button> ); export default Button;
How it works
The Vite plugin detects when a universal component is imported from a
"use client"island and resolves it with a?framework=Xquery. Theloadhook injects the correct@jsxImportSourcepragma and applies attribute mapping (e.g.classtoclassNamefor React,stylestrings to style objects). Function-valued props likeonClickare silently dropped when rendering as server HTML.Other changes
FrameworkAdapterinterface gains an optionaltransformUniversal(code)method for framework-specific attribute mapping- Server HTML JSX runtime now skips function-valued props instead of rendering them as strings
- Event handler types (
on*) in Atollic's JSX namespace accept functions alongside strings