I'm starting to think that automated detection might be a significant footgun. At least when done this way. https://github.com/facebook/create-react-app/pull/9788/files#r506932998
I'm leaning towards this proposal:
This also addresses automatic detection issues in https://github.com/facebook/react/issues/20031#issuecomment-710821817.
IMHO the detection is fine - it solves more problems than it creates. As mentioned in the other thread - I believe that if pragmas alone would reconfigure the transform then there wont be a problem here. We would eat the cake and have it too 😉
Just waiting for some more thoughts from the team on this, but we could leave the automatic detection on - with a manual "emergency" flag, as we know it may fail in some cases (where there are mixed React versions installed).
Another option may be to move back to the previous logic, and find another way to resolve the Jest issue - maybe an environment variable that we set in test or something like that.
We definitely need an opt-out flag. For detection, if we leave it in — it needs to resolve React from the application folder (and not from react-scripts's own folder). It needs to happen outside the Babel preset because the preset output itself must be deterministic, or caching won't work correctly.
I think I addressed all these issues in #9861
Most helpful comment
We definitely need an opt-out flag. For detection, if we leave it in — it needs to resolve React from the application folder (and not from
react-scripts's own folder). It needs to happen outside the Babel preset because the preset output itself must be deterministic, or caching won't work correctly.