@@ -2,11 +2,11 @@ mod error;
22pub mod package;
33mod package_manager;
44
5- use std:: { collections:: hash_map:: Entry , fs, io} ;
5+ use std:: { collections:: hash_map:: Entry , fs, io, sync :: Arc } ;
66
77use petgraph:: graph:: { DefaultIx , DiGraph , EdgeIndex , IndexType , NodeIndex } ;
88use rustc_hash:: { FxHashMap as HashMap , FxHashSet as HashSet } ;
9- use serde:: { Deserialize , Serialize } ;
9+ use serde:: Deserialize ;
1010use vec1:: smallvec_v1:: SmallVec1 ;
1111use vite_glob:: GlobPatternSet ;
1212use vite_path:: { AbsolutePath , AbsolutePathBuf , RelativePathBuf } ;
@@ -111,7 +111,12 @@ struct PackageGraphBuilder {
111111}
112112
113113impl 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