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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "test-workspace",
"private": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "self-dep",
"version": "1.0.0",
"dependencies": {
"self-dep": "workspace:*"
},
"scripts": {
"build": "echo building"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- 'packages/*'
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Tests that a package with a self-referential workspace dependency (e.g. for
# testing purposes) does not produce a false cycle-dependency error.

[[plan]]
name = "build in self-referential package"
args = ["run", "build"]
cwd = "packages/self-dep"
compact = true

[[plan]]
name = "recursive build across workspace"
args = ["run", "-r", "build"]
compact = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
expression: "&compact_plan"
info:
args:
- run
- build
cwd: packages/self-dep
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/package-self-dependency
---
{
"packages/self-dep#build": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
expression: "&compact_plan"
info:
args:
- run
- "-r"
- build
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/package-self-dependency
---
{
"packages/self-dep#build": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
expression: task_graph_json
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/package-self-dependency
---
[
{
"key": [
"<workspace>/packages/self-dep",
"build"
],
"node": {
"task_display": {
"package_name": "self-dep",
"task_name": "build",
"package_path": "<workspace>/packages/self-dep"
},
"resolved_config": {
"command": "echo building",
"resolved_options": {
"cwd": "<workspace>/packages/self-dep",
"cache_config": {
"env_config": {
"fingerprinted_envs": [],
"untracked_env": [
"<default untracked envs>"
]
},
"input_config": {
"includes_auto": true,
"positive_globs": [],
"negative_globs": []
}
}
}
},
"source": "PackageJsonScript"
},
"neighbors": []
}
]
6 changes: 5 additions & 1 deletion crates/vite_workspace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ impl PackageGraphBuilder {
path2: dep_path2.clone(),
});
}
self.graph.add_edge(*id, *dep_id, *dep_type);
// Skip self-referential edges: a package listing itself as a dependency
// (e.g. for testing purposes) must not create a cycle in the task graph.
if *id != *dep_id {
self.graph.add_edge(*id, *dep_id, *dep_type);
}
}
// Silently skip if dependency not found - it might be an external package
}
Expand Down
Loading