@@ -365,8 +365,14 @@ pub fn compiler_args(
365
365
) -> Vec < String > {
366
366
let bsc_flags = config:: flatten_flags ( & config. bsc_flags ) ;
367
367
368
- let dependency_paths =
369
- get_dependency_paths ( config, project_root, workspace_root, packages, build_dev_deps) ;
368
+ let dependency_paths = get_dependency_paths (
369
+ config,
370
+ project_root,
371
+ workspace_root,
372
+ packages,
373
+ build_dev_deps,
374
+ file_path,
375
+ ) ;
370
376
371
377
let module_name = helpers:: file_path_to_module_name ( file_path, & config. get_namespace ( ) ) ;
372
378
@@ -499,12 +505,37 @@ impl DependentPackage {
499
505
}
500
506
}
501
507
508
+ fn is_file_type_dev ( config : & config:: Config , file_path : & Path ) -> bool {
509
+ let Some ( sources) = & config. sources else {
510
+ return false ;
511
+ } ;
512
+ match sources {
513
+ config:: OneOrMore :: Multiple ( multiple) => {
514
+ for source in multiple. iter ( ) {
515
+ match source {
516
+ config:: Source :: Qualified ( config:: PackageSource {
517
+ dir : dir,
518
+ subdirs : _,
519
+ type_ : Some ( type_) ,
520
+ } ) if * type_ == String :: from ( "dev" ) => {
521
+ return Path :: new ( dir) == file_path. parent ( ) . unwrap ( ) ;
522
+ }
523
+ _ => { }
524
+ }
525
+ }
526
+ false
527
+ }
528
+ _ => todo ! ( ) ,
529
+ }
530
+ }
531
+
502
532
fn get_dependency_paths (
503
533
config : & config:: Config ,
504
534
project_root : & Path ,
505
535
workspace_root : & Option < PathBuf > ,
506
536
packages : & Option < & AHashMap < String , packages:: Package > > ,
507
537
build_dev_deps : bool ,
538
+ file_path : & Path ,
508
539
) -> Vec < Vec < String > > {
509
540
let normal_deps = config
510
541
. bs_dependencies
@@ -513,7 +544,10 @@ fn get_dependency_paths(
513
544
. into_iter ( )
514
545
. map ( DependentPackage :: Normal )
515
546
. collect ( ) ;
516
- let dev_deps = if build_dev_deps {
547
+ // We need to check if the current file is listed as type: "dev"
548
+ // Only then it has access of using the bs-dev-dependencies
549
+ let is_file_type_dev = is_file_type_dev ( config, file_path) ;
550
+ let dev_deps = if build_dev_deps && is_file_type_dev {
517
551
config
518
552
. bs_dev_dependencies
519
553
. clone ( )
0 commit comments