From 2e9464121e059de94bf5c56ad10b96271545ed4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Tue, 3 Dec 2024 11:22:01 +0900 Subject: [PATCH] done? --- crates/next-core/src/util.rs | 45 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/crates/next-core/src/util.rs b/crates/next-core/src/util.rs index bd9501423d8c52..f2ea8baa64c7c5 100644 --- a/crates/next-core/src/util.rs +++ b/crates/next-core/src/util.rs @@ -200,6 +200,14 @@ pub struct NextSourceConfigParsingIssue { detail: ResolvedVc, } +#[turbo_tasks::value_impl] +impl NextSourceConfigParsingIssue { + #[turbo_tasks::function] + pub fn new(ident: ResolvedVc, detail: ResolvedVc) -> Vc { + Self { ident, detail }.cell() + } +} + #[turbo_tasks::value_impl] impl Issue for NextSourceConfigParsingIssue { #[turbo_tasks::function] @@ -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 @@ -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 @@ -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(); } } }