Skip to content

Commit ae5ae18

Browse files
Tahulatinux
andauthored
feat(unplugin): move parsing steps to unplugin (#43)
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
1 parent d4c0ae3 commit ae5ae18

26 files changed

+9220
-7965
lines changed

.github/workflows/ci.yml

+12-7
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ jobs:
1919
- uses: actions/setup-node@v3
2020
with:
2121
node-version: '16'
22-
cache: yarn
23-
- run: yarn install
24-
- run: yarn dev:prepare
25-
- run: yarn lint
26-
- run: yarn prepack
27-
- run: yarn dev:generate
28-
- run: yarn test
22+
- uses: pnpm/action-setup@v2.2.2
23+
name: Install pnpm
24+
id: pnpm-install
25+
with:
26+
version: 7
27+
run_install: false
28+
- run: pnpm install
29+
- run: pnpm dev:prepare
30+
- run: pnpm lint
31+
- run: pnpm prepack
32+
- run: pnpm dev:generate
33+
- run: pnpm test

.gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ node_modules
99
.tmp
1010
.cache
1111

12-
# Yarn
13-
**/.yarn/cache
14-
**/.yarn/*state*
15-
1612
# Generated dirs
1713
dist
1814

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shamefully-hoist=true

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
1. Add `nuxt-component-meta` dependency to your project:
1010

1111
```bash
12-
# Using Yarn
13-
yarn add --dev nuxt-component-meta
12+
# Using PNPM
13+
pnpm add -D nuxt-component-meta
14+
1415
# Using NPM
1516
npm install --save-dev nuxt-component-meta
1617
```
@@ -43,5 +44,5 @@ const { data: meta } = await useAsyncData('my-component', () => $fetch('/api/com
4344
## Development
4445

4546
1. Clone this repository
46-
2. Install dependencies using `yarn install`
47-
3. Start dev server using `yarn dev`
47+
2. Install dependencies using `pnpm install`
48+
3. Start dev server using `pnpm dev`

package.json

+27-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuxt-component-meta",
3-
"version": "0.2.3",
3+
"version": "0.3.2",
44
"license": "MIT",
55
"type": "module",
66
"exports": {
@@ -19,25 +19,43 @@
1919
"dev": "nuxi dev playground",
2020
"dev:build": "nuxi build playground",
2121
"dev:generate": "nuxi generate playground",
22-
"dev:prepare": "nuxt-module-build --stub && yarn install --cwd ./playground && nuxi prepare playground",
22+
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
2323
"lint": "eslint --ext .js,.ts,.vue .",
2424
"test": "vitest",
25-
"release": "yarn test && standard-version && git push --follow-tags && npm publish"
25+
"release": "pnpm test && standard-version && git push --follow-tags && npm publish"
2626
},
2727
"dependencies": {
28-
"@nuxt/kit": "^3.0.0-rc.10",
28+
"@nuxt/kit": "^3.0.0-rc.12",
2929
"scule": "^0.3.2",
30-
"vue-component-meta": "^0.40.13"
30+
"vue-component-meta": "^1.0.8"
3131
},
3232
"devDependencies": {
3333
"@iconify/vue": "^4.0.0",
34+
"@nuxt/content": "^2.1.1",
3435
"@nuxt/module-builder": "latest",
35-
"@nuxt/test-utils": "^3.0.0-rc.10",
36+
"@nuxt/test-utils": "^3.0.0-rc.12",
3637
"@nuxtjs/eslint-config-typescript": "latest",
37-
"@nuxt/content": "npm:@nuxt/content-edge@latest",
3838
"eslint": "latest",
39-
"nuxt": "^3.0.0-rc.10",
39+
"nuxt": "^3.0.0-rc.12",
4040
"standard-version": "^9.5.0",
41-
"vitest": "^0.23.4"
41+
"typescript": "^4.8.4",
42+
"vitest": "^0.24.3",
43+
"vue": "^3.2.41"
44+
},
45+
"build": {
46+
"externals": [
47+
"#nuxt-component-meta",
48+
"ufo",
49+
"pathe",
50+
"defu",
51+
"unplugin"
52+
]
53+
},
54+
"pnpm": {
55+
"peerDependencyRules": {
56+
"ignoreMissing": [
57+
"postcss*"
58+
]
59+
}
4260
}
4361
}

playground/app.vue

+25-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
<template>
22
<div>
3-
<h2>Components from <code>/api/component-meta</code> nitro route</h2>
4-
<pre>{{ data }}</pre>
5-
<hr />
6-
<h2>Components from <code>#nuxt-component-meta</code> virtual module</h2>
7-
<pre>{{ components }}</pre>
3+
<div>
4+
<TestComponent foo="test" />
5+
<TestGlobalComponent />
6+
<TestTyped :hello="`test`" />
7+
</div>
8+
9+
<h2>Components from <code>useComponentMeta('{{ specificComponentName }}')</code></h2>
10+
11+
<pre>{{ specificComponentMeta }}</pre>
12+
13+
<h2>Components from <code>useComponentMeta</code></h2>
14+
15+
<pre>{{ composableData }}</pre>
16+
17+
<hr>
818
</div>
919
</template>
1020

11-
<script setup>
12-
import components from '#nuxt-component-meta'
13-
const { data } = await useAsyncData('metas', () => $fetch('/api/component-meta'))
21+
<script lang="ts" setup>
22+
import TestComponent from './components/TestComponent.vue'
23+
import TestTyped from './components/testTyped.vue'
24+
import { NuxtComponentMetaNames } from '#nuxt-component-meta/types'
25+
26+
const specificComponentName = ref<NuxtComponentMetaNames>('TestComponent')
27+
28+
const specificComponentMeta = await useComponentMeta(specificComponentName)
29+
30+
const composableData = await useComponentMeta()
1431
</script>

playground/components/TestComponent.vue

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
<template>
22
<div>
3-
<slot />
43
<hr>
4+
TestComponent
5+
<hr>
6+
<slot />
57
<slot name="nuxt" />
68
</div>
79
</template>
810

911
<script setup>
1012
defineProps({
13+
/**
14+
* The foo property.
15+
*
16+
* @since v1.0.0
17+
*/
1118
foo: {
1219
type: String,
13-
required: true
20+
default: 'Hello'
1421
},
1522
/**
1623
* The hello property.
@@ -30,5 +37,6 @@ defineProps({
3037
default: 1.3
3138
}
3239
})
40+
3341
const emit = defineEmits(['change', 'delete'])
3442
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div>
3+
<ContentSlot :use="$slots.default" />
4+
</div>
5+
</template>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
<template>
2-
<div>I am global</div>
2+
<div>
3+
<hr>
4+
I am global
5+
<hr>
6+
</div>
37
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<template>
2+
<div :class="$pinceau">
3+
Hello World!
4+
</div>
5+
</template>
6+
7+
<script setup lang="ts">
8+
defineProps({
9+
...$variantsProps
10+
})
11+
</script>
12+
13+
<style scoped lang="ts">
14+
css({
15+
variants: {
16+
background: {
17+
red: {
18+
background: 'red',
19+
},
20+
blue: {
21+
background: 'blue',
22+
}
23+
}
24+
}
25+
})
26+
</style>

playground/components/testTyped.vue

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
22
<div>
3+
<hr>
4+
TestTyped
5+
<hr>
36
<slot />
47
<hr>
58
<slot name="nuxt" />

playground/nuxt.config.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,23 @@ export default defineNuxtConfig({
55
dirs: [
66
{
77
path: '~/components/global',
8+
prefix: '',
9+
global: true
10+
},
11+
{
12+
path: '~/components/pinceau',
13+
prefix: '',
814
global: true
915
},
1016
'~/components'
1117
]
1218
},
1319
modules: [
1420
'@nuxt/content',
21+
'pinceau/nuxt',
1522
nuxtMetaModule
16-
]
23+
],
24+
pinceau: {
25+
followSymbolicLinks: false
26+
}
1727
})

playground/package.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"private": true,
3+
"name": "nuxt-component-meta-playground",
4+
"devDependencies": {
5+
"@nuxt/content": "npm:@nuxt/content-edge@latest",
6+
"nuxt": "^3.0.0-rc.12",
7+
"nuxt-component-meta": "*",
8+
"pinceau": "latest"
9+
},
10+
"scripts": {
11+
"dev": "nuxi dev",
12+
"build": "nuxi build",
13+
"generate": "nuxi generate"
14+
}
15+
}

playground/pinceau.config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { defineTheme } from 'pinceau'
2+
3+
export default defineTheme({})

0 commit comments

Comments
 (0)