Skip to content

Commit 477f6d7

Browse files
committed
resolve conflict
1 parent 2801ddc commit 477f6d7

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

crates/vite_task_graph/tests/snapshots.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clap::Parser;
55
use copy_dir::copy_dir;
66
use petgraph::visit::EdgeRef as _;
77
use tokio::runtime::Runtime;
8-
use vite_path::{AbsolutePath, RelativePathBuf, relative};
8+
use vite_path::{AbsolutePath, RelativePathBuf};
99
use vite_str::Str;
1010
use vite_task_graph::{
1111
IndexedTaskGraph, SpecifierLookupError, TaskDependencyType, TaskNodeIndex,

crates/vite_workspace/src/lib.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ mod error;
22
pub mod package;
33
mod package_manager;
44

5-
use std::{collections::hash_map::Entry, fs, io};
5+
use std::{collections::hash_map::Entry, fs, io, sync::Arc};
66

77
use petgraph::graph::{DefaultIx, DiGraph, EdgeIndex, IndexType, NodeIndex};
88
use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet};
9-
use serde::{Deserialize, Serialize};
9+
use serde::Deserialize;
1010
use vec1::smallvec_v1::SmallVec1;
1111
use vite_glob::GlobPatternSet;
1212
use vite_path::{AbsolutePath, AbsolutePathBuf, RelativePathBuf};
@@ -111,7 +111,12 @@ struct PackageGraphBuilder {
111111
}
112112

113113
impl PackageGraphBuilder {
114-
fn add_package(&mut self, package_path: RelativePathBuf, package_json: PackageJson) {
114+
fn add_package(
115+
&mut self,
116+
package_path: RelativePathBuf,
117+
absolute_path: Arc<AbsolutePath>,
118+
package_json: PackageJson,
119+
) {
115120
let deps = package_json.get_workspace_dependencies().collect::<Vec<_>>();
116121
let package_name = package_json.name.clone();
117122
let id = self.graph.add_node(PackageInfo {
@@ -208,7 +213,11 @@ pub fn load_package_graph(
208213
WorkspaceFile::NonWorkspacePackage(file) => {
209214
// For non-workspace packages, add the package.json to the graph as a root package
210215
let package_json: PackageJson = serde_json::from_reader(file)?;
211-
graph_builder.add_package(RelativePathBuf::default(), package_json);
216+
graph_builder.add_package(
217+
RelativePathBuf::default(),
218+
workspace_root.path.into(),
219+
package_json,
220+
);
212221

213222
return graph_builder.build();
214223
}
@@ -227,15 +236,19 @@ pub fn load_package_graph(
227236
};
228237

229238
has_root_package = has_root_package || package_path.as_str().is_empty();
230-
graph_builder.add_package(package_path, package_json);
239+
graph_builder.add_package(package_path, absolute_path.into(), package_json);
231240
}
232241
// try add the root package anyway if the member globs do not include it.
233242
if !has_root_package {
234243
let package_json_path = workspace_root.path.join("package.json");
235244
match fs::read(&package_json_path) {
236245
Ok(package_json) => {
237246
let package_json: PackageJson = serde_json::from_slice(&package_json)?;
238-
graph_builder.add_package(RelativePathBuf::default(), package_json);
247+
graph_builder.add_package(
248+
RelativePathBuf::default(),
249+
workspace_root.path.into(),
250+
package_json,
251+
);
239252
}
240253
Err(err) => {
241254
if err.kind() != io::ErrorKind::NotFound {

0 commit comments

Comments
 (0)