3 ms·
Hey guys, I made Tamagui because there’s no reason we should have to accept clunky, slow apps when sharing code between React Native and Web. It has a pretty ad
by nwienert 4y ago
Hey guys, I made Tamagui because there’s no reason we should have to accept clunky, slow apps when sharing code between React Native and Web. It has a pretty advanced optimizing compiler that’s been a fun (and challenging) project.
If you’d like a high level on how the optimizing compiler works and why its important, I wrote some here [0].
Happy to expand on any tech details. It’s not too fancy - Babel, AST analysis, logic to parse and normalize many expressions, then passing all static scope (even across module boundaries) to the underrated node vm[1] package.
If it can analyze all the props for any component statically, it flattens what would normally be a somewhat expensive React component into a simple div (or View on native), including ones with inline logic so you can write your components/styles naturally.
The tree flattening and focus on outputting CSS rather than JS is the real magic sauce netting big gains in performance all over - bundle size, startup, runtime.
We see a 15-20% increase in lighthouse score on the site homepage just by toggling the compiler on, with over 400 components being flattened (!)
[0] https://tamagui.dev/docs/intro/compiler https://tamagui.dev/docs/intro/compiler
[1] https://nodejs.org/api/vm.html https://nodejs.org/api/vm.html