Skip to content

transform-react-jsx with runtime: automatic should always using jsx-runtime #12177

Description

@morlay

Bug Report

"@babel/plugin-transform-react-jsx" ^7.10.4

[ "@babel/plugin-transform-react-jsx", { "runtime": "automatic"  }]

Current behavior
fallbacked classic runtime when jsx use spread with key exists

_createElement("span", {...obj, key: "key"})

Input Code

<span {...obj} key={"key"} />

Expected behavior

_jsx("span", obj, "key")

Environment

  • Babel version(s): 7.12.0
  • Node/npm version: 14.12.0
  • OS: [e.g. OSX 10.13.4, Windows 10]
  • Monorepo: yes
  • How you are using Babel: cli, register, loader

Possible Solution

may transform codes like

<span key={key} {...obj} /> => jsx("span", obj, key)
<span {...obj} key={key} /> => jsx("span", {...obj, key}, key)

to support https://github.com/babel/babel/blob/master/packages/babel-helper-builder-react-jsx-experimental/src/index.js#L270

it will be friendly for custom jsx-runtime and some react-like lib

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions