stylex
stylex copied to clipboard
[babel-plugin] Optimize dynamic styles output
Follow up to https://github.com/facebook/stylex/pull/1153
There are times in which we don't need to emit a ternary wrapping dynamic styles when we can confirm the expression is not null or undefined. We have coverage for binary and unary expressions, but there are a few more cases we can optimize for:
- template literals
- conditional exprs (recursively check both sides)
- logical expressions like
- nullish coalescing
??(if left side is safe) - logical or
||(if either side is safe) - logical
&&(both sides are safe ie. a string/binary/unary/template literal of course).
- nullish coalescing
May be missing some cases
- same treatment for the inline styles portion