Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize React.createElement property accesses #8848

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NeoLegends
Copy link

@NeoLegends NeoLegends commented Apr 17, 2020

This PR fixes #5435 and addresses #6219 (comment) 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 #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.

@facebook-github-bot
Copy link

Hi @NeoLegends!

Thank you for your pull request and welcome to our community.We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, 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.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@stale
Copy link

stale bot commented May 20, 2020

This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label May 20, 2020
@NeoLegends
Copy link
Author

No.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compile JSX to direct createElement() calls
3 participants