-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Feat] Support new jsx - jsx-runtime #5085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't quite get your meaning, we already have jsx-next, what is the different? |
Don't use the React JSX transform for Vue... they are not the same. For Vue 3 you should be using https://github.com/vuejs/jsx-next |
The repoI created a repo for support JSX runtime vue-jsx-runtime and examples vue-jsx-runtime-examples. Runtime size:
About examples( used TS): Different with vue jsx-next
First of allWe should forget the The advantages
|
@yyx990803 Once vue provider exports If you don't want rewrite too much, we could just wrap Howerver, hope it could do some refactor. // vue/jsx-runtime.ts
export const jsxs = (type: any, { children, ...otherProps }: any = {}, key: string | undefined) => {
const props = key ? { ...otherProps, key } : otherProps;
if (typeof type === "object") {
return h(type, props, isProxy(children) ? children : () => children);
}
return h(type, props, children);
};
export const jsx = (type: any, { children, ...otherProps }: any = {}, key: string | undefined) => {
const props = key ? { ...otherProps, key } : otherProps;
if (children) {
if (typeof type === "object") {
return h(type, props, isProxy(children) ? children : () => children);
}
return h(type, props, children);
}
return h(type, props);
}; // vue/jsx-dev-runtime.ts
import { Fragment } from "vue";
import { jsx, jsxs } from "./jsx-runtime";
export { Fragment };
export function jsxDEV(
type: any,
props: any = {},
key: string | undefined,
_isStaticChildren: boolean,
_source: object,
_self: object
) {
if (Array.isArray(props.children)) {
return jsxs(type, props, key);
}
return jsx(type, props, key);
} {
"exports": {
"./jsx-runtime": {
"import": {
"types": "./jsx-runtime.d.ts",
"default": "./jsx-runtime.mjs"
}
},
"./jsx-dev-runtime": {
"import": {
"types": "./jsx-dev-runtime.d.ts",
"default": "./jsx-dev-runtime.mjs"
}
}
},
} |
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 tovue.h(...)
What does the proposed API look like?
In:
Out:
The text was updated successfully, but these errors were encountered: