@@ -45,6 +45,7 @@ struct Dependency {
4545 config : config:: Config ,
4646 path : PathBuf ,
4747 dependencies : Vec < Dependency > ,
48+ is_local_dep : bool ,
4849}
4950
5051#[ derive( Debug , Clone ) ]
@@ -359,6 +360,10 @@ fn read_dependencies(
359360 }
360361 } ;
361362
363+ let is_local_dep = {
364+ canonical_path. starts_with ( project_root)
365+ && !canonical_path. components ( ) . any ( |c| c. as_os_str ( ) == "node_modules" )
366+ } ;
362367
363368 let dependencies = read_dependencies (
364369 & mut registered_dependencies_set. to_owned ( ) ,
@@ -367,14 +372,15 @@ fn read_dependencies(
367372 project_root,
368373 workspace_root,
369374 show_progress,
370- build_dev_deps,
375+ is_local_dep && build_dev_deps,
371376 ) ;
372377
373378 Dependency {
374379 name : package_name. to_owned ( ) ,
375380 config,
376381 path : canonical_path,
377382 dependencies,
383+ is_local_dep
378384 }
379385 } )
380386 . collect ( )
@@ -405,7 +411,7 @@ pub fn read_package_name(package_dir: &Path) -> Result<String> {
405411 . ok_or_else ( || anyhow ! ( "No name field found in package.json" ) )
406412}
407413
408- fn make_package ( config : config:: Config , package_path : & Path , is_root : bool , project_root : & Path ) -> Package {
414+ fn make_package ( config : config:: Config , package_path : & Path , is_root : bool , is_local_dep : bool ) -> Package {
409415 let source_folders = match config. sources . to_owned ( ) {
410416 Some ( config:: OneOrMore :: Single ( source) ) => get_source_dirs ( source, None ) ,
411417 Some ( config:: OneOrMore :: Multiple ( sources) ) => {
@@ -444,11 +450,6 @@ This inconsistency will cause issues with package resolution.\n",
444450 ) ;
445451 }
446452
447- let is_local_dep = {
448- package_path. starts_with ( project_root)
449- && !package_path. components ( ) . any ( |c| c. as_os_str ( ) == "node_modules" )
450- } ;
451-
452453 Package {
453454 name : package_name,
454455 config : config. to_owned ( ) ,
@@ -477,7 +478,7 @@ fn read_packages(
477478
478479 // Store all packages and completely deduplicate them
479480 let mut map: AHashMap < String , Package > = AHashMap :: new ( ) ;
480- let root_package = make_package ( root_config. to_owned ( ) , project_root, true , project_root ) ;
481+ let root_package = make_package ( root_config. to_owned ( ) , project_root, true , true ) ;
481482 map. insert ( root_package. name . to_string ( ) , root_package) ;
482483
483484 let mut registered_dependencies_set: AHashSet < String > = AHashSet :: new ( ) ;
@@ -492,7 +493,7 @@ fn read_packages(
492493 ) ) ;
493494 dependencies. iter ( ) . for_each ( |d| {
494495 if !map. contains_key ( & d. name ) {
495- let package = make_package ( d. config . to_owned ( ) , & d. path , false , project_root ) ;
496+ let package = make_package ( d. config . to_owned ( ) , & d. path , false , d . is_local_dep ) ;
496497 map. insert ( d. name . to_string ( ) , package) ;
497498 }
498499 } ) ;
0 commit comments