@@ -1392,7 +1392,7 @@ pub struct JsonModule {
13921392}
13931393
13941394impl JsonModule {
1395- /// Return the size in bytes of the content of the JSON module.
1395+ /// Return the size in bytes of the content of the module.
13961396 pub fn size ( & self ) -> usize {
13971397 self . source . text . len ( )
13981398 }
@@ -1888,6 +1888,7 @@ impl<'a, 'options> ModuleEntryIterator<'a, 'options> {
18881888 MediaType :: Css
18891889 | MediaType :: SourceMap
18901890 | MediaType :: Html
1891+ | MediaType :: Markdown
18911892 | MediaType :: Sql
18921893 | MediaType :: Jsonc
18931894 | MediaType :: Json5
@@ -2951,6 +2952,19 @@ pub(crate) async fn parse_module_source_and_info(
29512952 ) ;
29522953 }
29532954
2955+ if let Some ( attribute_type) = opts. maybe_attribute_type
2956+ && !matches ! ( attribute_type. kind. as_str( ) , "json" | "text" | "bytes" )
2957+ {
2958+ return Err (
2959+ ModuleErrorKind :: UnsupportedImportAttributeType {
2960+ specifier : opts. specifier ,
2961+ referrer : attribute_type. range . clone ( ) ,
2962+ kind : attribute_type. kind . clone ( ) ,
2963+ }
2964+ . into_box ( ) ,
2965+ ) ;
2966+ }
2967+
29542968 // here we check any media types that should have assertions made against them
29552969 // if they aren't the root and add them to the graph, otherwise we continue
29562970 if media_type == MediaType :: Json
@@ -2974,27 +2988,18 @@ pub(crate) async fn parse_module_source_and_info(
29742988 } ) ;
29752989 }
29762990
2977- if let Some ( attribute_type) = opts. maybe_attribute_type {
2978- if attribute_type. kind == "json" {
2979- return Err (
2980- ModuleErrorKind :: InvalidTypeAssertion {
2981- specifier : opts. specifier . clone ( ) ,
2982- referrer : attribute_type. range . clone ( ) ,
2983- actual_media_type : media_type,
2984- expected_media_type : MediaType :: Json ,
2985- }
2986- . into_box ( ) ,
2987- ) ;
2988- } else if !matches ! ( attribute_type. kind. as_str( ) , "text" | "bytes" ) {
2989- return Err (
2990- ModuleErrorKind :: UnsupportedImportAttributeType {
2991- specifier : opts. specifier ,
2992- referrer : attribute_type. range . clone ( ) ,
2993- kind : attribute_type. kind . clone ( ) ,
2994- }
2995- . into_box ( ) ,
2996- ) ;
2997- }
2991+ if let Some ( attribute_type) = opts. maybe_attribute_type
2992+ && attribute_type. kind == "json"
2993+ {
2994+ return Err (
2995+ ModuleErrorKind :: InvalidTypeAssertion {
2996+ specifier : opts. specifier . clone ( ) ,
2997+ referrer : attribute_type. range . clone ( ) ,
2998+ actual_media_type : media_type,
2999+ expected_media_type : MediaType :: Json ,
3000+ }
3001+ . into_box ( ) ,
3002+ ) ;
29983003 }
29993004
30003005 if matches ! ( media_type, MediaType :: Cjs | MediaType :: Cts )
@@ -3100,6 +3105,7 @@ pub(crate) async fn parse_module_source_and_info(
31003105 | MediaType :: Sql
31013106 | MediaType :: Jsonc
31023107 | MediaType :: Json5
3108+ | MediaType :: Markdown
31033109 | MediaType :: Unknown => Err (
31043110 ModuleErrorKind :: UnsupportedMediaType {
31053111 specifier : opts. specifier ,
0 commit comments