Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog

- **Fixed** Broad workspace globs no longer discover and run package scripts inside `node_modules` ([#539](https://github.com/voidzero-dev/vite-task/pull/539)).
- **Fixed** The task cache now supports much larger automatically tracked input sets without hitting wincode's default 4 MiB sequence preallocation limit ([#554](https://github.com/voidzero-dev/vite-task/pull/554)).
- **Fixed** npm workspace patterns beginning with `./` now discover matching packages correctly ([vite-plus#2201](https://github.com/voidzero-dev/vite-plus/issues/2201), [#547](https://github.com/voidzero-dev/vite-task/pull/547)).
- **Fixed** Failures while forwarding output from a started task process no longer incorrectly say the process failed to spawn ([#506](https://github.com/voidzero-dev/vite-task/issues/506)).
Expand Down
33 changes: 31 additions & 2 deletions crates/vite_workspace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ use vec1::smallvec_v1::SmallVec1;
use vite_glob::path::PathGlobSet;
use vite_path::{AbsolutePath, AbsolutePathBuf, RelativePathBuf};
use vite_str::Str;
use wax::{Glob, walk::Entry as _};
use wax::{
Glob,
walk::{Entry as _, FileIterator as _},
};

pub use crate::{
error::Error,
Expand Down Expand Up @@ -134,7 +137,9 @@ impl WorkspaceMemberGlobs {
// TODO: parallelize this
for inclusion in inclusions {
let glob = Glob::new(&inclusion)?;
for entry in glob.walk(workspace_root.as_path().to_path_buf()) {
for entry in
glob.walk(workspace_root.as_path().to_path_buf()).not("**/node_modules/**")?
Comment thread
jong-kyung marked this conversation as resolved.
{
let Ok(entry) = entry else {
continue;
};
Expand Down Expand Up @@ -594,6 +599,30 @@ mod tests {
assert!(!found_excluded, "Should not have found excluded package");
}

#[test]
fn test_get_package_graph_workspace_ignores_node_modules() {
let temp_dir = TempDir::new().unwrap();
let temp_dir_path = AbsolutePath::new(temp_dir.path()).unwrap();
fs::write(
temp_dir_path.join("package.json"),
r#"{"name":"root","workspaces":["samples/**"]}"#,
)
.unwrap();
fs::create_dir_all(temp_dir_path.join("samples/app/node_modules/dependency")).unwrap();
fs::write(temp_dir_path.join("samples/app/package.json"), r#"{"name":"app"}"#).unwrap();
fs::write(
temp_dir_path.join("samples/app/node_modules/dependency/package.json"),
r#"{"name":"dependency"}"#,
)
.unwrap();

let graph = discover_package_graph(temp_dir_path).unwrap();
let package_names: HashSet<_> =
graph.node_weights().map(|package| package.package_json.name.as_str()).collect();

assert_eq!(package_names, HashSet::from_iter(["root", "app"]));
}

#[test]
fn test_get_package_graph_workspace_work_with_last_match_wins() {
let temp_dir = TempDir::new().unwrap();
Expand Down