[compiler] Validate against component/hook factories
Previously, the compiler would incorrectly attempt to compile nested components/hooks defined inside non-React functions. This would lead to scope reference errors at runtime because the compiler would optimize the nested React function without understanding its closure over the parent function's variables. This PR adds detection when non-React functions declare components or hooks, and reports a clear error before compilation. I put this under a new compiler flag defaulting to false. I'll run a test on this internally first, but I expect we should be able to just turn it on in both compiler (so we stop miscompiling) and linter. Closes #33978 Playground example: https://react-compiler-playground-git-pr34305-fbopensource.vercel.app/#N4Igzg9grgTgxgUxALhAejQAgAIDcCGANgJYAm+ALggHIQDCEAtgA4QB2CbFA8jABIQIAawBi+OBQgxiCMAB0OAD1YwKmAGZQ2E4u0wBzBBQCSbZlAoAKfAEpMwBZkxx2YNQHUY+ZswQxMALyYlnYBAHz2jk7OrmoAFvhspIQIdAlshoHBoREObNHR+AB07GmJhiEA3FFOAL7VbDWYMEaw+QA8xGYWmKXphgHA6cmp-Qi1mGhhDXUNUS0UbZie3r4wDbUgtUA
L
Lauren Tan committed
8990ebf390e8e9861ddcab362ce23f59df1d8100
Parent: 33a1095