React / foldkit-react-codegen
Diagnostics when compilation refuses a construct
When a view uses an unsupported construct, the CLI prints file:line:column - error CODE: message, writes no output, and exits with status 1:
FKREACT0001:h.submodelmissing a literal{ model, view, toParentMessage }object, orh.keyedwith a computed tag name.FKREACT0002: Unsupported attributes lacking a faithful React equivalent (OnMount,OnUnmount, nativeOnChange,InnerHTML, or unlisted attributes).FKREACT0003: Non-literal attribute arrays, spreads inside attribute arrays, or attribute helpers built outside an element call.FKREACT0004: Assigning or passinghto anything other than calling it or passing it directly to a helper view.FKREACT0005: Click modifier options, non-literalStyleobjects, or computedAttributenames.FKREACT0006: Lazy slots stored or invoked outsideconst slot = createLazy()and a directslot(...)call.FKREACT0007: Custom element specs that are not inlineCustomElement.define({ tag, properties, events })declarations or bound outsidespec.withMessage(h).
Keep components needing these features in Foldkit and embed them with foldkit-react.
Semantic differences in React output
- Lazy Message construction: Foldkit builds Message values during render; compiled handlers build them when the event fires (equivalent for pure constructors).
- Direct calls without memo slots: Lazy slots compile to direct calls (wrap callers in
React.memoif needed),slotIddisappears, and unused Foldkit runtime imports are stripped. - List keys: React warns on unkeyed arrays; use
h.keyedorh.Keyin lists intended for React compilation.
CLI flags
Run foldkit-react-codegen <file-or-directory>... --out-dir <directory> with optional flags:
--root-dir <directory>: Base path for relative output structure under--out-dir(defaults to working directory).--watch: Recompiles on changes, keeping the last valid build on diagnostics and ignoring its own output writes.--source-map: Emits<output>.tsx.mapwithsourceMappingURLmapping JSX nodes back to Foldkit source lines.
Files without views copy through (preserving relative imports), unchanged byte output skips disk writes, and .d.ts / .test.ts files are ignored.