Skip to content

Commit 26afc8c

Browse files
committed
feat: support functional component in interop mode
1 parent 9e51df0 commit 26afc8c

File tree

5 files changed

+195
-187
lines changed

5 files changed

+195
-187
lines changed

docs/introduction/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ We assume you are already familiar with the basic usages of Vue before you conti
2525
pnpm add vue-jsx-vapor
2626

2727
# runtime
28-
pnpm add https://pkg.pr.new/vue@9e2eea9
28+
pnpm add https://pkg.pr.new/vue@715b798
2929
```
3030

3131
The Vue Vapor runtime is not release, so we use [pkg.pr.new](https://github.com/stackblitz-labs/pkg.pr.new) to install.

packages/babel/src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,20 @@ export default (): {
9595
statements.unshift(preambleResult)
9696
}
9797

98-
const helpers = ['setNodes', 'createNodes'].filter((helper) => {
98+
const helpers = [
99+
'setNodes',
100+
'createNodes',
101+
state.opts.interop ? 'createComponent' : '',
102+
].filter((helper) => {
99103
const result = importSet.has(helper)
100104
result && importSet.delete(helper)
101105
return result
102106
})
103107
if (helpers.length) {
104108
statements.unshift(
105-
`import { ${helpers.map((i) => `${i} as _${i}`).join(', ')} } from 'vue-jsx-vapor/runtime';\n`,
109+
`import { ${helpers
110+
.map((i) => `${i} as _${i}`)
111+
.join(', ')} } from 'vue-jsx-vapor/runtime';\n`,
106112
)
107113
}
108114

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ import {
1616

1717
export { shallowRef as useRef } from 'vue'
1818

19+
export const createComponent: typeof _createComponent = (...args) => {
20+
typeof args[0] === 'function' && (args[0].__vapor = true)
21+
return _createComponent(...args)
22+
}
23+
1924
/**
2025
* Returns the props of the current component instance.
2126
*

0 commit comments

Comments
 (0)