Преглед на файлове

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

close #10121
Evan You преди 2 години
родител
ревизия
75e866bd4e
променени са 2 файла, в които са добавени 3 реда и са изтрити 1 реда
  1. 1 0
      packages/compiler-sfc/src/compileScript.ts
  2. 2 1
      packages/compiler-sfc/src/script/resolveType.ts

+ 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
   }
 }