@@ -67,9 +67,14 @@ impl<Fs: FileSystem> Cache for FsCache<Fs> {
6767 return entry. clone ( ) ;
6868 }
6969 let parent = path. parent ( ) . map ( |p| self . value ( p) ) ;
70+ let is_node_modules = path. file_name ( ) . as_ref ( ) . is_some_and ( |& name| name == "node_modules" ) ;
71+ let inside_node_modules =
72+ is_node_modules || parent. as_ref ( ) . is_some_and ( |parent| parent. inside_node_modules ) ;
7073 let cached_path = FsCachedPath ( Arc :: new ( CachedPathImpl :: new (
7174 hash,
7275 path. to_path_buf ( ) . into_boxed_path ( ) ,
76+ is_node_modules,
77+ inside_node_modules,
7378 parent,
7479 ) ) ) ;
7580 paths. insert ( cached_path. clone ( ) ) ;
@@ -262,18 +267,28 @@ pub struct CachedPathImpl {
262267 hash : u64 ,
263268 path : Box < Path > ,
264269 parent : Option < FsCachedPath > ,
270+ is_node_modules : bool ,
271+ inside_node_modules : bool ,
265272 meta : OnceLock < Option < FileMetadata > > ,
266273 canonicalized : OnceLock < Result < FsCachedPath , ResolveError > > ,
267274 canonicalizing : AtomicU64 ,
268275 package_json : OnceLock < Option < ( FsCachedPath , Arc < PackageJsonSerde > ) > > ,
269276}
270277
271278impl CachedPathImpl {
272- const fn new ( hash : u64 , path : Box < Path > , parent : Option < FsCachedPath > ) -> Self {
279+ fn new (
280+ hash : u64 ,
281+ path : Box < Path > ,
282+ is_node_modules : bool ,
283+ inside_node_modules : bool ,
284+ parent : Option < FsCachedPath > ,
285+ ) -> Self {
273286 Self {
274287 hash,
275288 path,
276289 parent,
290+ is_node_modules,
291+ inside_node_modules,
277292 meta : OnceLock :: new ( ) ,
278293 canonicalized : OnceLock :: new ( ) ,
279294 canonicalizing : AtomicU64 :: new ( 0 ) ,
@@ -303,6 +318,14 @@ impl CachedPath for FsCachedPath {
303318 self . 0 . parent . as_ref ( )
304319 }
305320
321+ fn is_node_modules ( & self ) -> bool {
322+ self . is_node_modules
323+ }
324+
325+ fn inside_node_modules ( & self ) -> bool {
326+ self . inside_node_modules
327+ }
328+
306329 /// Find package.json of a path by traversing parent directories.
307330 ///
308331 /// # Errors
0 commit comments