@@ -136,6 +136,8 @@ pub enum WorkspaceDiagnosticKind {
136
136
MissingExports ,
137
137
#[ error( "\" importMap\" field is ignored when \" imports\" or \" scopes\" are specified in the config file." ) ]
138
138
ImportMapReferencingImportMap ,
139
+ #[ error( "\" imports\" and \" scopes\" field is ignored when \" importMap\" is specified in the root config file." ) ]
140
+ MemberImportsScopesIgnored ,
139
141
#[ error( "Patching npm packages ({package_json_url}) is not implemented." ) ]
140
142
NpmPatchNotImplemented { package_json_url : Url } ,
141
143
#[ error( "`\" nodeModulesDir\" : {previous}` is deprecated in Deno 2.0. Use `\" nodeModulesDir\" : \" {suggestion}\" ` instead" ) ]
@@ -630,13 +632,27 @@ impl Workspace {
630
632
pub fn diagnostics ( & self ) -> Vec < WorkspaceDiagnostic > {
631
633
fn check_member_diagnostics (
632
634
member_config : & ConfigFile ,
635
+ root_config : Option < & ConfigFile > ,
633
636
diagnostics : & mut Vec < WorkspaceDiagnostic > ,
634
637
) {
635
638
if member_config. json . import_map . is_some ( ) {
636
639
diagnostics. push ( WorkspaceDiagnostic {
637
640
config_url : member_config. specifier . clone ( ) ,
638
641
kind : WorkspaceDiagnosticKind :: RootOnlyOption ( "importMap" ) ,
639
642
} ) ;
643
+ } else if member_config. is_an_import_map ( )
644
+ && root_config
645
+ . map ( |c| {
646
+ c. json . import_map . is_some ( )
647
+ && c. json . imports . is_none ( )
648
+ && c. json . scopes . is_none ( )
649
+ } )
650
+ . unwrap_or ( false )
651
+ {
652
+ diagnostics. push ( WorkspaceDiagnostic {
653
+ config_url : member_config. specifier . clone ( ) ,
654
+ kind : WorkspaceDiagnosticKind :: MemberImportsScopesIgnored ,
655
+ } ) ;
640
656
}
641
657
if member_config. json . lock . is_some ( ) {
642
658
diagnostics. push ( WorkspaceDiagnostic {
@@ -746,7 +762,11 @@ impl Workspace {
746
762
if let Some ( config) = & folder. deno_json {
747
763
let is_root = url == & self . root_dir ;
748
764
if !is_root {
749
- check_member_diagnostics ( config, & mut diagnostics) ;
765
+ check_member_diagnostics (
766
+ config,
767
+ self . root_deno_json ( ) . map ( |r| r. as_ref ( ) ) ,
768
+ & mut diagnostics,
769
+ ) ;
750
770
}
751
771
752
772
check_all_configs ( config, & mut diagnostics) ;
@@ -2750,6 +2770,28 @@ pub mod test {
2750
2770
) ;
2751
2771
}
2752
2772
2773
+ #[ test]
2774
+ fn test_root_import_map_with_member_imports_and_scopes ( ) {
2775
+ let workspace_dir = workspace_for_root_and_member (
2776
+ json ! ( {
2777
+ "importMap" : "./other.json"
2778
+ } ) ,
2779
+ json ! ( {
2780
+ "imports" : {
2781
+ "@scope/pkg" : "jsr:@scope/pkg@3"
2782
+ }
2783
+ } ) ,
2784
+ ) ;
2785
+ assert_eq ! (
2786
+ workspace_dir. workspace. diagnostics( ) ,
2787
+ vec![ WorkspaceDiagnostic {
2788
+ kind: WorkspaceDiagnosticKind :: MemberImportsScopesIgnored ,
2789
+ config_url: Url :: from_file_path( root_dir( ) . join( "member/deno.json" ) )
2790
+ . unwrap( ) ,
2791
+ } ]
2792
+ ) ;
2793
+ }
2794
+
2753
2795
#[ test]
2754
2796
fn test_root_member_exclude ( ) {
2755
2797
let workspace_dir = workspace_for_root_and_member (
0 commit comments