diff --git a/crates/turbopack-cli-utils/src/runtime_entry.rs b/crates/turbopack-cli-utils/src/runtime_entry.rs index 6d4f2d03c69a6..45a120c12be9b 100644 --- a/crates/turbopack-cli-utils/src/runtime_entry.rs +++ b/crates/turbopack-cli-utils/src/runtime_entry.rs @@ -4,7 +4,7 @@ use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ chunk::{EvaluatableAsset, EvaluatableAssetExt, EvaluatableAssets}, context::AssetContext, - issue::{IssueSeverity, OptionIssueSource}, + issue::IssueSeverity, module::Module, resolve::{origin::PlainResolveOrigin, parse::Request}, source::Source, @@ -36,7 +36,7 @@ impl RuntimeEntry { let modules = cjs_resolve( Vc::upcast(PlainResolveOrigin::new(asset_context, path)), request, - OptionIssueSource::none(), + None, IssueSeverity::Error.cell(), ) .primary_modules() diff --git a/crates/turbopack-core/src/issue/mod.rs b/crates/turbopack-core/src/issue/mod.rs index 4bb8b9fddcd04..b16f5773ce468 100644 --- a/crates/turbopack-core/src/issue/mod.rs +++ b/crates/turbopack-core/src/issue/mod.rs @@ -119,7 +119,7 @@ pub trait Issue { /// should point at the offending character. Displayed to the user alongside /// the title/description. fn source(self: Vc) -> Vc { - OptionIssueSource::none() + Vc::cell(None) } fn sub_issues(self: Vc) -> Vc { @@ -449,19 +449,6 @@ impl IssueSource { #[turbo_tasks::value(transparent)] pub struct OptionIssueSource(Option>); -#[turbo_tasks::value_impl] -impl OptionIssueSource { - #[turbo_tasks::function] - pub fn some(source: Vc) -> Vc { - Vc::cell(Some(source)) - } - - #[turbo_tasks::function] - pub fn none() -> Vc { - Vc::cell(None) - } -} - #[turbo_tasks::value(serialization = "none")] #[derive(Clone, Debug)] pub struct PlainIssue { diff --git a/crates/turbopack-core/src/issue/resolve.rs b/crates/turbopack-core/src/issue/resolve.rs index 71b7404741d34..dd7bb076de171 100644 --- a/crates/turbopack-core/src/issue/resolve.rs +++ b/crates/turbopack-core/src/issue/resolve.rs @@ -4,10 +4,10 @@ use anyhow::Result; use turbo_tasks::{ValueToString, Vc}; use turbo_tasks_fs::FileSystemPath; -use super::Issue; +use super::{Issue, OptionIssueSource}; use crate::{ error::PrettyPrintError, - issue::{IssueSeverity, OptionIssueSource}, + issue::{IssueSeverity, IssueSource}, resolve::{options::ResolveOptions, parse::Request}, }; @@ -19,7 +19,7 @@ pub struct ResolvingIssue { pub file_path: Vc, pub resolve_options: Vc, pub error_message: Option, - pub source: Vc, + pub source: Option>, } #[turbo_tasks::value_impl] @@ -102,7 +102,7 @@ impl Issue for ResolvingIssue { #[turbo_tasks::function] fn source(&self) -> Vc { - self.source + Vc::cell(self.source) } // TODO add sub_issue for a description of resolve_options diff --git a/crates/turbopack-core/src/resolve/mod.rs b/crates/turbopack-core/src/resolve/mod.rs index 8b3369a4f8fc3..b80e63ef4510e 100644 --- a/crates/turbopack-core/src/resolve/mod.rs +++ b/crates/turbopack-core/src/resolve/mod.rs @@ -52,7 +52,7 @@ pub use alias_map::{ }; pub use remap::{ResolveAliasMap, SubpathValue}; -use crate::issue::{IssueSeverity, OptionIssueSource}; +use crate::issue::{IssueSeverity, IssueSource}; #[turbo_tasks::value(shared)] #[derive(Clone, Debug)] @@ -1209,7 +1209,7 @@ async fn resolve_internal( relative to the file you are importing from." .to_string(), ), - source: OptionIssueSource::none(), + source: None, } .cell() .emit(); @@ -1228,7 +1228,7 @@ async fn resolve_internal( file_path: lookup_path, resolve_options: options, error_message: Some("windows imports are not implemented yet".to_string()), - source: OptionIssueSource::none(), + source: None, } .cell() .emit(); @@ -1275,7 +1275,7 @@ async fn resolve_internal( file_path: lookup_path, resolve_options: options, error_message: None, - source: OptionIssueSource::none(), + source: None, } .cell() .emit(); @@ -1620,7 +1620,7 @@ async fn resolve_alias_field_result( request: Request::parse(Value::new(Pattern::Constant(issue_request.to_string()))), resolve_options, error_message: Some(format!("invalid alias field value: {}", result)), - source: OptionIssueSource::none(), + source: None, } .cell() .emit(); @@ -1791,7 +1791,7 @@ async fn resolve_package_internal_with_imports_field( request, resolve_options, error_message: None, - source: OptionIssueSource::none(), + source: None, } .cell() .emit(); @@ -1855,7 +1855,7 @@ pub async fn handle_resolve_error( origin_path: Vc, request: Vc, resolve_options: Vc, - source: Vc, + source: Option>, severity: Vc, ) -> Result> { Ok(match result.is_unresolveable().await { diff --git a/crates/turbopack-css/src/references/compose.rs b/crates/turbopack-css/src/references/compose.rs index 8a23bcda76a54..71ce7b71eee7a 100644 --- a/crates/turbopack-css/src/references/compose.rs +++ b/crates/turbopack-css/src/references/compose.rs @@ -2,7 +2,6 @@ use anyhow::Result; use turbo_tasks::{Value, ValueToString, Vc}; use turbopack_core::{ chunk::ChunkableModuleReference, - issue::OptionIssueSource, reference::ModuleReference, reference_type::CssReferenceSubType, resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult}, @@ -38,7 +37,7 @@ impl ModuleReference for CssModuleComposeReference { // TODO: add real issue source, currently impossible because `CssClassName` doesn't // contain the source span // https://docs.rs/swc_css_modules/0.21.16/swc_css_modules/enum.CssClassName.html - OptionIssueSource::none(), + None, ) } } diff --git a/crates/turbopack-css/src/references/import.rs b/crates/turbopack-css/src/references/import.rs index c498f6e384884..e8d253712246a 100644 --- a/crates/turbopack-css/src/references/import.rs +++ b/crates/turbopack-css/src/references/import.rs @@ -12,7 +12,7 @@ use swc_core::{ use turbo_tasks::{Value, ValueToString, Vc}; use turbopack_core::{ chunk::{ChunkableModuleReference, ChunkingContext}, - issue::{IssueSource, OptionIssueSource}, + issue::IssueSource, reference::ModuleReference, reference_type::CssReferenceSubType, resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult}, @@ -218,7 +218,7 @@ impl ModuleReference for ImportAssetReference { self.origin, self.request, Value::new(CssReferenceSubType::AtImport), - OptionIssueSource::some(self.issue_source), + Some(self.issue_source), ) } } diff --git a/crates/turbopack-css/src/references/mod.rs b/crates/turbopack-css/src/references/mod.rs index 831504b1e01c8..9e2c615d0f913 100644 --- a/crates/turbopack-css/src/references/mod.rs +++ b/crates/turbopack-css/src/references/mod.rs @@ -12,7 +12,7 @@ use swc_core::{ }; use turbo_tasks::{Value, Vc}; use turbopack_core::{ - issue::{IssueSeverity, IssueSource, OptionIssueSource}, + issue::{IssueSeverity, IssueSource}, reference::{ModuleReference, ModuleReferences}, reference_type::{CssReferenceSubType, ReferenceType}, resolve::{ @@ -177,7 +177,7 @@ pub async fn css_resolve( origin: Vc>, request: Vc, ty: Value, - issue_source: Vc, + issue_source: Option>, ) -> Result> { let ty = Value::new(ReferenceType::Css(ty.into_value())); let options = origin.resolve_options(ty.clone()); diff --git a/crates/turbopack-ecmascript/src/references/amd.rs b/crates/turbopack-ecmascript/src/references/amd.rs index 9db80c6f06110..cd42e27a81d16 100644 --- a/crates/turbopack-ecmascript/src/references/amd.rs +++ b/crates/turbopack-ecmascript/src/references/amd.rs @@ -15,7 +15,7 @@ use turbo_tasks::{ }; use turbopack_core::{ chunk::ChunkableModuleReference, - issue::{IssueSource, OptionIssueSource}, + issue::IssueSource, reference::ModuleReference, resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult}, }; @@ -63,7 +63,7 @@ impl ModuleReference for AmdDefineAssetReference { cjs_resolve( self.origin, self.request, - OptionIssueSource::some(self.issue_source), + Some(self.issue_source), try_to_severity(self.in_try), ) } @@ -156,7 +156,7 @@ impl CodeGenerateable for AmdDefineWithDependenciesCodeGen { cjs_resolve( self.origin, *request, - OptionIssueSource::some(self.issue_source), + Some(self.issue_source), try_to_severity(self.in_try), ), Value::new(Cjs), diff --git a/crates/turbopack-ecmascript/src/references/cjs.rs b/crates/turbopack-ecmascript/src/references/cjs.rs index d7c2918efa4cc..555e9a769822d 100644 --- a/crates/turbopack-ecmascript/src/references/cjs.rs +++ b/crates/turbopack-ecmascript/src/references/cjs.rs @@ -6,7 +6,7 @@ use swc_core::{ use turbo_tasks::{Value, ValueToString, Vc}; use turbopack_core::{ chunk::ChunkableModuleReference, - issue::{IssueSource, OptionIssueSource}, + issue::IssueSource, reference::ModuleReference, resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult}, }; @@ -54,7 +54,7 @@ impl ModuleReference for CjsAssetReference { cjs_resolve( self.origin, self.request, - OptionIssueSource::some(self.issue_source), + Some(self.issue_source), try_to_severity(self.in_try), ) } @@ -111,7 +111,7 @@ impl ModuleReference for CjsRequireAssetReference { cjs_resolve( self.origin, self.request, - OptionIssueSource::some(self.issue_source), + Some(self.issue_source), try_to_severity(self.in_try), ) } @@ -145,7 +145,7 @@ impl CodeGenerateable for CjsRequireAssetReference { cjs_resolve( self.origin, self.request, - OptionIssueSource::some(self.issue_source), + Some(self.issue_source), try_to_severity(self.in_try), ), Value::new(Cjs), @@ -235,7 +235,7 @@ impl ModuleReference for CjsRequireResolveAssetReference { cjs_resolve( self.origin, self.request, - OptionIssueSource::some(self.issue_source), + Some(self.issue_source), try_to_severity(self.in_try), ) } @@ -269,7 +269,7 @@ impl CodeGenerateable for CjsRequireResolveAssetReference { cjs_resolve( self.origin, self.request, - OptionIssueSource::some(self.issue_source), + Some(self.issue_source), try_to_severity(self.in_try), ), Value::new(Cjs), diff --git a/crates/turbopack-ecmascript/src/references/esm/base.rs b/crates/turbopack-ecmascript/src/references/esm/base.rs index 8103344cf190c..7fa82cd5427a0 100644 --- a/crates/turbopack-ecmascript/src/references/esm/base.rs +++ b/crates/turbopack-ecmascript/src/references/esm/base.rs @@ -11,7 +11,7 @@ use turbopack_core::{ ChunkItemExt, ChunkableModule, ChunkableModuleReference, ChunkingContext, ChunkingType, ChunkingTypeOption, ModuleId, }, - issue::{IssueSeverity, OptionIssueSource}, + issue::IssueSeverity, module::Module, reference::ModuleReference, reference_type::EcmaScriptModulesReferenceSubType, @@ -162,7 +162,7 @@ impl ModuleReference for EsmAssetReference { self.get_origin().resolve().await?, self.request, ty, - OptionIssueSource::none(), + None, IssueSeverity::Error.cell(), )) } diff --git a/crates/turbopack-ecmascript/src/references/esm/dynamic.rs b/crates/turbopack-ecmascript/src/references/esm/dynamic.rs index a497fdaa6a8e7..3eb0939816d01 100644 --- a/crates/turbopack-ecmascript/src/references/esm/dynamic.rs +++ b/crates/turbopack-ecmascript/src/references/esm/dynamic.rs @@ -6,7 +6,7 @@ use swc_core::{ use turbo_tasks::{Value, ValueToString, Vc}; use turbopack_core::{ chunk::{ChunkableModuleReference, ChunkingType, ChunkingTypeOption}, - issue::{IssueSource, OptionIssueSource}, + issue::IssueSource, reference::ModuleReference, reference_type::EcmaScriptModulesReferenceSubType, resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult}, @@ -59,7 +59,7 @@ impl ModuleReference for EsmAsyncAssetReference { self.origin, self.request, Default::default(), - OptionIssueSource::some(self.issue_source), + Some(self.issue_source), try_to_severity(self.in_try), ) } @@ -99,7 +99,7 @@ impl CodeGenerateable for EsmAsyncAssetReference { self.origin, self.request, Value::new(EcmaScriptModulesReferenceSubType::Undefined), - OptionIssueSource::some(self.issue_source).resolve().await?, + Some(self.issue_source), try_to_severity(self.in_try), ), Value::new(EsmAsync), diff --git a/crates/turbopack-ecmascript/src/references/mod.rs b/crates/turbopack-ecmascript/src/references/mod.rs index a6c3d1f66eba7..e3a4eda4bafaa 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, OptionIssueSource}, + issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity, IssueSource}, module::Module, reference::{ModuleReference, ModuleReferences, SourceMapReference}, reference_type::{CommonJsReferenceSubType, ReferenceType}, @@ -1190,7 +1190,7 @@ async fn handle_call) + Send + Sync>( options.include_subdirs, Vc::cell(options.filter), Vc::cell(ast_path.to_vec()), - OptionIssueSource::some(issue_source(source, span)), + Some(issue_source(source, span)), in_try, )); } @@ -2100,12 +2100,7 @@ async fn require_resolve_visitor( Ok(if args.len() == 1 { let pat = js_value_to_pattern(&args[0]); let request = Request::parse(Value::new(pat.clone())); - let resolved = cjs_resolve( - origin, - request, - OptionIssueSource::none(), - try_to_severity(in_try), - ); + let resolved = cjs_resolve(origin, request, None, try_to_severity(in_try)); let mut values = resolved .primary_modules() .await? @@ -2167,7 +2162,7 @@ async fn require_context_visitor( dir, options.include_subdirs, Vc::cell(options.filter), - OptionIssueSource::none(), + None, try_to_severity(in_try), ); diff --git a/crates/turbopack-ecmascript/src/references/require_context.rs b/crates/turbopack-ecmascript/src/references/require_context.rs index d26d6ce56c0ef..7c33ddb0aa256 100644 --- a/crates/turbopack-ecmascript/src/references/require_context.rs +++ b/crates/turbopack-ecmascript/src/references/require_context.rs @@ -22,7 +22,7 @@ use turbopack_core::{ ChunkingContext, }, ident::AssetIdent, - issue::{IssueSeverity, OptionIssueSource}, + issue::{IssueSeverity, IssueSource}, module::Module, reference::{ModuleReference, ModuleReferences}, resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult}, @@ -165,7 +165,7 @@ impl RequireContextMap { dir: Vc, recursive: bool, filter: Vc, - issue_source: Vc, + issue_source: Option>, issue_severity: Vc, ) -> Result> { let origin_path = &*origin.origin_path().parent().await?; @@ -206,7 +206,7 @@ pub struct RequireContextAssetReference { pub include_subdirs: bool, pub path: Vc, - pub issue_source: Vc, + pub issue_source: Option>, pub in_try: bool, } @@ -220,7 +220,7 @@ impl RequireContextAssetReference { include_subdirs: bool, filter: Vc, path: Vc, - issue_source: Vc, + issue_source: Option>, in_try: bool, ) -> Vc { let map = RequireContextMap::generate( diff --git a/crates/turbopack-ecmascript/src/resolve/mod.rs b/crates/turbopack-ecmascript/src/resolve/mod.rs index 625e0abe617f7..9a5dc2b057349 100644 --- a/crates/turbopack-ecmascript/src/resolve/mod.rs +++ b/crates/turbopack-ecmascript/src/resolve/mod.rs @@ -4,7 +4,7 @@ use anyhow::Result; use turbo_tasks::{Value, Vc}; use turbopack_core::{ context::AssetContext, - issue::{IssueSeverity, IssueSource, OptionIssueSource}, + issue::{IssueSeverity, IssueSource}, reference_type::{ CommonJsReferenceSubType, EcmaScriptModulesReferenceSubType, ReferenceType, UrlReferenceSubType, @@ -64,7 +64,7 @@ pub async fn esm_resolve( origin: Vc>, request: Vc, ty: Value, - issue_source: Vc, + issue_source: Option>, issue_severity: Vc, ) -> Result> { let ty = Value::new(ReferenceType::EcmaScriptModules(ty.into_value())); @@ -76,7 +76,7 @@ pub async fn esm_resolve( pub async fn cjs_resolve( origin: Vc>, request: Vc, - issue_source: Vc, + issue_source: Option>, issue_severity: Vc, ) -> Result> { // TODO pass CommonJsReferenceSubType @@ -113,7 +113,7 @@ pub async fn url_resolve( origin.origin_path(), request, resolve_options, - OptionIssueSource::some(issue_source), + Some(issue_source), issue_severity, ) .await @@ -124,7 +124,7 @@ async fn specific_resolve( request: Vc, options: Vc, reference_type: Value, - issue_source: Vc, + issue_source: Option>, issue_severity: Vc, ) -> Result> { let result = origin.resolve_asset(request, options, reference_type.clone()); diff --git a/crates/turbopack-ecmascript/src/typescript/mod.rs b/crates/turbopack-ecmascript/src/typescript/mod.rs index 6c225f17ceeb4..44fd2f7550d07 100644 --- a/crates/turbopack-ecmascript/src/typescript/mod.rs +++ b/crates/turbopack-ecmascript/src/typescript/mod.rs @@ -7,7 +7,7 @@ use turbo_tasks_fs::DirectoryContent; use turbopack_core::{ asset::{Asset, AssetContent}, ident::AssetIdent, - issue::{IssueSeverity, OptionIssueSource}, + issue::IssueSeverity, module::Module, raw_module::RawModule, reference::{ModuleReference, ModuleReferences}, @@ -180,12 +180,7 @@ impl CompilerReference { impl ModuleReference for CompilerReference { #[turbo_tasks::function] fn resolve_reference(&self) -> Vc { - cjs_resolve( - self.origin, - self.request, - OptionIssueSource::none(), - IssueSeverity::Error.cell(), - ) + cjs_resolve(self.origin, self.request, None, IssueSeverity::Error.cell()) } } @@ -252,12 +247,7 @@ impl TsNodeRequireReference { impl ModuleReference for TsNodeRequireReference { #[turbo_tasks::function] fn resolve_reference(&self) -> Vc { - cjs_resolve( - self.origin, - self.request, - OptionIssueSource::none(), - IssueSeverity::Error.cell(), - ) + cjs_resolve(self.origin, self.request, None, IssueSeverity::Error.cell()) } } diff --git a/crates/turbopack-ecmascript/src/typescript/resolve.rs b/crates/turbopack-ecmascript/src/typescript/resolve.rs index 17f755b550cc3..4e6c4cffc42c1 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, OptionIssueSource}, + issue::{Issue, IssueExt, IssueSeverity}, reference::ModuleReference, reference_type::{ReferenceType, TypeScriptReferenceSubType}, resolve::{ @@ -372,7 +372,7 @@ pub async fn type_resolve( origin.origin_path(), request, options, - OptionIssueSource::none(), + None, IssueSeverity::Error.cell(), ) .await