Skip to content

Commit d88fe67

Browse files
authored
feat(better-define): init (#126)
* wip: init api * rename * update * wip: emits * feat: supports extends * feat: resolve TS * test: add mixed * fix: circular-referencing * add docs * refactor * refactor: improve * feat: intersection * feat(better-define): init * feat: support intersection * fix: lockfile * fix: TSDeclaration * fix: inline template * feat: withDefaults * feat: emits * fix: ordering * chore: update comments * add changesets * add docs
1 parent 977dbe6 commit d88fe67

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4176
-24
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@vue-macros/common': minor
3+
'unplugin-vue-macros': minor
4+
'@vue-macros/api': patch
5+
'@vue-macros/better-define': patch
6+
'@vue-macros/hoist-static': patch
7+
'@vue-macros/short-emits': patch
8+
---
9+
10+
add better define

docs/.vitepress/configs/navs.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export const sidebar: DefaultTheme.Sidebar = [
6868
text: 'namedTemplate',
6969
link: '/features/named-template',
7070
},
71+
{
72+
text: 'betterDefine',
73+
link: '/features/better-define',
74+
},
7175
],
7276
},
7377
]

docs/features/better-define.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# betterDefine
2+
3+
With enabling `betterDefine`, imported types is supported in `<script setup>` type-based-macros.
4+
5+
[Related issue](https://github.com/vuejs/core/issues/4294)
6+
7+
| Features | Supported |
8+
| :----------------: | :----------------: |
9+
| Vue 3 | :white_check_mark: |
10+
| Vue 2 | :white_check_mark: |
11+
| TypeScript / Volar | :white_check_mark: |
12+
13+
## Basic Usage
14+
15+
:::: code-group
16+
17+
::: code-group-item App.vue
18+
19+
```vue
20+
<script setup lang="ts">
21+
import type { BaseProps } from './types'
22+
23+
interface Props extends BaseProps {
24+
foo: string
25+
}
26+
defineProps<Props>()
27+
</script>
28+
```
29+
30+
:::
31+
32+
::: code-group-item types.ts
33+
34+
```ts
35+
export interface BaseProps {
36+
title: string
37+
}
38+
```
39+
40+
:::
41+
42+
::::

docs/guide/getting-started.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ module.exports = {
131131
```ts
132132
VueMacros({
133133
root: '/your-project-path',
134+
134135
/**
135136
* Vue version, 2 or 3.
136137
*
@@ -152,6 +153,11 @@ VueMacros({
152153
*/
153154
unified: true,
154155
},
156+
157+
// Disable features
158+
hoistStatic: false,
159+
160+
// ... more features
155161
})
156162
```
157163

packages/api/package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "@vue-macros/api",
3+
"version": "0.0.0",
4+
"packageManager": "pnpm@7.13.5",
5+
"license": "MIT",
6+
"homepage": "https://github.com/sxzz/unplugin-vue-macros#readme",
7+
"bugs": {
8+
"url": "https://github.com/sxzz/unplugin-vue-macros/issues"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/sxzz/unplugin-vue-macros.git"
13+
},
14+
"author": "三咲智子 <sxzz@sxzz.moe>",
15+
"files": [
16+
"dist"
17+
],
18+
"main": "./dist/index.js",
19+
"module": "./dist/index.mjs",
20+
"types": "./dist/index.d.ts",
21+
"exports": {
22+
".": {
23+
"require": "./dist/index.js",
24+
"import": "./dist/index.mjs"
25+
},
26+
"./*": "./*"
27+
},
28+
"scripts": {
29+
"build": "tsup && tsx ../../scripts/postbuild.mts",
30+
"dev": "DEV=1 tsup"
31+
},
32+
"dependencies": {
33+
"@babel/types": "^7.19.4",
34+
"@vue-macros/common": "workspace:~"
35+
},
36+
"devDependencies": {},
37+
"engines": {
38+
"node": ">=14.19.0"
39+
}
40+
}

packages/api/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export { MagicString } from '@vue-macros/common'
2+
3+
export * from './vue'
4+
export * from './ts'
5+
export * from './utils'

0 commit comments

Comments
 (0)