Skip to content

Commit 07fc7cf

Browse files
committed
fix(workspace): ignore packages inside node_modules
1 parent 89fd4a2 commit 07fc7cf

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Changelog
22

3+
- **Fixed** Broad workspace globs no longer discover and run package scripts inside `node_modules` ([#???](https://github.com/voidzero-dev/vite-task/pull/???)).
34
- **Improved** Windows file-access tracking now uses sparse temporary backing files where supported, avoiding upfront allocation of the full backing file on disk ([#524](https://github.com/voidzero-dev/vite-task/pull/524)).
45
- **Fixed** Automatic file-access tracking on Linux now works in containers and Kubernetes runners with limited `/dev/shm` space ([#353](https://github.com/voidzero-dev/vite-task/issues/353), [#523](https://github.com/voidzero-dev/vite-task/pull/523)).
56
- **Fixed** Windows automatic input tracking now records executable image reads when process creation performs the lookup inside `NtCreateUserProcess` ([#518](https://github.com/voidzero-dev/vite-task/pull/518)).

crates/vite_workspace/src/lib.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ use vec1::smallvec_v1::SmallVec1;
1313
use vite_glob::path::PathGlobSet;
1414
use vite_path::{AbsolutePath, AbsolutePathBuf, RelativePathBuf};
1515
use vite_str::Str;
16-
use wax::{Glob, walk::Entry as _};
16+
use wax::{
17+
Glob,
18+
walk::{Entry as _, FileIterator as _},
19+
};
1720

1821
pub use crate::{
1922
error::Error,
@@ -112,7 +115,9 @@ impl WorkspaceMemberGlobs {
112115
// TODO: parallelize this
113116
for inclusion in inclusions {
114117
let glob = Glob::new(&inclusion)?;
115-
for entry in glob.walk(workspace_root.as_path().to_path_buf()) {
118+
for entry in
119+
glob.walk(workspace_root.as_path().to_path_buf()).not("**/node_modules/**")?
120+
{
116121
let Ok(entry) = entry else {
117122
continue;
118123
};
@@ -572,6 +577,30 @@ mod tests {
572577
assert!(!found_excluded, "Should not have found excluded package");
573578
}
574579

580+
#[test]
581+
fn test_get_package_graph_workspace_ignores_node_modules() {
582+
let temp_dir = TempDir::new().unwrap();
583+
let temp_dir_path = AbsolutePath::new(temp_dir.path()).unwrap();
584+
fs::write(
585+
temp_dir_path.join("package.json"),
586+
r#"{"name":"root","workspaces":["samples/**"]}"#,
587+
)
588+
.unwrap();
589+
fs::create_dir_all(temp_dir_path.join("samples/app/node_modules/dependency")).unwrap();
590+
fs::write(temp_dir_path.join("samples/app/package.json"), r#"{"name":"app"}"#).unwrap();
591+
fs::write(
592+
temp_dir_path.join("samples/app/node_modules/dependency/package.json"),
593+
r#"{"name":"dependency"}"#,
594+
)
595+
.unwrap();
596+
597+
let graph = discover_package_graph(temp_dir_path).unwrap();
598+
let package_names: HashSet<_> =
599+
graph.node_weights().map(|package| package.package_json.name.as_str()).collect();
600+
601+
assert_eq!(package_names, HashSet::from_iter(["root", "app"]));
602+
}
603+
575604
#[test]
576605
fn test_get_package_graph_workspace_work_with_last_match_wins() {
577606
let temp_dir = TempDir::new().unwrap();

0 commit comments

Comments
 (0)