turbopack_nodejs/fs.rs
1use std::{
2 ffi::OsStr,
3 path::{Component, Path},
4};
5
6use turbo_tasks_fs::DiskWatcherPathMatcher;
7
8/// Matches anything inside of a `node_modules` directory.
9///
10/// Package managers churn `node_modules` heavily while the dev server is running. More aggressively
11/// batching these may reduce system load during an installation.
12#[turbo_tasks::value(shared)]
13pub struct NodeModulesPathMatcher;
14
15#[turbo_tasks::value_impl]
16impl DiskWatcherPathMatcher for NodeModulesPathMatcher {
17 fn match_path(&self, path: &Path) -> bool {
18 path.components()
19 .any(|component| component == Component::Normal(OsStr::new("node_modules")))
20 }
21}