11import { createCheckerByJson } from "vue-component-meta"
22import type { MetaCheckerOptions } from 'vue-component-meta'
3- import { existsSync } from "fs"
3+ import { existsSync , readFileSync } from "fs"
4+ import { joinURL } from "ufo"
45
56export interface Options {
67 rootDir : string
@@ -11,6 +12,18 @@ export interface Options {
1112}
1213
1314export function createMetaChecker ( opts : Options ) {
15+ const baseUrl = joinURL ( opts . rootDir , '.nuxt' ) ;
16+ let paths : Record < string , string [ ] > | undefined = undefined ;
17+ try {
18+ const appTsconfig = JSON . parse ( readFileSync ( joinURL ( baseUrl , 'tsconfig.app.json' ) , 'utf8' ) ) ;
19+ const sharedTsconfig = JSON . parse ( readFileSync ( joinURL ( baseUrl , 'tsconfig.shared.json' ) , 'utf8' ) ) ;
20+ paths = {
21+ ...appTsconfig . compilerOptions . paths ,
22+ ...sharedTsconfig . compilerOptions . paths ,
23+ }
24+ } catch {
25+ // Failed to load tsconfig.app.json or tsconfig.shared.json, ignore
26+ }
1427 return createCheckerByJson (
1528 opts . rootDir ,
1629 {
@@ -22,7 +35,8 @@ export function createMetaChecker(opts: Options) {
2235 ? tryResolveTypesDeclaration ( path )
2336 : `${ path } /**/*`
2437 } ) ,
25- exclude : [ ]
38+ exclude : [ ] ,
39+ ...( paths ? { compilerOptions : { baseUrl, paths } } : { } )
2640 } ,
2741 opts . checkerOptions || {
2842 forceUseTs : true ,
0 commit comments