Explorar el Código

fix(compiler-sfc): fix type resolution for symlinked node_modules structure w/ pnpm

close #10121
Evan You hace 2 años
padre
commit
75e866bd4e

+ 1 - 0
packages/compiler-sfc/src/compileScript.ts

@@ -118,6 +118,7 @@ export interface SFCScriptCompileOptions {
   fs?: {
     fileExists(file: string): boolean
     readFile(file: string): string | undefined
+    realpath?(file: string): string
   }
   /**
    * Transform Vue SFCs into custom elements.

+ 2 - 1
packages/compiler-sfc/src/script/resolveType.ts

@@ -860,6 +860,7 @@ function resolveFS(ctx: TypeResolveContext): FS | undefined {
       }
       return fs.readFile(file)
     },
+    realpath: fs.realpath,
   })
 }
 
@@ -1048,7 +1049,7 @@ function resolveWithTS(
     if (filename.endsWith('.vue.ts')) {
       filename = filename.replace(/\.ts$/, '')
     }
-    return filename
+    return fs.realpath ? fs.realpath(filename) : filename
   }
 }