Skip to content

Compile JSX to direct createElement() calls #5435

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

Open
gaearon opened this issue Oct 14, 2018 · 6 comments · May be fixed by #8848
Open

Compile JSX to direct createElement() calls #5435

gaearon opened this issue Oct 14, 2018 · 6 comments · May be fixed by #8848

Comments

@gaearon
Copy link
Contributor

gaearon commented Oct 14, 2018

Due to how webpack works today with CommonJS, we pay the cost of three object property accesses (ReactWebpackBinding.default.createElement) for every JSX call. It doesn't minify well and has a minor effect on runtime performance. It's also a bit clowny.

We should fix this to compile JSX to something like

var createElement = require('react').createElement

createElement(...)

Could be a custom Babel transform. Could be a transform that inserts _createReactElement into scope and specifies it as the JSX pragma.

@gaearon
Copy link
Contributor Author

gaearon commented Oct 14, 2018

We should still require React to be in scope for consistency though. Hmm.

@stereobooster
Copy link
Contributor

@karanisverma
Copy link

Hi @gaearon I would like to pick this up! I have never worked on babel custom transfrom. it would be great if you can point me to some resource for the same(meanwhile I will google and try to understand how custom Babel transform can be implimented.)

@Rohanhacker
Copy link

@saranshkataria
Copy link
Contributor

Would be happy to pick this up if the proposed solutions do not look good enough.

@iansu iansu modified the milestones: 2.x, 3.x Mar 10, 2019
@NeoLegends NeoLegends linked a pull request Apr 17, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants