@@ -45,6 +45,7 @@ struct Dependency {
45
45
config : config:: Config ,
46
46
path : PathBuf ,
47
47
dependencies : Vec < Dependency > ,
48
+ is_local_dep : bool ,
48
49
}
49
50
50
51
#[ derive( Debug , Clone ) ]
@@ -359,6 +360,10 @@ fn read_dependencies(
359
360
}
360
361
} ;
361
362
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
+ } ;
362
367
363
368
let dependencies = read_dependencies (
364
369
& mut registered_dependencies_set. to_owned ( ) ,
@@ -367,14 +372,15 @@ fn read_dependencies(
367
372
project_root,
368
373
workspace_root,
369
374
show_progress,
370
- build_dev_deps,
375
+ is_local_dep && build_dev_deps,
371
376
) ;
372
377
373
378
Dependency {
374
379
name : package_name. to_owned ( ) ,
375
380
config,
376
381
path : canonical_path,
377
382
dependencies,
383
+ is_local_dep
378
384
}
379
385
} )
380
386
. collect ( )
@@ -405,7 +411,7 @@ pub fn read_package_name(package_dir: &Path) -> Result<String> {
405
411
. ok_or_else ( || anyhow ! ( "No name field found in package.json" ) )
406
412
}
407
413
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 {
409
415
let source_folders = match config. sources . to_owned ( ) {
410
416
Some ( config:: OneOrMore :: Single ( source) ) => get_source_dirs ( source, None ) ,
411
417
Some ( config:: OneOrMore :: Multiple ( sources) ) => {
@@ -444,11 +450,6 @@ This inconsistency will cause issues with package resolution.\n",
444
450
) ;
445
451
}
446
452
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
-
452
453
Package {
453
454
name : package_name,
454
455
config : config. to_owned ( ) ,
@@ -477,7 +478,7 @@ fn read_packages(
477
478
478
479
// Store all packages and completely deduplicate them
479
480
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 ) ;
481
482
map. insert ( root_package. name . to_string ( ) , root_package) ;
482
483
483
484
let mut registered_dependencies_set: AHashSet < String > = AHashSet :: new ( ) ;
@@ -492,7 +493,7 @@ fn read_packages(
492
493
) ) ;
493
494
dependencies. iter ( ) . for_each ( |d| {
494
495
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 ) ;
496
497
map. insert ( d. name . to_string ( ) , package) ;
497
498
}
498
499
} ) ;
0 commit comments