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

Suggestion: omit void 0 from output of new JSX transform (react-jsx) #47439

Closed
OliverJAsh opened this issue Jan 14, 2022 · 3 comments Β· Fixed by #47467
Closed

Suggestion: omit void 0 from output of new JSX transform (react-jsx) #47439

OliverJAsh opened this issue Jan 14, 2022 · 3 comments Β· Fixed by #47467
Labels
Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript

Comments

@OliverJAsh
Copy link
Contributor

OliverJAsh commented Jan 14, 2022

Bug Report

πŸ”Ž Search Terms

  • jsx
  • React
  • react-jsx
  • transform
  • void 0

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about JSX

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

export const el = <div>foo</div>;

tsconfig.json:

        "jsx": "react-jsx",

πŸ™ Actual behavior

import { jsx as _jsx } from "react/jsx-runtime";
export const el = _jsx("div", { children: "foo" }, void 0);

πŸ™‚ Expected behavior

import { jsx as _jsx } from "react/jsx-runtime";
export const el = _jsx("div", { children: "foo" });

This is how it works in Babel: Babel playground.

I just tried to migrate our codebase at Unsplash to use the new JSX transform but I noticed a cumulative increase of 5 KB across all chunks. If we can remove the extraneous void 0, this should help reduce the bundle size.

Twitter thread for reference: https://twitter.com/OliverJAsh/status/1481912497175203840

@RyanCavanaugh RyanCavanaugh added Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript labels Jan 14, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jan 14, 2022
@RyanCavanaugh
Copy link
Member

I'm not sure how that got there in the first place -- was it required at some point? Some background research to help us convince ourselves this is safe for all React versions would be good

@RyanCavanaugh RyanCavanaugh added the Help Wanted You can do this label Jan 14, 2022
@OliverJAsh
Copy link
Contributor Author

The new JSX transform was implemented in #39199. I searched the code and comments but didn't find very much. Maybe @weswigham could chime in?

This issue was also mentioned here but it was never addressed: #40774

@DanielRosenwasser
Copy link
Member

Thanks @a-tarasyuk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
3 participants