Create-react-app: [v4] Use new runtime by default or fix the detection

Created on 17 Oct 2020  Â·  4Comments  Â·  Source: facebook/create-react-app

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:

  1. Enable new transform by default in V4 (since we've now released compatible React versions for all majors)
  2. Offer an env option to turn it off

This also addresses automatic detection issues in https://github.com/facebook/react/issues/20031#issuecomment-710821817.

bug report

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.

All 4 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fson picture fson  Â·  3Comments

wereHamster picture wereHamster  Â·  3Comments

rdamian3 picture rdamian3  Â·  3Comments

stopachka picture stopachka  Â·  3Comments

DaveLindberg picture DaveLindberg  Â·  3Comments