Skip to content

Commit

Permalink
feat(better-define): init (#126)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sxzz committed Oct 27, 2022
1 parent 977dbe6 commit d88fe67
Show file tree
Hide file tree
Showing 55 changed files with 4,176 additions and 24 deletions.
10 changes: 10 additions & 0 deletions .changeset/gorgeous-monkeys-talk.md
@@ -0,0 +1,10 @@
---
'@vue-macros/common': minor
'unplugin-vue-macros': minor
'@vue-macros/api': patch
'@vue-macros/better-define': patch
'@vue-macros/hoist-static': patch
'@vue-macros/short-emits': patch
---

add better define
4 changes: 4 additions & 0 deletions docs/.vitepress/configs/navs.ts
Expand Up @@ -68,6 +68,10 @@ export const sidebar: DefaultTheme.Sidebar = [
text: 'namedTemplate',
link: '/features/named-template',
},
{
text: 'betterDefine',
link: '/features/better-define',
},
],
},
]
42 changes: 42 additions & 0 deletions docs/features/better-define.md
@@ -0,0 +1,42 @@
# betterDefine

With enabling `betterDefine`, imported types is supported in `<script setup>` type-based-macros.

[Related issue](https://github.com/vuejs/core/issues/4294)

| Features | Supported |
| :----------------: | :----------------: |
| Vue 3 | :white_check_mark: |
| Vue 2 | :white_check_mark: |
| TypeScript / Volar | :white_check_mark: |

## Basic Usage

:::: code-group

::: code-group-item App.vue

```vue
<script setup lang="ts">
import type { BaseProps } from './types'
interface Props extends BaseProps {
foo: string
}
defineProps<Props>()
</script>
```

:::

::: code-group-item types.ts

```ts
export interface BaseProps {
title: string
}
```

:::

::::
6 changes: 6 additions & 0 deletions docs/guide/getting-started.md
Expand Up @@ -131,6 +131,7 @@ module.exports = {
```ts
VueMacros({
root: '/your-project-path',

/**
* Vue version, 2 or 3.
*
Expand All @@ -152,6 +153,11 @@ VueMacros({
*/
unified: true,
},

// Disable features
hoistStatic: false,

// ... more features
})
```

Expand Down
40 changes: 40 additions & 0 deletions packages/api/package.json
@@ -0,0 +1,40 @@
{
"name": "@vue-macros/api",
"version": "0.0.0",
"packageManager": "pnpm@7.13.5",
"license": "MIT",
"homepage": "https://github.com/sxzz/unplugin-vue-macros#readme",
"bugs": {
"url": "https://github.com/sxzz/unplugin-vue-macros/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sxzz/unplugin-vue-macros.git"
},
"author": "三咲智子 <sxzz@sxzz.moe>",
"files": [
"dist"
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./*": "./*"
},
"scripts": {
"build": "tsup && tsx ../../scripts/postbuild.mts",
"dev": "DEV=1 tsup"
},
"dependencies": {
"@babel/types": "^7.19.4",
"@vue-macros/common": "workspace:~"
},
"devDependencies": {},
"engines": {
"node": ">=14.19.0"
}
}
5 changes: 5 additions & 0 deletions packages/api/src/index.ts
@@ -0,0 +1,5 @@
export { MagicString } from '@vue-macros/common'

export * from './vue'
export * from './ts'
export * from './utils'

0 comments on commit d88fe67

Please sign in to comment.