@@ -172,6 +172,20 @@ export abstract class NodeModulesCollector<ProdDepType extends Dependency<ProdDe
172172 return this . cache . realPath . get ( filePath ) !
173173 }
174174
175+ protected requireMemoized ( pkgPath : string ) : PackageJson {
176+ if ( ! this . cache . packageJson . has ( pkgPath ) ) {
177+ this . cache . packageJson . set ( pkgPath , require ( pkgPath ) )
178+ }
179+ return this . cache . packageJson . get ( pkgPath ) !
180+ }
181+
182+ protected existsSyncMemoized ( filePath : string ) : boolean {
183+ if ( ! this . cache . exists . has ( filePath ) ) {
184+ this . cache . exists . set ( filePath , fs . existsSync ( filePath ) )
185+ }
186+ return this . cache . exists . get ( filePath ) !
187+ }
188+
175189 protected async resolvePath ( filePath : string ) : Promise < string > {
176190 // Check if we've already resolved this path
177191 if ( this . cache . realPath . has ( filePath ) ) {
@@ -254,20 +268,6 @@ export abstract class NodeModulesCollector<ProdDepType extends Dependency<ProdDe
254268 return null
255269 }
256270
257- protected requireMemoized ( pkgPath : string ) : PackageJson {
258- if ( ! this . cache . packageJson . has ( pkgPath ) ) {
259- this . cache . packageJson . set ( pkgPath , require ( pkgPath ) )
260- }
261- return this . cache . packageJson . get ( pkgPath ) !
262- }
263-
264- protected existsSyncMemoized ( filePath : string ) : boolean {
265- if ( ! this . cache . exists . has ( filePath ) ) {
266- this . cache . exists . set ( filePath , fs . existsSync ( filePath ) )
267- }
268- return this . cache . exists . get ( filePath ) !
269- }
270-
271271 protected cacheKey ( pkg : ProdDepType ) : string {
272272 const rel = path . relative ( this . rootDir , pkg . path )
273273 return `${ pkg . name } ::${ pkg . version } ::${ rel ?? "." } `
0 commit comments