Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,7 @@ impl Issue for InvalidLoaderRuleRenameAsIssue {

#[turbo_tasks::value(shared)]
struct InvalidLoaderRuleConditionIssue {
error_string: RcStr,
condition: ConfigConditionItem,
config_file_path: FileSystemPath,
}
Expand All @@ -1307,7 +1308,15 @@ impl Issue for InvalidLoaderRuleConditionIssue {
#[turbo_tasks::function]
async fn description(&self) -> Result<Vc<OptionStyledString>> {
Ok(Vc::cell(Some(
StyledString::Text(RcStr::from(format!("{:#?}", self.condition))).resolved_cell(),
StyledString::Stack(vec![
StyledString::Line(vec![
StyledString::Text(rcstr!("Encountered the following error: ")),
StyledString::Code(self.error_string.clone()),
]),
StyledString::Text(rcstr!("While processing the condition:")),
StyledString::Code(RcStr::from(format!("{:#?}", self.condition))),
])
.resolved_cell(),
)))
}

Expand Down Expand Up @@ -1497,19 +1506,21 @@ impl NextConfig {
// convert from Next.js-specific condition type to internal Turbopack
// condition type
let condition = if let Some(condition) = condition {
if let Ok(cond) = ConditionItem::try_from(condition.clone()) {
Some(cond)
} else {
InvalidLoaderRuleConditionIssue {
condition: condition.clone(),
config_file_path: self
.config_file_path(project_path.clone())
.owned()
.await?,
match ConditionItem::try_from(condition.clone()) {
Ok(cond) => Some(cond),
Err(err) => {
InvalidLoaderRuleConditionIssue {
error_string: RcStr::from(err.to_string()),
condition: condition.clone(),
config_file_path: self
.config_file_path(project_path.clone())
.owned()
.await?,
}
.resolved_cell()
.emit();
None
}
.resolved_cell()
.emit();
None
}
} else {
None
Expand Down
13 changes: 13 additions & 0 deletions examples/basic-css/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
turbopack: {
rules: {
"*.svg": {
loaders: ["@svgr/webpack"],
as: "*.js",
condition: {
path: /abc/,
},
},
},
},
};
Loading