fix: missing dependencies after import

This commit is contained in:
zernonia 2023-11-06 12:12:54 +08:00
parent 3e74fe7de6
commit 4657fe8ccc
9 changed files with 46 additions and 22 deletions

View File

@ -615,22 +615,22 @@ export const Index = {
name: 'ActivityGoal',
type: 'components:example',
registryDependencies: ['button', 'card', 'themes', 'config'],
component: () => import('../src/lib/registry/default/example/Cards/ActivityGoal.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/Cards/ActivityGoal.vue'],
component: () => import('../src/lib/registry/default/example/ActivityGoal.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/ActivityGoal.vue'],
},
DataTable: {
name: 'DataTable',
type: 'components:example',
registryDependencies: ['button', 'checkbox', 'dropdown-menu', 'input', 'table', 'card', 'utils'],
component: () => import('../src/lib/registry/default/example/Cards/DataTable.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/Cards/DataTable.vue'],
component: () => import('../src/lib/registry/default/example/DataTable.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/DataTable.vue'],
},
Metric: {
name: 'Metric',
type: 'components:example',
registryDependencies: ['card', 'config'],
component: () => import('../src/lib/registry/default/example/Cards/Metric.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/Cards/Metric.vue'],
component: () => import('../src/lib/registry/default/example/Metric.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/Metric.vue'],
},
},
'new-york': {
@ -1247,22 +1247,22 @@ export const Index = {
name: 'ActivityGoal',
type: 'components:example',
registryDependencies: ['button', 'card', 'themes', 'config'],
component: () => import('../src/lib/registry/new-york/example/Cards/ActivityGoal.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/Cards/ActivityGoal.vue'],
component: () => import('../src/lib/registry/new-york/example/ActivityGoal.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/ActivityGoal.vue'],
},
DataTable: {
name: 'DataTable',
type: 'components:example',
registryDependencies: ['button', 'checkbox', 'dropdown-menu', 'input', 'table', 'card', 'utils'],
component: () => import('../src/lib/registry/new-york/example/Cards/DataTable.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/Cards/DataTable.vue'],
component: () => import('../src/lib/registry/new-york/example/DataTable.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/DataTable.vue'],
},
Metric: {
name: 'Metric',
type: 'components:example',
registryDependencies: ['card', 'config'],
component: () => import('../src/lib/registry/new-york/example/Cards/Metric.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/Cards/Metric.vue'],
component: () => import('../src/lib/registry/new-york/example/Metric.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/Metric.vue'],
},
},
}

View File

@ -6,10 +6,15 @@ import type { Registry } from '../../lib/registry'
const DEPENDENCIES = new Map<string, string[]>([
['radix-vue', []],
['@vueuse/core', []],
['v-calendar', []],
['@tanstack/vue-table', []],
['vee-validate', ['@vee-validate/zod', 'zod']],
])
// Some dependencies latest tag were not compatible with Vue3.
const DEPENDENCIES_WITH_TAGS = new Map<string, string>([
['v-calendar', 'v-calendar@next'],
])
const REGISTRY_DEPENDENCY = '@/'
type ArrayItem<T> = T extends Array<infer X> ? X : never
@ -139,7 +144,11 @@ async function getDependencies(filename: string) {
Object.values(compiled.imports!).forEach((value) => {
const source = value.source
const peerDeps = DEPENDENCIES.get(source)
const taggedDeps = DEPENDENCIES_WITH_TAGS.get(source)
if (peerDeps !== undefined) {
if (taggedDeps !== undefined)
dependencies.add(taggedDeps)
else
dependencies.add(source)
peerDeps.forEach(dep => dependencies.add(dep))
}

View File

@ -108,7 +108,8 @@
{
"name": "calendar",
"dependencies": [
"v-calendar"
"@vueuse/core",
"v-calendar@next"
],
"registryDependencies": [
"utils"
@ -302,7 +303,9 @@
},
{
"name": "input",
"dependencies": [],
"dependencies": [
"@vueuse/core"
],
"registryDependencies": [
"utils"
],
@ -590,7 +593,9 @@
},
{
"name": "textarea",
"dependencies": [],
"dependencies": [
"@vueuse/core"
],
"registryDependencies": [
"utils"
],

View File

@ -1,7 +1,8 @@
{
"name": "calendar",
"dependencies": [
"v-calendar"
"@vueuse/core",
"v-calendar@next"
],
"registryDependencies": [
"utils"

View File

@ -1,6 +1,8 @@
{
"name": "input",
"dependencies": [],
"dependencies": [
"@vueuse/core"
],
"registryDependencies": [
"utils"
],

View File

@ -1,6 +1,8 @@
{
"name": "textarea",
"dependencies": [],
"dependencies": [
"@vueuse/core"
],
"registryDependencies": [
"utils"
],

View File

@ -1,7 +1,8 @@
{
"name": "calendar",
"dependencies": [
"v-calendar"
"@vueuse/core",
"v-calendar@next"
],
"registryDependencies": [
"utils"

View File

@ -1,6 +1,8 @@
{
"name": "input",
"dependencies": [],
"dependencies": [
"@vueuse/core"
],
"registryDependencies": [
"utils"
],

View File

@ -1,6 +1,8 @@
{
"name": "textarea",
"dependencies": [],
"dependencies": [
"@vueuse/core"
],
"registryDependencies": [
"utils"
],