[babel-plugin] Optimize dynamic styles output
Open
- Dominant language
- JavaScript
- Stars
- 10.3k
- Forks
- 481
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 13
Description
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).
May be missing some cases
Contributor guide
Assessment
This issue has not been assessed yet.