Skip to content

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

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

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