Skip to content

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

Closed
@OliverJAsh

Description

@OliverJAsh

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions