Skip to content

Commit c24d3c7

Browse files
committed
feat(vue-jsx-vapor): support vue sfc
1 parent cea15e8 commit c24d3c7

File tree

8 files changed

+147
-275
lines changed

8 files changed

+147
-275
lines changed

packages/vue-jsx-vapor/src/core/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@ export function transformVueJsxVapor(
1212
options?: Options,
1313
needSourceMap = false,
1414
) {
15+
const params = new URLSearchParams(id)
16+
const vapor = params.get('vapor')
1517
return transformSync(code, {
1618
plugins: [
17-
[jsx, { compile: options?.compile, interop: options?.interop }],
19+
[
20+
jsx,
21+
{
22+
compile: options?.compile,
23+
interop: vapor ? false : options?.interop,
24+
},
25+
],
1826
...(id.endsWith('.tsx')
1927
? [[babelTypescript, { isTSX: true, allowExtensions: true }]]
2028
: []),

playground/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"build": "node vite.js build"
99
},
1010
"devDependencies": {
11+
"@vitejs/plugin-vue": "^6.0.0",
12+
"@vue-macros/define-render": "catalog:",
1113
"vite": "catalog:",
1214
"vite-hyper-config": "^0.7.0",
1315
"vite-node": "^3.2.4",

playground/src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineVaporComponent, ref, type Ref } from 'vue'
22
import { useRef } from 'vue-jsx-vapor'
3+
import VueComp from './Comp.vue'
34
import Count2 from './count'
45
import For from './for'
56
import Html from './html'
@@ -25,7 +26,7 @@ export default defineVaporComponent(() => {
2526
return (
2627
<>
2728
<fieldset>
28-
<legend>Component</legend>
29+
<VueComp />
2930
<input
3031
value_prop={count.value}
3132
onInput={(e) => (count.value = e.currentTarget.value)}

playground/src/Comp.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<script vapor lang="tsx">
2+
defineRender(<legend>Component</legend>)
3+
</script>

playground/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"module": "ESNext",
99
"moduleResolution": "bundler",
1010
"resolveJsonModule": true,
11-
"types": ["vite/client"],
11+
"types": ["vite/client", "@vue-macros/define-render/macros-global.d.ts"],
1212
"strict": true,
1313
"strictNullChecks": true,
1414
"esModuleInterop": true

playground/vite.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1+
import Vue from '@vitejs/plugin-vue'
2+
import DefineRender from '@vue-macros/define-render/vite'
13
import { defineConfig } from 'vite'
24
import Inspect from 'vite-plugin-inspect'
35
import VueJsxVapor from 'vue-jsx-vapor/vite'
46

57
export default defineConfig({
68
plugins: [
9+
Vue(),
710
VueJsxVapor({
11+
// interop: true,
812
macros: true,
913
}),
14+
DefineRender({
15+
vapor: true,
16+
}),
1017
Inspect(),
1118
],
1219
})

0 commit comments

Comments
 (0)