|
1 | 1 | import { createCheckerByJson } from "vue-component-meta" |
2 | 2 | import type { ComponentMeta } from 'vue-component-meta' |
3 | | -import { refineMeta } from "./utils" |
| 3 | +import { refineMeta, tryResolveTypesDeclaration } from "./utils" |
4 | 4 | import { isAbsolute, join } from "pathe" |
5 | 5 | import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs' |
6 | 6 | import { withBase } from "ufo" |
@@ -57,26 +57,7 @@ export function getComponentMeta(component: string, options?: Options): Componen |
57 | 57 | * @returns component meta |
58 | 58 | */ |
59 | 59 | function _getComponentMeta(fullPath: string, opts: Options) { |
60 | | - // Check if the component is in node_modules and adjust configuration accordingly |
61 | | - const isNodeModule = fullPath.includes('node_modules') |
62 | | - |
63 | | - // For node_modules components, try to find the TypeScript declaration file first |
64 | | - let resolvedPath = fullPath |
65 | | - if (isNodeModule && fullPath.endsWith('.vue')) { |
66 | | - // Try different TypeScript declaration file patterns |
67 | | - const patterns = [ |
68 | | - fullPath.replace('.vue', '.d.vue.ts'), |
69 | | - fullPath.replace('.vue', '.vue.d.ts'), |
70 | | - fullPath.replace('.vue', '.d.ts') |
71 | | - ] |
72 | | - |
73 | | - for (const pattern of patterns) { |
74 | | - if (existsSync(pattern)) { |
75 | | - resolvedPath = pattern |
76 | | - break |
77 | | - } |
78 | | - } |
79 | | - } |
| 60 | + let resolvedPath = tryResolveTypesDeclaration(fullPath) |
80 | 61 |
|
81 | 62 | const checker = createCheckerByJson( |
82 | 63 | opts.rootDir, |
|
0 commit comments