Created by: NeoLegends
This PR fixes https://github.com/facebook/create-react-app/issues/5435 and addresses https://github.com/facebook/create-react-app/pull/6219#issuecomment-613932332 by employing a new Babel plugin that replaces calls to React.createElement
with calls to a local variable that is bound to React.createElement
.
Originally I aimed for a babel plugin implementation that makes use of JSX pragmas to instruct the translator to use the local variable. That did not work out in the context of CRA, so the current implementation is based on what was proposed in https://github.com/facebook/create-react-app/pull/6219.
Right now, the plugin lives in my GitHub profile at https://github.com/NeoLegends/babel-plugin-transform-react-create-element. If desired, I'll happily transfer ownership of the code and the npm package here and remove the usage of TypeScript.
I tested the changes using yarn build
, inspecting the build output and verifying things work in the browser. The babel plugin itself also features tests.