diff --git a/crates/turbo-tasks-fetch/src/lib.rs b/crates/turbo-tasks-fetch/src/lib.rs index 0d996391a17b9..13d1000c65692 100644 --- a/crates/turbo-tasks-fetch/src/lib.rs +++ b/crates/turbo-tasks-fetch/src/lib.rs @@ -5,7 +5,7 @@ use anyhow::Result; use turbo_tasks::Vc; use turbo_tasks_fs::FileSystemPath; -use turbopack_core::issue::{Issue, IssueSeverity}; +use turbopack_core::issue::{Issue, IssueSeverity, StyledString}; pub fn register() { turbo_tasks::register(); @@ -154,11 +154,11 @@ impl Issue for FetchIssue { } #[turbo_tasks::function] - async fn description(&self) -> Result> { + async fn description(&self) -> Result> { let url = &*self.url.await?; let kind = &*self.kind.await?; - Ok(Vc::cell(match kind { + Ok(StyledString::Text(match kind { FetchErrorKind::Connect => format!( "There was an issue establishing a connection while requesting {}.", url @@ -171,7 +171,8 @@ impl Issue for FetchIssue { } FetchErrorKind::Timeout => format!("Connection timed out when requesting {}", url), FetchErrorKind::Other => format!("There was an issue requesting {}", url), - })) + }) + .cell()) } #[turbo_tasks::function] diff --git a/crates/turbo-tasks-fetch/tests/fetch.rs b/crates/turbo-tasks-fetch/tests/fetch.rs index 69d880e3e6751..bb2ba659c2743 100644 --- a/crates/turbo-tasks-fetch/tests/fetch.rs +++ b/crates/turbo-tasks-fetch/tests/fetch.rs @@ -4,7 +4,7 @@ use turbo_tasks::Vc; use turbo_tasks_fetch::{fetch, register, FetchErrorKind}; use turbo_tasks_fs::{DiskFileSystem, FileSystem, FileSystemPath}; use turbo_tasks_testing::{register, run}; -use turbopack_core::issue::{Issue, IssueSeverity}; +use turbopack_core::issue::{Issue, IssueSeverity, StyledString}; register!(); @@ -115,7 +115,7 @@ async fn errors_on_failed_connection() { let issue = err_vc.to_issue(IssueSeverity::Error.into(), get_issue_context()); assert_eq!(*issue.severity().await?, IssueSeverity::Error); assert_eq!(*issue.category().await?, "fetch"); - assert_eq!(*issue.description().await?, "There was an issue establishing a connection while requesting https://doesnotexist/foo.woff."); + assert_eq!(*issue.description().await?, StyledString::Text("There was an issue establishing a connection while requesting https://doesnotexist/foo.woff.".to_string())); } } @@ -137,7 +137,7 @@ async fn errors_on_404() { let issue = err_vc.to_issue(IssueSeverity::Error.into(), get_issue_context()); assert_eq!(*issue.severity().await?, IssueSeverity::Error); assert_eq!(*issue.category().await?, "fetch"); - assert_eq!(*issue.description().await?, format!("Received response with status 404 when requesting {}", &resource_url)); + assert_eq!(*issue.description().await?, StyledString::Text(format!("Received response with status 404 when requesting {}", &resource_url))); } } diff --git a/crates/turbopack-cli-utils/src/issue.rs b/crates/turbopack-cli-utils/src/issue.rs index df81ce39f86ad..c92c1d249ab1c 100644 --- a/crates/turbopack-cli-utils/src/issue.rs +++ b/crates/turbopack-cli-utils/src/issue.rs @@ -15,7 +15,7 @@ use turbo_tasks::{RawVc, ReadRef, TransientInstance, TransientValue, TryJoinIter use turbo_tasks_fs::{source_context::get_source_context, FileLinesContent}; use turbopack_core::issue::{ CapturedIssues, Issue, IssueReporter, IssueSeverity, PlainIssue, PlainIssueProcessingPathItem, - PlainIssueSource, + PlainIssueSource, StyledString, }; use crate::source_context::format_source_context_lines; @@ -145,7 +145,12 @@ pub fn format_issue( let mut styled_issue = style_issue_source(plain_issue, &context_path); let description = &plain_issue.description; if !description.is_empty() { - writeln!(styled_issue, "\n{description}").unwrap(); + writeln!( + styled_issue, + "\n{}", + render_styled_string_to_ansi(description) + ) + .unwrap(); } if log_detail { @@ -386,7 +391,11 @@ impl IssueReporter for ConsoleUi { let mut styled_issue = style_issue_source(&plain_issue, &context_path); let description = &plain_issue.description; if !description.is_empty() { - writeln!(&mut styled_issue, "\n{description}")?; + writeln!( + &mut styled_issue, + "\n{}", + render_styled_string_to_ansi(description) + )?; } if log_detail { @@ -539,6 +548,30 @@ fn show_all_message_with_shown_count( } } +fn render_styled_string_to_ansi(styled_string: &StyledString) -> String { + match styled_string { + StyledString::Line(parts) => { + let mut string = String::new(); + for part in parts { + string.push_str(&render_styled_string_to_ansi(part)); + } + string.push('\n'); + string + } + StyledString::Stack(parts) => { + let mut string = String::new(); + for part in parts { + string.push_str(&render_styled_string_to_ansi(part)); + string.push('\n'); + } + string + } + StyledString::Text(string) => string.to_string(), + StyledString::Code(string) => string.blue().to_string(), + StyledString::Strong(string) => string.bold().to_string(), + } +} + fn style_issue_source(plain_issue: &PlainIssue, context_path: &str) -> String { let title = &plain_issue.title; diff --git a/crates/turbopack-core/src/issue/analyze.rs b/crates/turbopack-core/src/issue/analyze.rs index 9e732e2c37e3d..84b786c2a1a09 100644 --- a/crates/turbopack-core/src/issue/analyze.rs +++ b/crates/turbopack-core/src/issue/analyze.rs @@ -2,7 +2,7 @@ use anyhow::Result; use turbo_tasks::Vc; use turbo_tasks_fs::FileSystemPath; -use super::{Issue, IssueSeverity, IssueSource, OptionIssueSource}; +use super::{Issue, IssueSeverity, IssueSource, OptionIssueSource, StyledString}; use crate::ident::AssetIdent; #[turbo_tasks::value(shared)] @@ -10,7 +10,7 @@ pub struct AnalyzeIssue { pub severity: Vc, pub source_ident: Vc, pub title: Vc, - pub message: Vc, + pub message: Vc, pub category: Vc, pub code: Option, pub source: Option>, @@ -43,7 +43,7 @@ impl Issue for AnalyzeIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { + fn description(&self) -> Vc { self.message } diff --git a/crates/turbopack-core/src/issue/code_gen.rs b/crates/turbopack-core/src/issue/code_gen.rs index 82b18235b3a1e..129e03618fd9f 100644 --- a/crates/turbopack-core/src/issue/code_gen.rs +++ b/crates/turbopack-core/src/issue/code_gen.rs @@ -1,14 +1,14 @@ use turbo_tasks::Vc; use turbo_tasks_fs::FileSystemPath; -use super::{Issue, IssueSeverity}; +use super::{Issue, IssueSeverity, StyledString}; #[turbo_tasks::value(shared)] pub struct CodeGenerationIssue { pub severity: Vc, pub path: Vc, pub title: Vc, - pub message: Vc, + pub message: Vc, } #[turbo_tasks::value_impl] @@ -34,7 +34,7 @@ impl Issue for CodeGenerationIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { + fn description(&self) -> Vc { self.message } } diff --git a/crates/turbopack-core/src/issue/mod.rs b/crates/turbopack-core/src/issue/mod.rs index 93a181d0eef09..2bd0fa69857d5 100644 --- a/crates/turbopack-core/src/issue/mod.rs +++ b/crates/turbopack-core/src/issue/mod.rs @@ -73,6 +73,41 @@ impl Display for IssueSeverity { } } +/// Represents a section of structured styled text. This can be interpreted and +/// rendered by various UIs as appropriate, e.g. HTML for display on the web, +/// ANSI sequences in TTYs. +#[derive(Clone, Debug, DeterministicHash)] +#[turbo_tasks::value(shared)] +pub enum StyledString { + /// Multiple [StyledString]s concatenated into a single line. Each item is + /// considered as inline element. Items might contain line breaks, which + /// would be considered as soft line breaks. + Line(Vec), + /// Multiple [StyledString]s stacked vertically. They are considered as + /// block elements, just like the top level [StyledString]. + Stack(Vec), + /// Some prose text. + Text(String), + /// Code snippet. + // TODO add language to support syntax hightlighting + Code(String), + /// Some important text. + Strong(String), +} + +impl StyledString { + pub fn is_empty(&self) -> bool { + match self { + StyledString::Line(parts) | StyledString::Stack(parts) => { + parts.iter().all(|part| part.is_empty()) + } + StyledString::Text(string) + | StyledString::Code(string) + | StyledString::Strong(string) => string.is_empty(), + } + } +} + #[turbo_tasks::value_trait] pub trait Issue { /// Severity allows the user to filter out unimportant issues, with Bug @@ -100,7 +135,7 @@ pub trait Issue { /// A more verbose message of the issue, appropriate for providing multiline /// information of the issue. // TODO add Vc - fn description(self: Vc) -> Vc; + fn description(self: Vc) -> Vc; /// Full details of the issue, appropriate for providing debug level /// information. Only displayed if the user explicitly asks for detailed @@ -484,7 +519,7 @@ pub struct PlainIssue { pub category: String, pub title: String, - pub description: String, + pub description: StyledString, pub detail: String, pub documentation_link: String, @@ -498,10 +533,7 @@ fn hash_plain_issue(issue: &PlainIssue, hasher: &mut Xxh3Hash64Hasher, full: boo hasher.write_ref(&issue.file_path); hasher.write_ref(&issue.category); hasher.write_ref(&issue.title); - hasher.write_ref( - // Normalize syspaths from Windows. These appear in stack traces. - &issue.description.replace('\\', "/"), - ); + hasher.write_ref(&issue.description); hasher.write_ref(&issue.detail); hasher.write_ref(&issue.documentation_link); diff --git a/crates/turbopack-core/src/issue/resolve.rs b/crates/turbopack-core/src/issue/resolve.rs index fb7f16f6610a6..06d5eb33d8d26 100644 --- a/crates/turbopack-core/src/issue/resolve.rs +++ b/crates/turbopack-core/src/issue/resolve.rs @@ -4,7 +4,7 @@ use anyhow::Result; use turbo_tasks::{ValueToString, Vc}; use turbo_tasks_fs::FileSystemPath; -use super::{Issue, IssueSource, OptionIssueSource}; +use super::{Issue, IssueSource, OptionIssueSource, StyledString}; use crate::{ error::PrettyPrintError, issue::IssueSeverity, @@ -48,11 +48,19 @@ impl Issue for ResolvingIssue { } #[turbo_tasks::function] - async fn description(&self) -> Result> { - Ok(Vc::cell(format!( - "unable to resolve {module_name}", - module_name = self.request.to_string().await? - ))) + async fn description(&self) -> Result> { + let module_not_found = StyledString::Strong("Module not found".to_string()); + + Ok(match self.request.await?.request() { + Some(request) => StyledString::Line(vec![ + module_not_found, + StyledString::Text(": Can't resolve '".to_string()), + StyledString::Code(request), + StyledString::Text("'".to_string()), + ]), + None => module_not_found, + } + .cell()) } #[turbo_tasks::function] diff --git a/crates/turbopack-core/src/issue/unsupported_module.rs b/crates/turbopack-core/src/issue/unsupported_module.rs index 16d11ef4029b4..279128e2de387 100644 --- a/crates/turbopack-core/src/issue/unsupported_module.rs +++ b/crates/turbopack-core/src/issue/unsupported_module.rs @@ -2,7 +2,7 @@ use anyhow::Result; use turbo_tasks::Vc; use turbo_tasks_fs::FileSystemPath; -use super::{Issue, IssueSeverity}; +use super::{Issue, IssueSeverity, StyledString}; #[turbo_tasks::value(shared)] pub struct UnsupportedModuleIssue { @@ -34,10 +34,11 @@ impl Issue for UnsupportedModuleIssue { } #[turbo_tasks::function] - async fn description(&self) -> Result> { - Ok(Vc::cell(match &self.package_path { + async fn description(&self) -> Result> { + Ok(StyledString::Text(match &self.package_path { Some(path) => format!("The module {}{} is not yet supported", self.package, path), None => format!("The package {} is not yet supported", self.package), - })) + }) + .cell()) } } diff --git a/crates/turbopack-core/src/package_json.rs b/crates/turbopack-core/src/package_json.rs index afd37fdc9ed9a..fcc7dc88b1c2d 100644 --- a/crates/turbopack-core/src/package_json.rs +++ b/crates/turbopack-core/src/package_json.rs @@ -6,7 +6,7 @@ use turbo_tasks::{debug::ValueDebugFormat, trace::TraceRawVcs, ReadRef, Vc}; use turbo_tasks_fs::{FileContent, FileJsonContent, FileSystemPath}; use super::issue::Issue; -use crate::issue::IssueExt; +use crate::issue::{IssueExt, StyledString}; /// PackageJson wraps the parsed JSON content of a `package.json` file. The /// wrapper is necessary so that we can reference the [FileJsonContent]'s inner @@ -79,7 +79,7 @@ impl Issue for PackageJsonIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { - Vc::cell(self.error_message.clone()) + fn description(&self) -> Vc { + StyledString::Text(self.error_message.clone()).cell() } } diff --git a/crates/turbopack-css/src/module_asset.rs b/crates/turbopack-css/src/module_asset.rs index 17ea3b68732ae..1120794e35ce2 100644 --- a/crates/turbopack-css/src/module_asset.rs +++ b/crates/turbopack-css/src/module_asset.rs @@ -14,7 +14,7 @@ use turbopack_core::{ chunk::{ChunkItem, ChunkItemExt, ChunkType, ChunkableModule, ChunkingContext}, context::AssetContext, ident::AssetIdent, - issue::{Issue, IssueExt, IssueSeverity}, + issue::{Issue, IssueExt, IssueSeverity, StyledString}, module::Module, reference::{ModuleReference, ModuleReferences}, reference_type::{CssReferenceSubType, ReferenceType}, @@ -316,12 +316,12 @@ impl EcmascriptChunkItem for ModuleChunkItem { CssModuleComposesIssue { severity: IssueSeverity::Error.cell(), source: self.module.ident(), - message: Vc::cell(formatdoc! { + message: formatdoc! { r#" Module {from} referenced in `composes: ... from {from};` can't be resolved. "#, from = &*from.await?.request.to_string().await? - }), + }, }.cell().emit(); continue; }; @@ -333,12 +333,12 @@ impl EcmascriptChunkItem for ModuleChunkItem { CssModuleComposesIssue { severity: IssueSeverity::Error.cell(), source: self.module.ident(), - message: Vc::cell(formatdoc! { + message: formatdoc! { r#" Module {from} referenced in `composes: ... from {from};` is not a CSS module. "#, from = &*from.await?.request.to_string().await? - }), + }, }.cell().emit(); continue; }; @@ -412,7 +412,7 @@ fn generate_minimal_source_map(filename: String, source: String) -> Vc, source: Vc, - message: Vc, + message: String, } #[turbo_tasks::value_impl] @@ -440,7 +440,7 @@ impl Issue for CssModuleComposesIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { - self.message + fn description(&self) -> Vc { + StyledString::Text(self.message.clone()).cell() } } diff --git a/crates/turbopack-dev-server/src/update/stream.rs b/crates/turbopack-dev-server/src/update/stream.rs index 19f8729fe6856..67efba3c74df9 100644 --- a/crates/turbopack-dev-server/src/update/stream.rs +++ b/crates/turbopack-dev-server/src/update/stream.rs @@ -11,6 +11,7 @@ use turbopack_core::{ error::PrettyPrintError, issue::{ Issue, IssueDescriptionExt, IssueSeverity, OptionIssueProcessingPathItems, PlainIssue, + StyledString, }, server_fs::ServerFileSystem, version::{ @@ -55,7 +56,7 @@ async fn get_update_stream_item( plain_issues.push( FatalStreamIssue { resource: resource.to_string(), - description: Vc::cell(format!("{}", PrettyPrintError(&e))), + description: StyledString::Text(format!("{}", PrettyPrintError(&e))).cell(), } .cell() .into_plain(OptionIssueProcessingPathItems::none()) @@ -279,7 +280,7 @@ pub enum UpdateStreamItem { #[turbo_tasks::value(serialization = "none")] struct FatalStreamIssue { - description: Vc, + description: Vc, resource: String, } @@ -306,7 +307,7 @@ impl Issue for FatalStreamIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { + fn description(&self) -> Vc { self.description } } diff --git a/crates/turbopack-dev/src/ecmascript/content_entry.rs b/crates/turbopack-dev/src/ecmascript/content_entry.rs index e0a3a533207fa..a2edde882c8a2 100644 --- a/crates/turbopack-dev/src/ecmascript/content_entry.rs +++ b/crates/turbopack-dev/src/ecmascript/content_entry.rs @@ -8,7 +8,7 @@ use turbopack_core::{ chunk::{AsyncModuleInfo, ChunkItem, ChunkItemExt, ModuleId}, code_builder::{Code, CodeBuilder}, error::PrettyPrintError, - issue::{code_gen::CodeGenerationIssue, IssueExt, IssueSeverity}, + issue::{code_gen::CodeGenerationIssue, IssueExt, IssueSeverity, StyledString}, }; use turbopack_ecmascript::chunk::{ EcmascriptChunkContent, EcmascriptChunkItem, EcmascriptChunkItemExt, @@ -104,7 +104,7 @@ async fn item_code( severity: IssueSeverity::Error.cell(), path: item.asset_ident().path(), title: Vc::cell("Code generation for chunk item errored".to_string()), - message: Vc::cell(error_message), + message: StyledString::Text(error_message).cell(), } .cell() .emit(); diff --git a/crates/turbopack-dev/src/react_refresh.rs b/crates/turbopack-dev/src/react_refresh.rs index eb4463f605aa5..da235accd5200 100644 --- a/crates/turbopack-dev/src/react_refresh.rs +++ b/crates/turbopack-dev/src/react_refresh.rs @@ -3,7 +3,7 @@ use turbo_tasks::Vc; use turbo_tasks_fs::FileSystemPath; use turbopack::resolve_options_context::ResolveOptionsContext; use turbopack_core::{ - issue::{Issue, IssueExt, IssueSeverity}, + issue::{Issue, IssueExt, IssueSeverity, StyledString}, resolve::parse::Request, }; use turbopack_ecmascript::resolve::apply_cjs_specific_options; @@ -89,11 +89,17 @@ impl Issue for ReactRefreshResolvingIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { - Vc::cell( - "React Refresh will be disabled.\nTo enable React Refresh, install the \ - `react-refresh` and `@next/react-refresh-utils` modules." - .to_string(), - ) + fn description(&self) -> Vc { + StyledString::Line(vec![ + StyledString::Text( + "React Refresh will be disabled.\nTo enable React Refresh, install the " + .to_string(), + ), + StyledString::Code("react-refresh".to_string()), + StyledString::Text(" and ".to_string()), + StyledString::Code("@next/react-refresh-utils".to_string()), + StyledString::Text(" modules.".to_string()), + ]) + .cell() } } diff --git a/crates/turbopack-ecmascript-hmr-protocol/src/lib.rs b/crates/turbopack-ecmascript-hmr-protocol/src/lib.rs index 1fb043bd93a28..9cf747f5b3533 100644 --- a/crates/turbopack-ecmascript-hmr-protocol/src/lib.rs +++ b/crates/turbopack-ecmascript-hmr-protocol/src/lib.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use turbopack_cli_utils::issue::{format_issue, LogOptions}; use turbopack_core::{ - issue::{IssueSeverity, PlainIssue}, + issue::{IssueSeverity, PlainIssue, StyledString}, source_pos::SourcePos, }; @@ -140,7 +140,7 @@ pub struct Issue<'a> { pub category: &'a str, pub title: &'a str, - pub description: &'a str, + pub description: &'a StyledString, pub detail: &'a str, pub documentation_link: &'a str, diff --git a/crates/turbopack-ecmascript-plugins/src/transform/swc_ecma_transform_plugins.rs b/crates/turbopack-ecmascript-plugins/src/transform/swc_ecma_transform_plugins.rs index af4b87d222571..762bfa887fb63 100644 --- a/crates/turbopack-ecmascript-plugins/src/transform/swc_ecma_transform_plugins.rs +++ b/crates/turbopack-ecmascript-plugins/src/transform/swc_ecma_transform_plugins.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use swc_core::ecma::ast::Program; use turbo_tasks::Vc; use turbo_tasks_fs::FileSystemPath; -use turbopack_core::issue::{Issue, IssueSeverity}; +use turbopack_core::issue::{Issue, IssueSeverity, StyledString}; use turbopack_ecmascript::{CustomTransformer, TransformContext}; /// A wrapper around an SWC's ecma transform wasm plugin module bytes, allowing @@ -82,12 +82,13 @@ impl Issue for UnsupportedSwcEcmaTransformPluginsIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { - Vc::cell( + fn description(&self) -> Vc { + StyledString::Text( "Turbopack does not yet support running SWC EcmaScript transform plugins on this \ platform." .to_string(), ) + .cell() } } diff --git a/crates/turbopack-ecmascript/src/chunk/item.rs b/crates/turbopack-ecmascript/src/chunk/item.rs index ef64b466cf950..c5acc96dcdb53 100644 --- a/crates/turbopack-ecmascript/src/chunk/item.rs +++ b/crates/turbopack-ecmascript/src/chunk/item.rs @@ -8,7 +8,7 @@ use turbopack_core::{ chunk::{AsyncModuleInfo, ChunkItem, ChunkItemExt, ChunkingContext}, code_builder::{Code, CodeBuilder}, error::PrettyPrintError, - issue::{code_gen::CodeGenerationIssue, IssueExt, IssueSeverity}, + issue::{code_gen::CodeGenerationIssue, IssueExt, IssueSeverity, StyledString}, }; use super::EcmascriptChunkingContext; @@ -238,7 +238,7 @@ async fn module_factory_with_code_generation_issue( severity: IssueSeverity::Error.cell(), path: chunk_item.asset_ident().path(), title: Vc::cell("Code generation for chunk item errored".to_string()), - message: Vc::cell(error_message), + message: StyledString::Text(error_message).cell(), } .cell() .emit(); diff --git a/crates/turbopack-ecmascript/src/parse.rs b/crates/turbopack-ecmascript/src/parse.rs index 35c9c0f841a33..ce0ae1b1592e7 100644 --- a/crates/turbopack-ecmascript/src/parse.rs +++ b/crates/turbopack-ecmascript/src/parse.rs @@ -25,7 +25,7 @@ use turbo_tasks_hash::hash_xxh3_hash64; use turbopack_core::{ asset::{Asset, AssetContent}, error::PrettyPrintError, - issue::{Issue, IssueExt, IssueSeverity}, + issue::{Issue, IssueExt, IssueSeverity, StyledString}, source::Source, source_map::{GenerateSourceMap, OptionSourceMap}, SOURCE_MAP_ROOT_NAME, @@ -395,11 +395,12 @@ impl Issue for ReadSourceIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { - Vc::cell(format!( + fn description(&self) -> Vc { + StyledString::Text(format!( "An unexpected error happened while trying to read the source code to parse: {}", self.error )) + .cell() } #[turbo_tasks::function] diff --git a/crates/turbopack-ecmascript/src/references/esm/export.rs b/crates/turbopack-ecmascript/src/references/esm/export.rs index e6e8b5ef840bc..d0835fea20851 100644 --- a/crates/turbopack-ecmascript/src/references/esm/export.rs +++ b/crates/turbopack-ecmascript/src/references/esm/export.rs @@ -15,7 +15,7 @@ use swc_core::{ }; use turbo_tasks::{trace::TraceRawVcs, ValueToString, Vc}; use turbopack_core::{ - issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity}, + issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity, StyledString}, module::Module, }; @@ -66,13 +66,14 @@ async fn expand_star_exports( EcmascriptExports::None => AnalyzeIssue { code: None, category: Vc::cell("analyze".to_string()), - message: Vc::cell(format!( + message: StyledString::Text(format!( "export * used with module {} which has no exports\nTypescript only: Did you \ want to export only types with `export type * from \"...\"`?\nNote: Using \ `export type` is more efficient than `export *` as it won't emit any runtime \ code.", asset.ident().to_string().await? - )), + )) + .cell(), source_ident: asset.ident(), severity: IssueSeverity::Warning.into(), source: None, @@ -83,12 +84,13 @@ async fn expand_star_exports( EcmascriptExports::Value => AnalyzeIssue { code: None, category: Vc::cell("analyze".to_string()), - message: Vc::cell(format!( + message: StyledString::Text(format!( "export * used with module {} which only has a default export (default export \ is not exported with export *)\nDid you want to use `export {{ default }} \ from \"...\";` instead?", asset.ident().to_string().await? - )), + )) + .cell(), source_ident: asset.ident(), severity: IssueSeverity::Warning.into(), source: None, @@ -101,13 +103,14 @@ async fn expand_star_exports( AnalyzeIssue { code: None, category: Vc::cell("analyze".to_string()), - message: Vc::cell(format!( + message: StyledString::Text(format!( "export * used with module {} which is a CommonJS module with exports \ only available at runtime\nList all export names manually (`export {{ a, \ b, c }} from \"...\") or rewrite the module to ESM, to avoid the \ additional runtime code.`", asset.ident().to_string().await? - )), + )) + .cell(), source_ident: asset.ident(), severity: IssueSeverity::Warning.into(), source: None, diff --git a/crates/turbopack-ecmascript/src/references/esm/url.rs b/crates/turbopack-ecmascript/src/references/esm/url.rs index 94a66a0b7e823..85dfd7a299c67 100644 --- a/crates/turbopack-ecmascript/src/references/esm/url.rs +++ b/crates/turbopack-ecmascript/src/references/esm/url.rs @@ -9,7 +9,7 @@ use turbopack_core::{ ChunkItemExt, ChunkableModule, ChunkableModuleReference, ChunkingType, ChunkingTypeOption, }, environment::Rendering, - issue::{code_gen::CodeGenerationIssue, IssueExt, IssueSeverity, IssueSource}, + issue::{code_gen::CodeGenerationIssue, IssueExt, IssueSeverity, IssueSource, StyledString}, reference::ModuleReference, reference_type::UrlReferenceSubType, resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult}, @@ -193,11 +193,12 @@ impl CodeGenerateable for UrlAssetReference { title: Vc::cell( "new URL(…) not implemented for this environment".to_string(), ), - message: Vc::cell( + message: StyledString::Text( "new URL(…) is only currently supported for rendering \ environments like Client-Side or Server-Side Rendering." .to_string(), - ), + ) + .cell(), path: this.origin.origin_path(), } .cell() diff --git a/crates/turbopack-ecmascript/src/references/mod.rs b/crates/turbopack-ecmascript/src/references/mod.rs index facc18a34b6eb..3fb23cd1071ff 100644 --- a/crates/turbopack-ecmascript/src/references/mod.rs +++ b/crates/turbopack-ecmascript/src/references/mod.rs @@ -51,7 +51,7 @@ use turbo_tasks_fs::{FileJsonContent, FileSystemPath}; use turbopack_core::{ compile_time_info::{CompileTimeInfo, FreeVarReference}, error::PrettyPrintError, - issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity, IssueSource}, + issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity, IssueSource, StyledString}, module::Module, reference::{ModuleReference, ModuleReferences, SourceMapReference}, reference_type::{CommonJsReferenceSubType, ReferenceType}, @@ -644,7 +644,10 @@ pub(crate) async fn analyze_ecmascript_module( AnalyzeIssue { code: None, category: Vc::cell("analyze".to_string()), - message: Vc::cell("top level await is only supported in ESM modules.".to_string()), + message: StyledString::Text( + "top level await is only supported in ESM modules.".to_string(), + ) + .cell(), source_ident: source.ident(), severity: IssueSeverity::Error.into(), source: Some(issue_source(source, span)), diff --git a/crates/turbopack-ecmascript/src/references/pattern_mapping.rs b/crates/turbopack-ecmascript/src/references/pattern_mapping.rs index a9896724cc48f..0e4672d4669d1 100644 --- a/crates/turbopack-ecmascript/src/references/pattern_mapping.rs +++ b/crates/turbopack-ecmascript/src/references/pattern_mapping.rs @@ -7,7 +7,7 @@ use swc_core::{ use turbo_tasks::{debug::ValueDebug, Value, Vc}; use turbopack_core::{ chunk::{ChunkItemExt, ChunkableModule, ChunkingContext, ModuleId}, - issue::{code_gen::CodeGenerationIssue, IssueExt, IssueSeverity}, + issue::{code_gen::CodeGenerationIssue, IssueExt, IssueSeverity, StyledString}, resolve::{ origin::ResolveOrigin, parse::Request, ModuleResolveResult, ModuleResolveResultItem, }, @@ -147,11 +147,12 @@ impl PatternMapping { title: Vc::cell( "pattern mapping is not implemented for this result".to_string(), ), - message: Vc::cell(format!( + message: StyledString::Text(format!( "the reference resolves to a non-trivial result, which is not supported \ yet: {:?}", resolve_result.dbg().await? - )), + )) + .cell(), path: origin.origin_path(), } .cell() @@ -181,9 +182,10 @@ impl PatternMapping { CodeGenerationIssue { severity: IssueSeverity::Bug.into(), title: Vc::cell("non-ecmascript placeable asset".to_string()), - message: Vc::cell( + message: StyledString::Text( "asset is not placeable in ESM chunks, so it doesn't have a module id".to_string(), - ), + ) + .cell(), path: origin.origin_path(), } .cell() diff --git a/crates/turbopack-ecmascript/src/references/type_issue.rs b/crates/turbopack-ecmascript/src/references/type_issue.rs index de7de0b92e36e..2b0614ee2ecb1 100644 --- a/crates/turbopack-ecmascript/src/references/type_issue.rs +++ b/crates/turbopack-ecmascript/src/references/type_issue.rs @@ -1,6 +1,6 @@ use turbo_tasks::Vc; use turbo_tasks_fs::FileSystemPath; -use turbopack_core::issue::{Issue, IssueSeverity}; +use turbopack_core::issue::{Issue, IssueSeverity, StyledString}; use crate::SpecifiedModuleType; @@ -38,9 +38,9 @@ impl Issue for SpecifiedModuleTypeIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { - match self.specified_type { - SpecifiedModuleType::CommonJs => Vc::cell( + fn description(&self) -> Vc { + StyledString::Text(match self.specified_type { + SpecifiedModuleType::CommonJs => { "The CommonJs module format was specified in the package.json that is affecting \ this source file or by using an special extension, but Ecmascript import/export \ syntax is used in the source code.\nThe module was automatically converted to an \ @@ -50,23 +50,23 @@ impl Issue for SpecifiedModuleTypeIssue { EcmaScript import/export syntax is added by an transform and isn't actually part \ of the source code. In these cases revisit transformation options to inject the \ correct syntax." - .to_string(), - ), - SpecifiedModuleType::EcmaScript => Vc::cell( + .to_string() + } + SpecifiedModuleType::EcmaScript => { "The EcmaScript module format was specified in the package.json that is affecting \ this source file or by using an special extension, but it looks like that \ - CommonJs syntax is used in the source code.\nExports made by CommonJs syntax \ - will lead to a runtime error, since the module is in EcmaScript mode. Either \ - change the \"type\" field in the package.json or replace CommonJs syntax with \ - EcmaScript import/export syntax in the source file." - .to_string(), - ), - SpecifiedModuleType::Automatic => Vc::cell( - "The module format specified in the package.json file is not matching the module \ - format of the source code." - .to_string(), - ), - } + CommonJs syntax is used in the source code.\nExports made by CommonJs syntax will \ + lead to a runtime error, since the module is in EcmaScript mode. Either change \ + the \"type\" field in the package.json or replace CommonJs syntax with EcmaScript \ + import/export syntax in the source file." + .to_string() + } + SpecifiedModuleType::Automatic => "The module format specified in the package.json \ + file is not matching the module format of the \ + source code." + .to_string(), + }) + .cell() } #[turbo_tasks::function] diff --git a/crates/turbopack-ecmascript/src/transform/mod.rs b/crates/turbopack-ecmascript/src/transform/mod.rs index 9a14f61036089..3ed899e4c10d1 100644 --- a/crates/turbopack-ecmascript/src/transform/mod.rs +++ b/crates/turbopack-ecmascript/src/transform/mod.rs @@ -21,7 +21,7 @@ use turbo_tasks::{ValueDefault, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ environment::Environment, - issue::{Issue, IssueSeverity}, + issue::{Issue, IssueSeverity, StyledString}, }; #[turbo_tasks::value(serialization = "auto_for_input")] @@ -314,7 +314,7 @@ impl Issue for UnsupportedServerActionIssue { } #[turbo_tasks::function] - async fn description(&self) -> Result> { - Ok(Vc::cell("".to_string())) + async fn description(&self) -> Result> { + Ok(StyledString::Text("".to_string()).cell()) } } diff --git a/crates/turbopack-ecmascript/src/typescript/resolve.rs b/crates/turbopack-ecmascript/src/typescript/resolve.rs index ac4b5b90927c9..de645580aa50e 100644 --- a/crates/turbopack-ecmascript/src/typescript/resolve.rs +++ b/crates/turbopack-ecmascript/src/typescript/resolve.rs @@ -9,7 +9,7 @@ use turbopack_core::{ context::AssetContext, file_source::FileSource, ident::AssetIdent, - issue::{Issue, IssueExt, IssueSeverity}, + issue::{Issue, IssueExt, IssueSeverity, StyledString}, reference::ModuleReference, reference_type::{ReferenceType, TypeScriptReferenceSubType}, resolve::{ @@ -30,7 +30,7 @@ use turbopack_core::{ pub struct TsConfigIssue { pub severity: Vc, pub source_ident: Vc, - pub message: Vc, + pub message: String, } #[turbo_tasks::function] @@ -61,7 +61,7 @@ pub async fn read_tsconfigs( TsConfigIssue { severity: IssueSeverity::Error.into(), source_ident: tsconfig.ident(), - message: Vc::cell(message), + message, } .cell() .emit(); @@ -70,7 +70,7 @@ pub async fn read_tsconfigs( TsConfigIssue { severity: IssueSeverity::Error.into(), source_ident: tsconfig.ident(), - message: Vc::cell("tsconfig not found".into()), + message: "tsconfig not found".into(), } .cell() .emit(); @@ -87,7 +87,7 @@ pub async fn read_tsconfigs( TsConfigIssue { severity: IssueSeverity::Error.into(), source_ident: tsconfig.ident(), - message: Vc::cell("extends doesn't resolve correctly".to_string()), + message: "extends doesn't resolve correctly".to_string(), } .cell() .emit(); @@ -257,12 +257,12 @@ pub async fn tsconfig_resolve_options( TsConfigIssue { severity: IssueSeverity::Warning.cell(), source_ident: source.ident(), - message: Vc::cell(format!( + message: format!( "compilerOptions.paths[{key}] doesn't contains an array as \ expected\n{key}: {value:#}", key = serde_json::to_string(key)?, value = value - )), + ), } .cell() .emit() @@ -473,7 +473,7 @@ impl Issue for TsConfigIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { - self.message + fn description(&self) -> Vc { + StyledString::Text(self.message.clone()).cell() } } diff --git a/crates/turbopack-env/src/issue.rs b/crates/turbopack-env/src/issue.rs index 9c7cee07b00a7..ed97c9b6942af 100644 --- a/crates/turbopack-env/src/issue.rs +++ b/crates/turbopack-env/src/issue.rs @@ -1,12 +1,12 @@ use turbo_tasks::Vc; use turbo_tasks_fs::FileSystemPath; -use turbopack_core::issue::Issue; +use turbopack_core::issue::{Issue, StyledString}; /// An issue that occurred while resolving the parsing or evaluating the .env. #[turbo_tasks::value(shared)] pub struct ProcessEnvIssue { pub path: Vc, - pub description: Vc, + pub description: Vc, } #[turbo_tasks::value_impl] @@ -27,7 +27,7 @@ impl Issue for ProcessEnvIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { + fn description(&self) -> Vc { self.description } } diff --git a/crates/turbopack-env/src/try_env.rs b/crates/turbopack-env/src/try_env.rs index 969b18b543c7a..f33e1cf77f45c 100644 --- a/crates/turbopack-env/src/try_env.rs +++ b/crates/turbopack-env/src/try_env.rs @@ -2,7 +2,7 @@ use anyhow::Result; use turbo_tasks::Vc; use turbo_tasks_env::{DotenvProcessEnv, EnvMap, ProcessEnv}; use turbo_tasks_fs::FileSystemPath; -use turbopack_core::issue::IssueExt; +use turbopack_core::issue::{IssueExt, StyledString}; use crate::ProcessEnvIssue; @@ -50,7 +50,7 @@ impl ProcessEnv for TryDotenvProcessEnv { // read_all_with_prior will wrap a current error with a context containing the // failing file, which we don't really care about (we report the filepath as the // Issue context, not the description). So extract the real error. - description: Vc::cell(e.root_cause().to_string()), + description: StyledString::Text(e.root_cause().to_string()).cell(), } .cell() .emit(); diff --git a/crates/turbopack-image/src/process/mod.rs b/crates/turbopack-image/src/process/mod.rs index f1d8b8f7e8759..0ecb15bf2a746 100644 --- a/crates/turbopack-image/src/process/mod.rs +++ b/crates/turbopack-image/src/process/mod.rs @@ -22,7 +22,7 @@ use turbo_tasks_fs::{File, FileContent, FileSystemPath}; use turbopack_core::{ error::PrettyPrintError, ident::AssetIdent, - issue::{Issue, IssueExt, IssueSeverity}, + issue::{Issue, IssueExt, IssueSeverity, StyledString}, }; use self::svg::calculate; @@ -107,7 +107,7 @@ fn result_to_issue(ident: Vc, result: Result) -> Option { Err(err) => { ImageProcessingIssue { path: ident.path(), - message: Vc::cell(format!("{}", PrettyPrintError(&err))), + message: StyledString::Text(format!("{}", PrettyPrintError(&err))).cell(), issue_severity: None, title: None, } @@ -164,11 +164,12 @@ fn load_image_internal( if matches!(format, Some(ImageFormat::Avif)) { ImageProcessingIssue { path: ident.path(), - message: Vc::cell( + message: StyledString::Text( "This version of Turbopack does not support AVIF images, will emit without \ optimization or encoding" .to_string(), - ), + ) + .cell(), title: Some(Vc::cell("AVIF image not supported".to_string())), issue_severity: Some(IssueSeverity::Warning.into()), } @@ -181,11 +182,12 @@ fn load_image_internal( if matches!(format, Some(ImageFormat::WebP)) { ImageProcessingIssue { path: ident.path(), - message: Vc::cell( + message: StyledString::Text( "This version of Turbopack does not support WEBP images, will emit without \ optimization or encoding" .to_string(), - ), + ) + .cell(), title: Some(Vc::cell("WEBP image not supported".to_string())), issue_severity: Some(IssueSeverity::Warning.into()), } @@ -211,7 +213,7 @@ fn compute_blur_data( Err(err) => { ImageProcessingIssue { path: ident.path(), - message: Vc::cell(format!("{}", PrettyPrintError(&err))), + message: StyledString::Text(format!("{}", PrettyPrintError(&err))).cell(), issue_severity: None, title: None, } @@ -481,7 +483,7 @@ pub async fn optimize( #[turbo_tasks::value] struct ImageProcessingIssue { path: Vc, - message: Vc, + message: Vc, title: Option>, issue_severity: Option>, } @@ -508,7 +510,7 @@ impl Issue for ImageProcessingIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { + fn description(&self) -> Vc { self.message } } diff --git a/crates/turbopack-node/src/evaluate.rs b/crates/turbopack-node/src/evaluate.rs index 1dba8de6149b6..3b62d648b59d4 100644 --- a/crates/turbopack-node/src/evaluate.rs +++ b/crates/turbopack-node/src/evaluate.rs @@ -26,7 +26,7 @@ use turbopack_core::{ context::AssetContext, file_source::FileSource, ident::AssetIdent, - issue::{Issue, IssueExt, IssueSeverity}, + issue::{Issue, IssueExt, IssueSeverity, StyledString}, module::Module, reference_type::{InnerAssets, ReferenceType}, virtual_source::VirtualSource, @@ -503,8 +503,8 @@ impl Issue for EvaluationIssue { } #[turbo_tasks::function] - async fn description(&self) -> Result> { - Ok(Vc::cell( + async fn description(&self) -> Result> { + Ok(StyledString::Text( self.error .print( self.assets_for_source_mapping, @@ -513,7 +513,8 @@ impl Issue for EvaluationIssue { FormattingMode::Plain, ) .await?, - )) + ) + .cell()) } } @@ -547,11 +548,11 @@ impl Issue for BuildDependencyIssue { } #[turbo_tasks::function] - async fn description(&self) -> Result> { - Ok(Vc::cell( + async fn description(&self) -> Result> { + Ok(StyledString::Text( format!("The file at {} is a build dependency, which is not yet implemented. Changing this file or any dependency will not be recognized and might require restarting the server", self.path.to_string().await?) - )) + ).cell()) } } @@ -627,8 +628,8 @@ impl Issue for EvaluateEmittedErrorIssue { } #[turbo_tasks::function] - async fn description(&self) -> Result> { - Ok(Vc::cell( + async fn description(&self) -> Result> { + Ok(StyledString::Text( self.error .print( self.assets_for_source_mapping, @@ -637,6 +638,7 @@ impl Issue for EvaluateEmittedErrorIssue { FormattingMode::Plain, ) .await?, - )) + ) + .cell()) } } diff --git a/crates/turbopack-node/src/render/issue.rs b/crates/turbopack-node/src/render/issue.rs index c30853e99aa58..ba0d067a7e8f6 100644 --- a/crates/turbopack-node/src/render/issue.rs +++ b/crates/turbopack-node/src/render/issue.rs @@ -1,13 +1,13 @@ use anyhow::Result; use turbo_tasks::Vc; use turbo_tasks_fs::FileSystemPath; -use turbopack_core::issue::Issue; +use turbopack_core::issue::{Issue, StyledString}; #[turbo_tasks::value(shared)] #[derive(Copy, Clone)] pub struct RenderingIssue { pub file_path: Vc, - pub message: Vc, + pub message: Vc, pub status: Option, } @@ -29,7 +29,7 @@ impl Issue for RenderingIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { + fn description(&self) -> Vc { self.message } diff --git a/crates/turbopack-node/src/render/render_proxy.rs b/crates/turbopack-node/src/render/render_proxy.rs index 365a3cc7fa4a8..dfb5b5993ba9b 100644 --- a/crates/turbopack-node/src/render/render_proxy.rs +++ b/crates/turbopack-node/src/render/render_proxy.rs @@ -12,7 +12,7 @@ use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ chunk::{ChunkingContext, EvaluatableAsset, EvaluatableAssets}, error::PrettyPrintError, - issue::IssueExt, + issue::{IssueExt, StyledString}, module::Module, }; use turbopack_dev_server::source::{Body, ProxyResult}; @@ -117,7 +117,7 @@ async fn proxy_error( RenderingIssue { file_path: path, - message: Vc::cell(message), + message: StyledString::Text(message).cell(), status: status.and_then(|status| status.code()), } .cell() diff --git a/crates/turbopack-node/src/render/render_static.rs b/crates/turbopack-node/src/render/render_static.rs index 8a30e73e3c10e..6d2b0820c9398 100644 --- a/crates/turbopack-node/src/render/render_static.rs +++ b/crates/turbopack-node/src/render/render_static.rs @@ -13,7 +13,7 @@ use turbopack_core::{ asset::{Asset, AssetContent}, chunk::{ChunkingContext, EvaluatableAsset, EvaluatableAssets}, error::PrettyPrintError, - issue::IssueExt, + issue::{IssueExt, StyledString}, module::Module, }; use turbopack_dev_server::{ @@ -165,7 +165,7 @@ async fn static_error( let issue = RenderingIssue { file_path: path, - message: Vc::cell(error), + message: StyledString::Text(error).cell(), status: status.and_then(|status| status.code()), }; diff --git a/crates/turbopack-node/src/transforms/postcss.rs b/crates/turbopack-node/src/transforms/postcss.rs index 98de0c4e85729..29c44c4a9e76a 100644 --- a/crates/turbopack-node/src/transforms/postcss.rs +++ b/crates/turbopack-node/src/transforms/postcss.rs @@ -12,7 +12,7 @@ use turbopack_core::{ context::AssetContext, file_source::FileSource, ident::AssetIdent, - issue::{Issue, IssueDescriptionExt, IssueExt, IssueSeverity}, + issue::{Issue, IssueDescriptionExt, IssueExt, IssueSeverity, StyledString}, module::Module, reference_type::{EntryReferenceSubType, InnerAssets, ReferenceType}, resolve::{find_context_file, FindContextFileResult}, @@ -310,8 +310,8 @@ impl Issue for PostCssTransformIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { - Vc::cell(self.description.to_string()) + fn description(&self) -> Vc { + StyledString::Text(self.description.to_string()).cell() } #[turbo_tasks::function] diff --git a/crates/turbopack-swc-utils/src/emitter.rs b/crates/turbopack-swc-utils/src/emitter.rs index 07bc7f05d4839..af3233d5da5ef 100644 --- a/crates/turbopack-swc-utils/src/emitter.rs +++ b/crates/turbopack-swc-utils/src/emitter.rs @@ -7,7 +7,7 @@ use swc_core::common::{ }; use turbo_tasks::Vc; use turbopack_core::{ - issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity, IssueSource}, + issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity, IssueSource, StyledString}, source::Source, }; @@ -60,7 +60,7 @@ impl Emitter for IssueEmitter { category: Vc::cell("parse".to_string()), source_ident: self.source.ident(), title: Vc::cell(title), - message: Vc::cell(message), + message: StyledString::Text(message).cell(), code, source, } diff --git a/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/issues/unexpected export __star__-2e0d97.txt b/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/issues/unexpected export __star__-16d066.txt similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/issues/unexpected export __star__-2e0d97.txt rename to crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/issues/unexpected export __star__-16d066.txt diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-bd2850.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-9f5c24.txt similarity index 94% rename from crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-bd2850.txt rename to crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-9f5c24.txt index f50d4f0056d24..c5c2c03563cc1 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-bd2850.txt +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-9f5c24.txt @@ -10,7 +10,8 @@ error - [resolve] [project]/crates/turbopack-tests/tests/execution/turbopack/bas 7 | 8 | function maybeReturn(x) { - unable to resolve relative "./not-existing-file" + Module not found: Can't resolve './not-existing-file' + | It was not possible to find the requested file. | Parsed request as written in source code: relative "./not-existing-file" diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-f9462b.txt similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt rename to crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-f9462b.txt diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-56db1a.txt similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt rename to crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-56db1a.txt diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-4e80a8.txt similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt rename to crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-4e80a8.txt diff --git a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-aac82c.txt b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-401f31.txt similarity index 100% rename from crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-aac82c.txt rename to crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-401f31.txt diff --git a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-f5230b.txt b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-93a8f5.txt similarity index 100% rename from crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-f5230b.txt rename to crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-93a8f5.txt diff --git a/crates/turbopack-tests/tests/snapshot/imports/json/issues/Code generation for chunk item errored-5567c6.txt b/crates/turbopack-tests/tests/snapshot/imports/json/issues/Code generation for chunk item errored-f0e9fc.txt similarity index 100% rename from crates/turbopack-tests/tests/snapshot/imports/json/issues/Code generation for chunk item errored-5567c6.txt rename to crates/turbopack-tests/tests/snapshot/imports/json/issues/Code generation for chunk item errored-f0e9fc.txt diff --git a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-5da3a2.txt b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-361fe2.txt similarity index 92% rename from crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-5da3a2.txt rename to crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-361fe2.txt index 9b90dcaac01c7..319b70f71697f 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-5da3a2.txt +++ b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-361fe2.txt @@ -6,7 +6,8 @@ error - [resolve] [project]/crates/turbopack-tests/tests/snapshot/imports/resolv 3 | console.log(dne); 4 | - unable to resolve module "does-not-exist" with subpath "/path" + Module not found: Can't resolve 'does-not-exist/path' + | It was not possible to find the requested file. | Parsed request as written in source code: module "does-not-exist" with subpath "/path" diff --git a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-c6e3fb.txt b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-09abc2.txt similarity index 92% rename from crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-c6e3fb.txt rename to crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-09abc2.txt index ed0d675e21566..1690692d803e7 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-c6e3fb.txt +++ b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-09abc2.txt @@ -7,7 +7,8 @@ error - [resolve] [project]/crates/turbopack-tests/tests/snapshot/imports/resolv 4 | console.log({}[dne]); 5 | - unable to resolve module "does-not-exist" with subpath "/path" + Module not found: Can't resolve 'does-not-exist/path' + | It was not possible to find the requested file. | Parsed request as written in source code: module "does-not-exist" with subpath "/path" diff --git a/crates/turbopack/src/lib.rs b/crates/turbopack/src/lib.rs index f3eb9bace363e..416635bdb5076 100644 --- a/crates/turbopack/src/lib.rs +++ b/crates/turbopack/src/lib.rs @@ -39,7 +39,7 @@ use turbopack_core::{ compile_time_info::CompileTimeInfo, context::AssetContext, ident::AssetIdent, - issue::{Issue, IssueExt}, + issue::{Issue, IssueExt, StyledString}, module::Module, output::OutputAsset, raw_module::RawModule, @@ -67,7 +67,7 @@ use self::{ struct ModuleIssue { ident: Vc, title: Vc, - description: Vc, + description: Vc, } #[turbo_tasks::value_impl] @@ -88,7 +88,7 @@ impl Issue for ModuleIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { + fn description(&self) -> Vc { self.description } } @@ -372,11 +372,12 @@ async fn process_default( ModuleIssue { ident, title: Vc::cell("Invalid module type".to_string()), - description: Vc::cell( + description: StyledString::Text( "The module type must be Ecmascript or Typescript to add \ Ecmascript transforms" .to_string(), - ), + ) + .cell(), } .cell() .emit(); @@ -386,11 +387,12 @@ async fn process_default( ModuleIssue { ident, title: Vc::cell("Missing module type".to_string()), - description: Vc::cell( + description: StyledString::Text( "The module type effect must be applied before adding \ Ecmascript transforms" .to_string(), - ), + ) + .cell(), } .cell() .emit(); diff --git a/crates/turbopack/src/unsupported_sass.rs b/crates/turbopack/src/unsupported_sass.rs index acf21e13a1a9f..4a9183202d7ab 100644 --- a/crates/turbopack/src/unsupported_sass.rs +++ b/crates/turbopack/src/unsupported_sass.rs @@ -4,7 +4,7 @@ use anyhow::Result; use turbo_tasks::Vc; use turbo_tasks_fs::{glob::Glob, FileSystemPath}; use turbopack_core::{ - issue::{Issue, IssueExt, IssueSeverity}, + issue::{Issue, IssueExt, IssueSeverity, StyledString}, resolve::{ parse::Request, plugin::{ResolvePlugin, ResolvePluginCondition}, @@ -86,7 +86,8 @@ impl Issue for UnsupportedSassModuleIssue { } #[turbo_tasks::function] - fn description(&self) -> Vc { - Vc::cell("Turbopack does not yet support importing Sass modules.".to_string()) + fn description(&self) -> Vc { + StyledString::Text("Turbopack does not yet support importing Sass modules.".to_string()) + .cell() } }