Skip to content

Commit de332fb

Browse files
committed
chore: update docs
1 parent a809954 commit de332fb

File tree

4 files changed

+19
-96
lines changed

4 files changed

+19
-96
lines changed

README.md

Lines changed: 13 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -2,102 +2,27 @@
22

33
[![NPM version](https://img.shields.io/npm/v/vue-jsx-vapor?color=a1b858&label=)](https://www.npmjs.com/package/vue-jsx-vapor)
44

5-
Vue JSX Vapor.
5+
Vapor Mode of Vue JSX.
66

7-
[Docs](https://jsx-vapor.netlify.app/) . [Playground](https://repl.zmjs.dev/vuejs/vue-jsx-vapor)
7+
## Features
88

9-
## Install
9+
- ⚡️ High Performance: It has the same performance as Vue Vapor!
10+
- ⚒️ Directives: Support all build-in directives of Vue.
11+
- ✨ Macros: Support most macros of Vue, Friendly to JSX.
12+
- 🌈 Hot Module Replacement: Support functional components or defined by defineComponent.
13+
- 🦾 Type Safe: Provide Volar plugin support by install TS Macro (VSCode plugin).
14+
- ⚙️ ESLint: Provide an ESLint plugin for vue-jsx-vapor to automatically fix code.
15+
16+
## Installation
1017

1118
```bash
1219
npm i vue-jsx-vapor
1320
```
1421

15-
> [!CAUTION]
16-
> ❌ The destructuring of props in a functional component will cause loss of reactivity.
17-
18-
```tsx
19-
function Comp({ foo }) {
20-
return <div>{foo}</div>
21-
}
22-
23-
export default () => {
24-
const foo = ref('foo')
25-
return <Comp foo={foo.value} />
26-
}
27-
```
28-
29-
#### Two Solutions
30-
31-
1. ✅ Pass a ref variable as prop:
32-
33-
```tsx
34-
function Comp({ foo }) {
35-
return <div>{foo.value}</div>
36-
}
37-
38-
export default () => {
39-
const foo = ref('foo')
40-
return <Comp foo={foo} />
41-
}
42-
```
43-
44-
2. ✅ Set the macros option to true, then use the `defineComponent` macro for wrapping.
45-
46-
Setup
47-
48-
```ts
49-
// vite.config.ts
50-
import vueJsxVapor from 'vue-jsx-vapor/vite'
51-
52-
export default defineConfig({
53-
plugins: [
54-
vueJsxVapor({
55-
macros: true,
56-
}),
57-
]
58-
})
59-
60-
```
61-
62-
Usage
63-
64-
```tsx
65-
const Comp = defineComponent(({ foo }) => {
66-
return <>{foo}</>
67-
})
68-
// Will be convert to:
69-
const Comp = defineComponent((_props) => {
70-
return <>{_props.foo}</>
71-
}, { props: ['foo'] })
72-
73-
export default () => {
74-
const foo = ref('foo')
75-
return <Comp foo={foo.value} />
76-
}
77-
```
78-
79-
## Typescript
80-
81-
Because of vue-jsx-vapor support all directives and most macros of Vue,\
82-
so we need the VSCode plugin [ts-macro](https://github.com/ts-macro/ts-macro) to use the `vue-jsx-vapor/volar` plugin for Typescript support.\
83-
It works similarly to [@vue/language-tools](https://github.com/vuejs/language-tools) but only used for `ts` or `tsx` files.
84-
85-
By default, after installing the `ts-macro` VSCode plugin, `ts-macro` will automatically load `vue-jsx-vapor/volar` by analyzing `vite.config.ts` and shared vueJsxVapor's options. so you don't need to config `tsm.config.ts`. But if you want, you can also configure it manually:
86-
87-
```ts
88-
// tsm.config.ts
89-
import vueJsxVapor from 'vue-jsx-vapor/volar'
90-
91-
export default {
92-
plugins: [
93-
vueJsxVapor({
94-
macros: true,
95-
}),
96-
],
97-
}
98-
99-
```
22+
## Usage
10023

24+
- [📜 Documentation]((https://jsx-vapor.netlify.app/))
25+
- [🛰️ Playground](https://repl.zmjs.dev/vuejs/vue-jsx-vapor)
10126

10227
<details>
10328
<summary>Vite</summary><br>

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ features:
2626
details: Support most macros of Vue, Friendly to JSX.
2727
- icon: 🦾
2828
title: Type Safe
29-
details: Provide Volar support by install TS Macro (VSCode plugin).
29+
details: Provide Volar plugin support by install TS Macro (VSCode plugin).
3030
- icon: ⚡️
3131
title: High Performance
32-
details: It has the same performance with Vue Vapor!
32+
details: It has the same performance as Vue Vapor!
3333
- icon: 🌈
3434
title: Hot Module Replacement
3535
details: Support functional components or defined by defineComponent.

docs/introduction/getting-started.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ export default defineConfig({
5151

5252
## Typescript
5353

54-
Because of `vue-jsx-vapor` support all directives and most macros of Vue, so we need the VSCode plugin [ts-macro](https://github.com/ts-macro/ts-macro) to use the `vue-jsx-vapor/volar` plugin for Typescript support.\
55-
It works similarly to [@vue/language-tools](https://github.com/vuejs/language-tools) but only used for `ts` or `tsx` files.
54+
Due to `vue-jsx-vapor`'s support for all Vue directives and most Vue macros, the [ts-macro](https://github.com/ts-macro/ts-macro) VSCode plugin is required to enable TypeScript support when using the `vue-jsx-vapor/volar` plugin.
5655

57-
By default, after installing the `ts-macro` VSCode plugin, `ts-macro` will automatically load `vue-jsx-vapor/volar` by analyzing `vite.config.ts` and shared vueJsxVapor's options. so you don't need to config `tsm.config.ts`. But if you want, you can also configure it manually:
56+
After installing the `ts-macro` VSCode plugin, it automatically loads `vue-jsx-vapor/volar` by analyzing vite.config.ts and shared vueJsxVapor options, eliminating the need to configure tsm.config.ts.
5857

5958
::: code-group
6059

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import {
2-
effectScope,
2+
EffectScope,
33
insert,
44
isFragment,
55
isVaporComponent,
66
remove,
77
renderEffect,
88
VaporFragment,
99
type Block,
10-
type EffectScope,
1110
} from 'vue'
1211

1312
export { shallowRef as useRef } from 'vue'
@@ -80,7 +79,7 @@ function resolveValues(values: any[] = [], _anchor?: Element) {
8079
if (typeof value === 'function') {
8180
renderEffect(() => {
8281
if (scopes[index]) scopes[index].stop()
83-
scopes[index] = effectScope()
82+
scopes[index] = new EffectScope()
8483
nodes[index] = scopes[index].run(() =>
8584
resolveValue(nodes[index], value(), anchor),
8685
)!

0 commit comments

Comments
 (0)