Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 3ea6e42

Browse files
committed
docs: update docs about ref sugar
1 parent 5e60710 commit 3ea6e42

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

README.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import ScriptSetup from 'unplugin-vue2-script-setup/vite'
3232
export default defineConfig({
3333
plugins: [
3434
Vue2(),
35-
ScriptSetup(),
35+
ScriptSetup({ /* options */ }),
3636
],
3737
})
3838
```
@@ -104,7 +104,7 @@ And then use [`vue-tsc`](https://github.com/johnsoncodehk/volar) to do the type
104104
module.exports = {
105105
configureWebpack: {
106106
plugins: [
107-
require('unplugin-vue2-script-setup/webpack')(),
107+
require('unplugin-vue2-script-setup/webpack')({ /* options */ }),
108108
],
109109
},
110110
}
@@ -124,7 +124,7 @@ npm i -D @vue/cli-plugin-typescript vue-tsc
124124
module.exports = {
125125
configureWebpack: {
126126
plugins: [
127-
require('unplugin-vue2-script-setup/webpack')(),
127+
require('unplugin-vue2-script-setup/webpack')({ /* options */ }),
128128
],
129129
},
130130
chainWebpack(config) {
@@ -156,7 +156,7 @@ And then use [`vue-tsc`](https://github.com/johnsoncodehk/volar) to do the type
156156
module.exports = {
157157
/* ... */
158158
plugins: [
159-
require('unplugin-vue2-script-setup/webpack')()
159+
require('unplugin-vue2-script-setup/webpack')({ /* options */ }),
160160
]
161161
}
162162
```
@@ -231,6 +231,38 @@ If the global types are missing for your IDE, update your `tsconfig.json` with:
231231

232232
If you are using ESLint, you might get `@typescript-eslint/no-unused-vars` warning with `<script setup>`. You can disable it and add `noUnusedLocals: true` in your `tsconfig.json`, Volar will infer the real missing locals correctly for you.
233233

234+
## Configurations
235+
236+
<details>
237+
<summary>
238+
Ref Sugar (take 2)
239+
</summary>
240+
241+
In v0.5.x, we shipped the **experimental** [Ref Sugar (take 2)](https://github.com/vuejs/rfcs/discussions/369) implementation based on Vue 3's [`@vue/ref-transform`](https://github.com/vuejs/vue-next/tree/master/packages/ref-transform) package. **Use at your own risk!**
242+
243+
To enabled it, pass the option:
244+
245+
```ts
246+
ScriptSetup({
247+
refTransform: true
248+
})
249+
```
250+
251+
To get TypeScript support, update your `tsconfig.json` with:
252+
253+
```jsonc
254+
{
255+
"compilerOptions": {
256+
"types": [
257+
"unplugin-vue2-script-setup/types",
258+
"unplugin-vue2-script-setup/ref-macros"
259+
]
260+
}
261+
}
262+
```
263+
264+
</details>
265+
234266
## Recommendations
235267

236268
If you enjoy using `<script setup>`, you might also want to try [`unplugin-auto-import`](https://github.com/antfu/unplugin-auto-import) to improve the DX even further.
@@ -242,6 +274,7 @@ If you enjoy using `<script setup>`, you might also want to try [`unplugin-auto-
242274
- [x] Compile time macros `defineProps` `defineEmits` `withDefaults`
243275
- [x] Global types
244276
- [x] Merge with normal scripts
277+
- [x] [Ref Sugar (take 2)](https://github.com/vuejs/rfcs/discussions/369)
245278
- [x] Vite plugin
246279
- [x] Webpack plugin
247280
- [x] Nuxt module

0 commit comments

Comments
 (0)