Skip to content

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

Closed

Description

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

Activity

  1. RyanCavanaugh commented on Jan 14, 2022

    @RyanCavanaugh
    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

  2. OliverJAsh commented on Jan 14, 2022

    @OliverJAsh
    ContributorAuthor

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

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

  3. DanielRosenwasser commented on Jan 18, 2022

    @DanielRosenwasser
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions