Unverified Commit 13c47b3f authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: improve module type error message (#88815)

### What?

improve module type error message
parent c582bf8e
......@@ -674,10 +674,12 @@ async fn process_default_internal(
ModuleIssue::new(
*ident,
rcstr!("Invalid module type"),
rcstr!(
format!(
"The module type must be Ecmascript or Typescript to add \
Ecmascript transforms"
),
Ecmascript transforms (got {})",
module_type
)
.into(),
Some(IssueSource::from_source_only(current_source)),
)
.to_resolved()
......
use std::fmt::Display;
use anyhow::Result;
use bincode::{Decode, Encode};
use turbo_rcstr::RcStr;
......@@ -153,3 +155,24 @@ pub enum ModuleType {
},
Custom(ResolvedVc<Box<dyn CustomModuleType>>),
}
impl Display for ModuleType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ModuleType::Ecmascript { .. } => write!(f, "Ecmascript"),
ModuleType::Typescript { .. } => write!(f, "Typescript"),
ModuleType::TypescriptDeclaration { .. } => write!(f, "TypescriptDeclaration"),
ModuleType::EcmascriptExtensionless { .. } => write!(f, "EcmascriptExtensionless"),
ModuleType::Json => write!(f, "Json"),
ModuleType::Raw => write!(f, "Raw"),
ModuleType::NodeAddon => write!(f, "NodeAddon"),
ModuleType::CssModule => write!(f, "CssModule"),
ModuleType::Css { .. } => write!(f, "Css"),
ModuleType::StaticUrlJs { .. } => write!(f, "StaticUrlJs"),
ModuleType::StaticUrlCss { .. } => write!(f, "StaticUrlCss"),
ModuleType::InlinedBytesJs => write!(f, "InlinedBytesJs"),
ModuleType::WebAssembly { .. } => write!(f, "WebAssembly"),
ModuleType::Custom(_) => write!(f, "Custom"),
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment