Skip to content

Commit b5e051d

Browse files
committed
feat(vue-jsx-vapor): add jsxImportSource support
1 parent a8f5e39 commit b5e051d

File tree

9 files changed

+1869
-13
lines changed

9 files changed

+1869
-13
lines changed

packages/vue-jsx-vapor/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@
9090
"require": "./dist/unplugin.cjs",
9191
"import": "./dist/unplugin.js"
9292
},
93+
"./jsx-runtime": {
94+
"dev": "./src/jsx-runtime.ts",
95+
"require": "./dist/jsx-runtime.cjs",
96+
"default": "./dist/jsx-runtime.js"
97+
},
9398
"./volar": {
9499
"dev": "./src/volar.ts",
95100
"require": "./dist/volar.cjs",
@@ -154,6 +159,10 @@
154159
"require": "./dist/raw.cjs",
155160
"import": "./dist/raw.js"
156161
},
162+
"./jsx-runtime": {
163+
"require": "./dist/jsx-runtime.cjs",
164+
"default": "./dist/jsx-runtime.js"
165+
},
157166
"./volar": {
158167
"require": "./dist/volar.cjs",
159168
"import": "./dist/volar.js"
@@ -212,6 +221,7 @@
212221
"@nuxt/kit": "catalog:",
213222
"@nuxt/schema": "catalog:",
214223
"@types/babel__core": "catalog:",
224+
"csstype": "^3.1.3",
215225
"vue": "catalog:"
216226
}
217227
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Fragment, h } from 'vue'
2+
import type { NativeElements } from './jsx-runtime/dom'
3+
4+
function jsx(type: any, props: any, key: any): ReturnType<typeof h> {
5+
const { children } = props
6+
delete props.children
7+
if (arguments.length > 2) {
8+
props.key = key
9+
}
10+
return h(type, props, children)
11+
}
12+
13+
export { Fragment, jsx, jsx as jsxDEV, jsx as jsxs }
14+
15+
type VNode = import('vue').VNode
16+
type ReservedProps = import('vue').ReservedProps
17+
type AllowedComponentProps = import('vue').AllowedComponentProps
18+
type ComponentCustomProps = import('vue').ComponentCustomProps
19+
20+
declare global {
21+
// eslint-disable-next-line @typescript-eslint/no-namespace
22+
namespace JSX {
23+
interface Element extends VNode {}
24+
interface ElementClass {
25+
$props: {}
26+
}
27+
interface ElementAttributesProperty {
28+
$props: {}
29+
}
30+
interface IntrinsicElements extends NativeElements {
31+
[name: string]: any
32+
}
33+
34+
interface IntrinsicAttributes
35+
extends ReservedProps,
36+
AllowedComponentProps,
37+
ComponentCustomProps {}
38+
}
39+
}

0 commit comments

Comments
 (0)