Skip to content

Commit

Permalink
done?
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Dec 8, 2024
1 parent adf7674 commit 113bdb7
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions crates/next-core/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ pub struct NextSourceConfigParsingIssue {
detail: ResolvedVc<StyledString>,
}

#[turbo_tasks::value_impl]
impl NextSourceConfigParsingIssue {
#[turbo_tasks::function]
pub fn new(ident: ResolvedVc<AssetIdent>, detail: ResolvedVc<StyledString>) -> Vc<Self> {
Self { ident, detail }.cell()
}
}

#[turbo_tasks::value_impl]
impl Issue for NextSourceConfigParsingIssue {
#[turbo_tasks::function]
Expand Down Expand Up @@ -407,17 +415,16 @@ pub async fn parse_config_from_source(
Ok(parse_config_from_js_value(*module, &value).cell())
});
} else {
NextSourceConfigParsingIssue {
ident: module.ident(),
detail: StyledString::Text(
NextSourceConfigParsingIssue::new(
module.ident(),
StyledString::Text(
"The exported config object must contain an variable \
initializer."
.into(),
)
.resolved_cell(),
}
.resolved_cell()
.emit()
.cell(),
)
.emit();
}
}
// Or, check if there is segment runtime option
Expand All @@ -426,15 +433,14 @@ pub async fn parse_config_from_source(
.map(|ident| &*ident.sym == "runtime")
.unwrap_or_default()
{
let runtime_value_issue = NextSourceConfigParsingIssue {
ident: module.ident(),
detail: StyledString::Text(
let runtime_value_issue = NextSourceConfigParsingIssue::new(
module.ident(),
StyledString::Text(
"The runtime property must be either \"nodejs\" or \"edge\"."
.into(),
)
.resolved_cell(),
}
.resolved_cell();
.cell(),
);
if let Some(init) = decl.init.as_ref() {
// skipping eval and directly read the expr's value, as we know it
// should be a const string
Expand All @@ -459,17 +465,16 @@ pub async fn parse_config_from_source(
runtime_value_issue.emit();
}
} else {
NextSourceConfigParsingIssue {
ident: module.ident(),
detail: StyledString::Text(
NextSourceConfigParsingIssue::new(
module.ident(),
StyledString::Text(
"The exported segment runtime option must contain an \
variable initializer."
.into(),
)
.resolved_cell(),
}
.resolved_cell()
.emit()
.cell(),
)
.emit();
}
}
}
Expand Down

0 comments on commit 113bdb7

Please sign in to comment.