Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions crates/pack-api/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ pub struct WatchOptions {
/// Enable polling at a certain interval if the native file watching doesn't work (e.g.
/// docker).
pub poll_interval: Option<Duration>,

/// Paths to ignore when watching for file changes.
/// By default, ignores: node_modules
#[serde(default = "default_ignored_paths")]
pub ignored: Vec<RcStr>,
}

pub fn default_ignored_paths() -> Vec<RcStr> {
vec!["node_modules".into()]
}

#[turbo_tasks::value]
Expand Down Expand Up @@ -588,16 +597,20 @@ impl Project {
}
}

if denied_paths.is_empty() {
// Get watched ignored paths from configuration
let watched_ignored = self.watch.ignored.clone();

if denied_paths.is_empty() && watched_ignored.is_empty() {
Ok(DiskFileSystem::new(
PROJECT_FILESYSTEM_NAME.into(),
self.root_path.clone(),
))
} else {
Ok(DiskFileSystem::new_with_denied_paths(
Ok(DiskFileSystem::new_with_watched_ignored(
PROJECT_FILESYSTEM_NAME.into(),
self.root_path.clone(),
denied_paths,
watched_ignored,
))
}
}
Expand Down
8 changes: 8 additions & 0 deletions crates/pack-napi/src/pack_api/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ pub struct NapiWatchOptions {
/// Enable polling at a certain interval if the native file watching doesn't work (e.g.
/// docker).
pub poll_interval_ms: Option<f64>,

/// Paths to ignore when watching for file changes.
/// By default, ignores: node_modules
pub ignored: Option<Vec<String>>,
}

#[napi(object)]
Expand Down Expand Up @@ -178,6 +182,10 @@ impl From<NapiWatchOptions> for WatchOptions {
.poll_interval_ms
.filter(|interval| !interval.is_nan() && interval.is_finite() && *interval > 0.0)
.map(|interval| Duration::from_secs_f64(interval / 1000.0)),
ignored: val
.ignored
.map(|v| v.into_iter().map(|s| s.into()).collect())
.unwrap_or_else(pack_api::project::default_ignored_paths),
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions crates/pack-schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ pub struct SchemaWatchOptions {
/// Enable polling at a certain interval if the native file watching doesn't work (e.g. docker).
#[serde(skip_serializing_if = "Option::is_none")]
pub poll_interval: Option<u64>,

/// Paths to ignore when watching for file changes.
/// By default, ignores: node_modules
#[serde(skip_serializing_if = "Option::is_none")]
pub ignored: Option<Vec<String>>,
}

/// Environment variables for build-time injection
Expand Down
5 changes: 5 additions & 0 deletions packages/pack/src/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ export interface NapiWatchOptions {
* docker).
*/
pollIntervalMs?: number
/**
* Paths to ignore when watching for file changes.
* By default, ignores: node_modules
*/
ignored?: Array<string>
}
export interface NapiProjectOptions {
/**
Expand Down
Loading