r/reactjs • u/Remarkable_Salad2462 • May 09 '26
Discussion Tell me why my approach is wrong
[EDIT 3 months later — two of the four issues raised in the comments are now solved. Details at the bottom.]
I couldn't tolerate the runtime merging of CSS Modules and tailwind-merge, so I wrote a compiler that uses ASTs to create lookup tables for all patterns. The result is zero runtime, zero bundle size CSS-in-JS. The documentation is here (https://plumeria.dev), and the design philosophy is in this article — in Japanese — (https://zenn.dev/refirst11/articles/db47880cdfe443), but what do you think are the pitfalls of this approach? Is there something fundamentally wrong with eliminating the runtime entirely?
EDIT (3 months later). The top comment found four holes. Two are closed, one I'd failed to answer, one is still real. Since the original post linked out instead of showing anything, here's the actual shape of it:
const styles = css.create({
text: { fontSize: 12 },
cond: { background: 'navy' },
scale: (value) => ({ scale: value }),
});
<div classStyle={[styles.text, cond && styles.cond, styles.scale(scale)]} />
compiles to:
<div
className={'xhrr6ses ' + (cond ? 'xj00ajs1' : '') + ' xnoo1byz'}
style={{ '--scale-value': scale }}
/>
Static styles become class names at build time; only genuinely dynamic values survive as CSS variables. Details in the replies below.