@@ -198,6 +198,7 @@ impl NodeJsErrorCoded for PackageSubpathResolveError {
198198 PackageSubpathResolveErrorKind :: PkgJsonLoad ( e) => e. code ( ) ,
199199 PackageSubpathResolveErrorKind :: Exports ( e) => e. code ( ) ,
200200 PackageSubpathResolveErrorKind :: LegacyResolve ( e) => e. code ( ) ,
201+ PackageSubpathResolveErrorKind :: FinalizeResolution ( e) => e. code ( ) ,
201202 }
202203 }
203204}
@@ -216,6 +217,9 @@ pub enum PackageSubpathResolveErrorKind {
216217 #[ class( inherit) ]
217218 #[ error( transparent) ]
218219 LegacyResolve ( LegacyResolveError ) ,
220+ #[ class( inherit) ]
221+ #[ error( transparent) ]
222+ FinalizeResolution ( #[ from] FinalizeResolutionError ) ,
219223}
220224
221225#[ derive( Debug , Error , JsError ) ]
@@ -551,16 +555,18 @@ impl NodeJsErrorCoded for FinalizeResolutionError {
551555#[ derive( Debug , Error , JsError ) ]
552556#[ class( generic) ]
553557#[ error(
554- "[{}] Cannot find {} '{}'{}" ,
558+ "[{}] Cannot find {} '{}'{}{} " ,
555559 self . code( ) ,
556560 typ,
557561 specifier,
558- maybe_referrer. as_ref( ) . map( |referrer| format!( " imported from '{}'" , referrer) ) . unwrap_or_default( )
562+ maybe_referrer. as_ref( ) . map( |referrer| format!( " imported from '{}'" , referrer) ) . unwrap_or_default( ) ,
563+ suggested_ext. as_ref( ) . map( |m| format!( "\n Did you mean to import with the \" .{}\" extension?" , m) ) . unwrap_or_default( )
559564) ]
560565pub struct ModuleNotFoundError {
561566 pub specifier : UrlOrPath ,
562567 pub maybe_referrer : Option < UrlOrPath > ,
563568 pub typ : & ' static str ,
569+ pub suggested_ext : Option < & ' static str > ,
564570}
565571
566572impl NodeJsErrorCoded for ModuleNotFoundError {
@@ -572,14 +578,16 @@ impl NodeJsErrorCoded for ModuleNotFoundError {
572578#[ derive( Debug , Error , JsError ) ]
573579#[ class( generic) ]
574580#[ error(
575- "[{}] Directory import '{}' is not supported resolving ES modules{}" ,
581+ "[{}] Directory import '{}' is not supported resolving ES modules{}{} " ,
576582 self . code( ) ,
577583 dir_url,
578584 maybe_referrer. as_ref( ) . map( |referrer| format!( " imported from '{}'" , referrer) ) . unwrap_or_default( ) ,
585+ suggested_file_name. map( |file_name| format!( "\n Did you mean to import {file_name} within the directory?" ) ) . unwrap_or_default( ) ,
579586) ]
580587pub struct UnsupportedDirImportError {
581588 pub dir_url : UrlOrPath ,
582589 pub maybe_referrer : Option < UrlOrPath > ,
590+ pub suggested_file_name : Option < & ' static str > ,
583591}
584592
585593impl NodeJsErrorCoded for UnsupportedDirImportError {
0 commit comments