Updates "@babel/preset-react" preset "runtime" param to "automatic" and cleans up import lines#325
Conversation
|
Hi @sagemintblue! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
While working through the Relay tutorial and its "newsfeed" example [1] I was confused by some seemingly unused import lines in tsx files of the following form:
My VSCode configuration enables removal of unused imports when files are saved, so this line was being removed. This led to a runtime error of the form:
Some searching lead me to the new JSX Transform announcement [2] which suggested that most of these React import lines are no longer needed. After further reading I found docs for the "@babel/preset-react" Babel preset [3] which suggest that the
runtimeparameter should beautomatic(instead ofclassic, the default value) to ensure the functions that JSX transpiles to are automatically imported. This change did the trick for me. After cleaning up the import lines across most tsx files in the newsfeed project it still builds and runs without issue for me.[1] https://relay.dev/docs/tutorial/intro/
[2] https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
[3] https://babeljs.io/docs/babel-preset-react