Skip to content

Commit 228c397

Browse files
feat: add sources option to allow loading external component definition (#60)
1 parent 0a285c7 commit 228c397

File tree

16 files changed

+1983
-5631
lines changed

16 files changed

+1983
-5631
lines changed

bin/nuxt-component-meta.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env node
2+
3+
import { runGenerate } from '../dist/cli.mjs'
4+
5+
runGenerate()

package.json

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"version": "0.5.4",
44
"license": "MIT",
55
"type": "module",
6+
"bin": {
7+
"nuxt-component-meta": "./bin/nuxt-component-meta.mjs"
8+
},
69
"exports": {
710
".": {
811
"import": "./dist/module.mjs",
@@ -15,7 +18,7 @@
1518
"dist"
1619
],
1720
"scripts": {
18-
"prepack": "nuxt-module-build",
21+
"prepack": "nuxt-module-build build",
1922
"dev": "nuxi dev playground",
2023
"dev:build": "nuxi build playground",
2124
"dev:generate": "nuxi generate playground",
@@ -26,29 +29,34 @@
2629
},
2730
"dependencies": {
2831
"@nuxt/kit": "^3.8.0",
32+
"citty": "^0.1.4",
2933
"scule": "^1.0.0",
3034
"typescript": "^5.2.2",
3135
"vue-component-meta": "^1.8.22"
3236
},
3337
"devDependencies": {
3438
"@iconify/vue": "^4.1.1",
3539
"@nuxt/content": "^2.9.0",
36-
"@nuxt/module-builder": "latest",
37-
"@nuxt/test-utils": "^3.8.0",
38-
"@nuxtjs/eslint-config-typescript": "latest",
40+
"@nuxt/module-builder": "^0.5.4",
41+
"@nuxt/test-utils": "^3.8.1",
42+
"@nuxtjs/eslint-config-typescript": "^12.1.0",
3943
"changelogen": "^0.5.5",
40-
"eslint": "latest",
44+
"eslint": "^8.53.0",
4145
"jiti": "^1.21.0",
42-
"nuxt": "^3.8.0",
46+
"nuxt": "^3.8.1",
4347
"release-it": "^16.2.1",
4448
"vitest": "^0.34.6",
45-
"vue": "^3.3.7"
49+
"vue": "^3.3.8"
4650
},
4751
"build": {
4852
"entries": [
4953
{
5054
"input": "./src/parser.ts",
5155
"name": "parser"
56+
},
57+
{
58+
"input": "./src/cli/index.ts",
59+
"name": "cli"
5260
}
5361
],
5462
"externals": [
@@ -57,7 +65,11 @@
5765
"pathe",
5866
"defu",
5967
"unplugin",
60-
"consola"
68+
"consola",
69+
"mlly",
70+
"acorn",
71+
"pkg-types",
72+
"jsonc-parser"
6173
]
6274
},
6375
"pnpm": {

playground/app.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<script lang="ts" setup>
2222
import TestComponent from './components/TestComponent.vue'
2323
import TestTyped from './components/testTyped.vue'
24-
import { NuxtComponentMetaNames } from '#nuxt-component-meta/types'
24+
import type { NuxtComponentMetaNames } from '#nuxt-component-meta/types'
2525
2626
const specificComponentName = ref<NuxtComponentMetaNames>('TestContent')
2727

playground/nuxt.config.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,27 @@ export default defineNuxtConfig({
2525

2626
componentMeta: {
2727
debug: 2,
28-
exclude: [/test/i, (component: any) => {
29-
return component.global
30-
}]
28+
exclude: [/node_modules/i],
29+
metaSources: [
30+
{
31+
TestExternalMeta: {
32+
pascalName: 'TestExternalMeta',
33+
kebabName: 'test-external-meta',
34+
chunkName: 'components/test-external-meta',
35+
export: 'default',
36+
priority: 1,
37+
prefetch: false,
38+
preload: false,
39+
meta: {
40+
type: 0,
41+
props: [],
42+
slots: [],
43+
events: [],
44+
exposed: []
45+
}
46+
}
47+
}
48+
]
3149
},
3250

3351
pinceau: {

0 commit comments

Comments
 (0)