@@ -38,6 +38,57 @@ export async function load(tsconfig: string, languages: string[]) {
38
38
plugins . push ( vueLanguagePlugin ) ;
39
39
}
40
40
41
+ if ( languages . includes ( 'vue-vine' ) ) {
42
+ let vue : typeof import ( '@vue/language-core' ) ;
43
+ let vueVine : typeof import ( '@vue-vine/language-service' ) ;
44
+ let pkgPath : string | undefined ;
45
+
46
+ if ( pkgPath = findPackageJson ( '@vue-vine/language-service' ) ) {
47
+ const pkgDir = path . dirname ( pkgPath ) ;
48
+ vueVine = require ( '@vue-vine/language-service' ) ;
49
+ vue = require ( require . resolve ( '@vue/language-core' , { paths : [ pkgDir ] } ) ) ;
50
+ } else if ( pkgPath = findPackageJson ( 'vue-vine-tsc' ) ) {
51
+ const pkgDir = path . dirname ( pkgPath ) ;
52
+ vue = require ( require . resolve ( '@vue/language-core' , { paths : [ pkgDir ] } ) ) ;
53
+ vueVine = require ( require . resolve ( '@vue/language-core' , { paths : [ pkgDir ] } ) ) ;
54
+ } else {
55
+ const pkg = ts . findConfigFile ( path . dirname ( tsconfig ) , ts . sys . fileExists , 'package.json' ) ;
56
+ if ( pkg ) {
57
+ throw new Error ( 'Please install @vue-vine/language-service or vue-vine-tsc to ' + path . relative ( process . cwd ( ) , pkg ) ) ;
58
+ } else {
59
+ throw new Error ( 'Please install @vue-vine/language-service or vue-vine-tsc for ' + path . relative ( process . cwd ( ) , tsconfig ) ) ;
60
+ }
61
+ }
62
+
63
+ const commonLine = vue . createParsedCommandLine ( ts , ts . sys , tsconfig , true ) ;
64
+ const globalTypesFilePath = vueVine . setupGlobalTypes ( path . dirname ( tsconfig ) , commonLine . vueOptions as any , ts . sys ) ;
65
+ if ( globalTypesFilePath ) {
66
+ commonLine . vueOptions . __setupedGlobalTypes = {
67
+ absolutePath : globalTypesFilePath ,
68
+ } ;
69
+ }
70
+
71
+ plugins . push (
72
+ vue . createVueLanguagePlugin < string > (
73
+ ts ,
74
+ commonLine . options ,
75
+ commonLine . vueOptions ,
76
+ id => id
77
+ )
78
+ ) ;
79
+
80
+ plugins . push (
81
+ vueVine . createVueVineLanguagePlugin (
82
+ ts ,
83
+ {
84
+ compilerOptions : commonLine . options ,
85
+ vueCompilerOptions : commonLine . vueOptions as any ,
86
+ target : 'tsc' ,
87
+ }
88
+ )
89
+ ) ;
90
+ }
91
+
41
92
if ( languages . includes ( 'mdx' ) ) {
42
93
let mdx : any ;
43
94
@@ -78,8 +129,6 @@ export async function load(tsconfig: string, languages: string[]) {
78
129
return plugins ;
79
130
80
131
function findPackageJson ( pkgName : string ) {
81
- try {
82
- return require . resolve ( `${ pkgName } /package.json` , { paths : [ path . dirname ( tsconfig ) ] } ) ;
83
- } catch { }
132
+ return ts . findConfigFile ( path . dirname ( tsconfig ) , ts . sys . fileExists , `node_modules/${ pkgName } /package.json` ) ;
84
133
}
85
134
}
0 commit comments