@@ -136,6 +136,7 @@ export class ProjectDirManager {
136136 private tsc : typeof ts
137137 private tmplGroup : TmplGroup
138138 private readonly rootPath : string
139+ private appJsonData : ComponentJsonData | null = null
139140 private trackingComponents = Object . create ( null ) as Record < string , ComponentJsonData >
140141 private convertedExpr = Object . create ( null ) as Record < string , ConvertedExprCache >
141142 private pendingAsyncTasks = 0
@@ -170,6 +171,7 @@ export class ProjectDirManager {
170171 this . vfs . onTrackedFileRemoved = ( fullPath ) => {
171172 this . handleFileRemoved ( fullPath )
172173 }
174+ this . appJsonData = this . readComponentJsonData ( this . appPath ( ) )
173175 }
174176
175177 stop ( ) {
@@ -182,8 +184,15 @@ export class ProjectDirManager {
182184 return this . pendingAsyncTasks
183185 }
184186
187+ private appPath ( ) {
188+ return path . join ( this . rootPath , 'app' )
189+ }
190+
185191 private handleFileOpened ( fullPath : string ) {
186192 const compPath = possibleComponentPath ( fullPath )
193+ if ( compPath === this . appPath ( ) ) {
194+ return
195+ }
187196 if ( isTsFile ( fullPath ) ) {
188197 this . onScriptFileAdded ( fullPath )
189198 }
@@ -206,6 +215,13 @@ export class ProjectDirManager {
206215
207216 private handleFileUpdated ( fullPath : string ) {
208217 const compPath = possibleComponentPath ( fullPath )
218+ if ( compPath === this . appPath ( ) ) {
219+ this . appJsonData = this . readComponentJsonData ( compPath )
220+ Object . keys ( this . trackingComponents ) . forEach ( ( p ) => {
221+ this . checkConvertedExprCache ( `${ p } .wxml` )
222+ } )
223+ return
224+ }
209225 if ( compPath !== null ) {
210226 if ( isJsonFile ( fullPath ) ) {
211227 const isComp = ! ! this . trackingComponents [ compPath ]
@@ -233,6 +249,13 @@ export class ProjectDirManager {
233249
234250 private handleFileRemoved ( fullPath : string ) {
235251 const compPath = possibleComponentPath ( fullPath )
252+ if ( compPath === this . appPath ( ) ) {
253+ this . appJsonData = null
254+ Object . keys ( this . trackingComponents ) . forEach ( ( p ) => {
255+ this . checkConvertedExprCache ( `${ p } .wxml` )
256+ } )
257+ return
258+ }
236259 if ( isTsFile ( fullPath ) ) {
237260 this . onScriptFileRemoved ( fullPath )
238261 }
@@ -408,10 +431,6 @@ export class ProjectDirManager {
408431 private updateComponentJsonData ( fullPath : string ) : string | null {
409432 const compPath = possibleComponentPath ( fullPath )
410433 if ( compPath === null ) return null
411- const version = this . getFileVersion ( `${ compPath } .json` )
412- if ( version !== null && version === this . trackingComponents [ compPath ] ?. jsonFileVersion ) {
413- return compPath
414- }
415434 const compJson = this . readComponentJsonData ( compPath )
416435 if ( compJson !== null ) {
417436 this . trackingComponents [ compPath ] = compJson
@@ -432,10 +451,13 @@ export class ProjectDirManager {
432451 }
433452
434453 getUsingComponents ( compPath : string ) : Record < string , string > {
435- const comp = this . trackingComponents [ compPath ]
454+ const comp = this . trackingComponents [ compPath ] ?. usingComponents ?? { }
455+ const app = this . appJsonData ?. usingComponents ?? { }
436456 // eslint-disable-next-line @typescript-eslint/no-unsafe-return
437- if ( ! comp ) return Object . create ( null )
438- return comp . usingComponents
457+ return {
458+ ...app ,
459+ ...comp ,
460+ }
439461 }
440462
441463 getGenerics ( compPath : string ) : string [ ] {
0 commit comments