Skip to content

[Feat] Support new jsx - jsx-runtime #5085

@dolymood

Description

@dolymood

What problem does this feature solve?

Same feature issue in Vue2 vuejs/vue#12379.

See https://babeljs.io/docs/en/babel-plugin-transform-react-jsx for more details.

We can have a better JSX experience.

Even we can process all the directives/ref/slot features with vue/jsx functions.

Transform original jsx(...) input to vue.h(...)

What does the proposed API look like?

In:

/** @jsxImportSource vue */

const profile = (
  <div>
    <img src="avatar.png" class="profile" />
    <h3>{[user.firstName, user.lastName].join(" ")}</h3>
  </div>
)

Out:

import { jsx as _jsx } from "vue/jsx-runtime";
import { jsxs as _jsxs } from "vue/jsx-runtime";

const profile = _jsxs("div", {
  children: [
    _jsx("img", {
      src: "avatar.png",
      class: "profile",
    }),
    _jsx("h3", {
      children: [user.firstName, user.lastName].join(" "),
    }),
  ],
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions