diff --git a/crates/turbopack-core/src/issue/analyze.rs b/crates/turbopack-core/src/issue/analyze.rs index 7d5b1e975ed0d1..9e732e2c37e3d0 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, LazyIssueSource, OptionIssueSource}; +use super::{Issue, IssueSeverity, IssueSource, OptionIssueSource}; use crate::ident::AssetIdent; #[turbo_tasks::value(shared)] @@ -13,7 +13,7 @@ pub struct AnalyzeIssue { pub message: Vc, pub category: Vc, pub code: Option, - pub source: Option>, + pub source: Option>, } #[turbo_tasks::value_impl] @@ -49,6 +49,6 @@ impl Issue for AnalyzeIssue { #[turbo_tasks::function] fn source(&self) -> Vc { - Vc::cell(self.source.map(|s| s.to_issue_source())) + Vc::cell(self.source) } } diff --git a/crates/turbopack-core/src/issue/mod.rs b/crates/turbopack-core/src/issue/mod.rs index 6c21ad227c6986..358c20682f0e44 100644 --- a/crates/turbopack-core/src/issue/mod.rs +++ b/crates/turbopack-core/src/issue/mod.rs @@ -396,65 +396,18 @@ impl CapturedIssues { } } -/// Use this to pass and store byte offsets for an AST node along with its -/// source. When row/column is needed, this can be lazily converted into a -/// proper `IssueSource` at that time using -/// [LazyIssueSource::to_issue_source]. #[turbo_tasks::value] #[derive(Clone, Debug)] -pub struct LazyIssueSource { - pub source: Vc>, - pub start_end: Option<(usize, usize)>, -} - -#[turbo_tasks::value_impl] -impl LazyIssueSource { - /// Create a [`LazyIssueSource`] from byte offsets given by an swc ast node - /// span. - /// - /// Arguments: - /// - /// * `source`: The source code in which to look up the byte offsets. - /// * `start`: The start index of the span. Must use **1-based** indexing. - /// * `end`: The end index of the span. Must use **1-based** indexing. - #[turbo_tasks::function] - pub fn from_swc_offsets(source: Vc>, start: usize, end: usize) -> Vc { - match (start == 0, end == 0) { - (true, true) => Self::cell(LazyIssueSource { - source, - start_end: None, - }), - (false, false) => Self::cell(LazyIssueSource { - source, - start_end: Some((start - 1, end - 1)), - }), - (false, true) => Self::cell(LazyIssueSource { - source, - start_end: Some((start - 1, start - 1)), - }), - (true, false) => Self::cell(LazyIssueSource { - source, - start_end: Some((end - 1, end - 1)), - }), - } - } - - #[turbo_tasks::function] - pub async fn to_issue_source(self: Vc) -> Result> { - let this = &*self.await?; - Ok(if let Some((start, end)) = this.start_end { - IssueSource::from_byte_offset(this.source, start, end) - } else { - IssueSource::from_source_only(this.source) - }) - } +pub struct IssueSource { + source: Vc>, + range: Option>, } #[turbo_tasks::value] #[derive(Clone, Debug)] -pub struct IssueSource { - source: Vc>, - range: Option<(SourcePos, SourcePos)>, +enum SourceRange { + Normal(SourcePos, SourcePos), + Lazy(usize, usize), } #[turbo_tasks::value_impl] @@ -469,6 +422,27 @@ impl IssueSource { }) } + /// Create a [`IssueSource`] from byte offsets given by an swc ast node + /// span. + /// + /// Arguments: + /// + /// * `source`: The source code in which to look up the byte offsets. + /// * `start`: The start index of the span. Must use **1-based** indexing. + /// * `end`: The end index of the span. Must use **1-based** indexing. + #[turbo_tasks::function] + pub fn from_swc_offsets(source: Vc>, start: usize, end: usize) -> Vc { + Self::cell(IssueSource { + source, + range: match (start == 0, end == 0) { + (true, true) => None, + (false, false) => Some(SourceRange::Lazy(start - 1, end - 1).cell()), + (false, true) => Some(SourceRange::Lazy(start - 1, start - 1).cell()), + (true, false) => Some(SourceRange::Lazy(end - 1, end - 1).cell()), + }, + }) + } + #[turbo_tasks::function] /// Returns an `IssueSource` representing a span of code in the `source`. /// Positions are derived from byte offsets and stored as lines and columns. @@ -486,31 +460,12 @@ impl IssueSource { start: usize, end: usize, ) -> Result> { - fn find_line_and_column(lines: &[FileLine], offset: usize) -> SourcePos { - match lines.binary_search_by(|line| line.bytes_offset.cmp(&offset)) { - Ok(i) => SourcePos { line: i, column: 0 }, - Err(i) => { - if i == 0 { - SourcePos { - line: 0, - column: offset, - } - } else { - let line = &lines[i - 1]; - SourcePos { - line: i - 1, - column: min(line.content.len(), offset - line.bytes_offset), - } - } - } - } - } Ok(Self::cell(IssueSource { source, range: if let FileLinesContent::Lines(lines) = &*source.content().lines().await? { let start = find_line_and_column(lines.as_ref(), start); let end = find_line_and_column(lines.as_ref(), end); - Some((start, end)) + Some(SourceRange::Normal(start, end).cell()) } else { None }, @@ -615,7 +570,23 @@ impl IssueSource { let this = self.await?; Ok(PlainIssueSource { asset: PlainSource::from_source(this.source).await?, - range: this.range, + range: match this.range { + Some(range) => match &*range.await? { + SourceRange::Normal(start, end) => Some((*start, *end)), + SourceRange::Lazy(start, end) => { + if let FileLinesContent::Lines(lines) = + &*this.source.content().lines().await? + { + let start = find_line_and_column(lines.as_ref(), *start); + let end = find_line_and_column(lines.as_ref(), *end); + Some((start, end)) + } else { + None + } + } + }, + _ => None, + }, } .cell()) } @@ -830,3 +801,23 @@ pub async fn handle_issues( Ok(()) } } + +fn find_line_and_column(lines: &[FileLine], offset: usize) -> SourcePos { + match lines.binary_search_by(|line| line.bytes_offset.cmp(&offset)) { + Ok(i) => SourcePos { line: i, column: 0 }, + Err(i) => { + if i == 0 { + SourcePos { + line: 0, + column: offset, + } + } else { + let line = &lines[i - 1]; + SourcePos { + line: i - 1, + column: min(line.content.len(), offset - line.bytes_offset), + } + } + } + } +} diff --git a/crates/turbopack-core/src/issue/resolve.rs b/crates/turbopack-core/src/issue/resolve.rs index b78159f82169e1..fb7f16f6610a60 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, OptionIssueSource}; +use super::{Issue, IssueSource, OptionIssueSource}; use crate::{ error::PrettyPrintError, - issue::{IssueSeverity, LazyIssueSource}, + issue::IssueSeverity, 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: Option>, + pub source: Option>, } #[turbo_tasks::value_impl] @@ -102,7 +102,7 @@ impl Issue for ResolvingIssue { #[turbo_tasks::function] fn source(&self) -> Vc { - Vc::cell(self.source.map(|s| s.to_issue_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 44d66070daf169..edf4f2472074a0 100644 --- a/crates/turbopack-core/src/resolve/mod.rs +++ b/crates/turbopack-core/src/resolve/mod.rs @@ -26,7 +26,7 @@ use self::{ }; use crate::{ file_source::FileSource, - issue::{resolve::ResolvingIssue, IssueExt, LazyIssueSource}, + issue::{resolve::ResolvingIssue, IssueExt, IssueSource}, module::{Module, Modules, OptionModule}, output::{OutputAsset, OutputAssets}, package_json::{read_package_json, PackageJsonIssue}, @@ -1931,7 +1931,7 @@ pub async fn handle_resolve_error( request: Vc, resolve_options: Vc, severity: Vc, - source: Option>, + source: Option>, ) -> Result> { Ok(match result.is_unresolveable().await { Ok(unresolveable) => { diff --git a/crates/turbopack-css/src/references/import.rs b/crates/turbopack-css/src/references/import.rs index b3340e71875b56..e8d253712246ab 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::LazyIssueSource, + issue::IssueSource, reference::ModuleReference, reference_type::CssReferenceSubType, resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult}, @@ -187,7 +187,7 @@ pub struct ImportAssetReference { pub request: Vc, pub path: Vc, pub attributes: Vc, - pub issue_source: Vc, + pub issue_source: Vc, } #[turbo_tasks::value_impl] @@ -198,7 +198,7 @@ impl ImportAssetReference { request: Vc, path: Vc, attributes: Vc, - issue_source: Vc, + issue_source: Vc, ) -> Vc { Self::cell(ImportAssetReference { origin, diff --git a/crates/turbopack-css/src/references/mod.rs b/crates/turbopack-css/src/references/mod.rs index 0c9672f3debf96..764524e5c5fb00 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, LazyIssueSource}, + issue::{IssueSeverity, IssueSource}, reference::{ModuleReference, ModuleReferences}, reference_type::{CssReferenceSubType, ReferenceType}, resolve::{ @@ -133,7 +133,7 @@ impl<'a> VisitAstPath for ModuleReferencesVisitor<'a> { Request::parse(Value::new(src.to_string().into())), Vc::cell(as_parent_path(ast_path)), ImportAttributes::new_from_prelude(i).into(), - LazyIssueSource::from_swc_offsets( + IssueSource::from_swc_offsets( Vc::upcast(self.source), issue_span.lo.to_usize(), issue_span.hi.to_usize(), @@ -160,7 +160,7 @@ impl<'a> VisitAstPath for ModuleReferencesVisitor<'a> { self.origin, Request::parse(Value::new(src.to_string().into())), Vc::cell(as_parent_path(ast_path)), - LazyIssueSource::from_swc_offsets( + IssueSource::from_swc_offsets( Vc::upcast(self.source), issue_span.lo.to_usize(), issue_span.hi.to_usize(), @@ -177,7 +177,7 @@ pub async fn css_resolve( origin: Vc>, request: Vc, ty: Value, - issue_source: Option>, + 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-css/src/references/url.rs b/crates/turbopack-css/src/references/url.rs index db471566ee7fe8..82304e7b146463 100644 --- a/crates/turbopack-css/src/references/url.rs +++ b/crates/turbopack-css/src/references/url.rs @@ -10,7 +10,7 @@ use turbopack_core::{ ChunkingTypeOption, }, ident::AssetIdent, - issue::{IssueSeverity, LazyIssueSource}, + issue::{IssueSeverity, IssueSource}, output::OutputAsset, reference::ModuleReference, reference_type::UrlReferenceSubType, @@ -37,7 +37,7 @@ pub struct UrlAssetReference { pub origin: Vc>, pub request: Vc, pub path: Vc, - pub issue_source: Vc, + pub issue_source: Vc, } #[turbo_tasks::value_impl] @@ -47,7 +47,7 @@ impl UrlAssetReference { origin: Vc>, request: Vc, path: Vc, - issue_source: Vc, + issue_source: Vc, ) -> Vc { Self::cell(UrlAssetReference { origin, diff --git a/crates/turbopack-ecmascript/src/analyzer/imports.rs b/crates/turbopack-ecmascript/src/analyzer/imports.rs index 5c852b654d88de..cdc5838a04a549 100644 --- a/crates/turbopack-ecmascript/src/analyzer/imports.rs +++ b/crates/turbopack-ecmascript/src/analyzer/imports.rs @@ -11,7 +11,7 @@ use swc_core::{ }, }; use turbo_tasks::Vc; -use turbopack_core::{issue::LazyIssueSource, source::Source}; +use turbopack_core::{issue::IssueSource, source::Source}; use super::{JsValue, ModuleValue}; use crate::utils::unparen; @@ -118,7 +118,7 @@ pub(crate) struct ImportMapReference { pub module_path: JsWord, pub imported_symbol: ImportedSymbol, pub annotations: ImportAnnotations, - pub issue_source: Option>, + pub issue_source: Option>, } impl ImportMap { @@ -196,7 +196,7 @@ impl<'a> Analyzer<'a> { ) -> usize { let issue_source = self .source - .map(|s| LazyIssueSource::from_swc_offsets(s, span.lo.to_usize(), span.hi.to_usize())); + .map(|s| IssueSource::from_swc_offsets(s, span.lo.to_usize(), span.hi.to_usize())); let r = ImportMapReference { module_path, diff --git a/crates/turbopack-ecmascript/src/references/amd.rs b/crates/turbopack-ecmascript/src/references/amd.rs index bb58f76de8f837..cd42e27a81d16c 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::LazyIssueSource, + issue::IssueSource, reference::ModuleReference, resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult}, }; @@ -34,7 +34,7 @@ use crate::{ pub struct AmdDefineAssetReference { origin: Vc>, request: Vc, - issue_source: Vc, + issue_source: Vc, in_try: bool, } @@ -44,7 +44,7 @@ impl AmdDefineAssetReference { pub fn new( origin: Vc>, request: Vc, - issue_source: Vc, + issue_source: Vc, in_try: bool, ) -> Vc { Self::cell(AmdDefineAssetReference { @@ -109,7 +109,7 @@ pub struct AmdDefineWithDependenciesCodeGen { origin: Vc>, path: Vc, factory_type: AmdDefineFactoryType, - issue_source: Vc, + issue_source: Vc, in_try: bool, } @@ -119,7 +119,7 @@ impl AmdDefineWithDependenciesCodeGen { origin: Vc>, path: Vc, factory_type: AmdDefineFactoryType, - issue_source: Vc, + issue_source: Vc, in_try: bool, ) -> Vc { Self::cell(AmdDefineWithDependenciesCodeGen { diff --git a/crates/turbopack-ecmascript/src/references/cjs.rs b/crates/turbopack-ecmascript/src/references/cjs.rs index 18bf52e575d368..555e9a769822da 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::LazyIssueSource, + issue::IssueSource, reference::ModuleReference, resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult}, }; @@ -25,7 +25,7 @@ use crate::{ pub struct CjsAssetReference { pub origin: Vc>, pub request: Vc, - pub issue_source: Vc, + pub issue_source: Vc, pub in_try: bool, } @@ -35,7 +35,7 @@ impl CjsAssetReference { pub fn new( origin: Vc>, request: Vc, - issue_source: Vc, + issue_source: Vc, in_try: bool, ) -> Vc { Self::cell(CjsAssetReference { @@ -80,7 +80,7 @@ pub struct CjsRequireAssetReference { pub origin: Vc>, pub request: Vc, pub path: Vc, - pub issue_source: Vc, + pub issue_source: Vc, pub in_try: bool, } @@ -91,7 +91,7 @@ impl CjsRequireAssetReference { origin: Vc>, request: Vc, path: Vc, - issue_source: Vc, + issue_source: Vc, in_try: bool, ) -> Vc { Self::cell(CjsRequireAssetReference { @@ -204,7 +204,7 @@ pub struct CjsRequireResolveAssetReference { pub origin: Vc>, pub request: Vc, pub path: Vc, - pub issue_source: Vc, + pub issue_source: Vc, pub in_try: bool, } @@ -215,7 +215,7 @@ impl CjsRequireResolveAssetReference { origin: Vc>, request: Vc, path: Vc, - issue_source: Vc, + issue_source: Vc, in_try: bool, ) -> Vc { Self::cell(CjsRequireResolveAssetReference { diff --git a/crates/turbopack-ecmascript/src/references/esm/base.rs b/crates/turbopack-ecmascript/src/references/esm/base.rs index ea66adb034c0c9..7d8aa29d1af7ec 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, LazyIssueSource}, + issue::{IssueSeverity, IssueSource}, module::Module, reference::ModuleReference, reference_type::EcmaScriptModulesReferenceSubType, @@ -103,7 +103,7 @@ pub struct EsmAssetReference { pub origin: Vc>, pub request: Vc, pub annotations: ImportAnnotations, - pub issue_source: Option>, + pub issue_source: Option>, pub export_name: Option>, } @@ -127,7 +127,7 @@ impl EsmAssetReference { pub fn new( origin: Vc>, request: Vc, - issue_source: Option>, + issue_source: Option>, annotations: Value, export_name: Option>, ) -> Vc { diff --git a/crates/turbopack-ecmascript/src/references/esm/dynamic.rs b/crates/turbopack-ecmascript/src/references/esm/dynamic.rs index 6f2e601c3bf7e7..c36ca0a79d4ab2 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::LazyIssueSource, + issue::IssueSource, reference::ModuleReference, reference_type::EcmaScriptModulesReferenceSubType, resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult}, @@ -27,7 +27,7 @@ pub struct EsmAsyncAssetReference { pub origin: Vc>, pub request: Vc, pub path: Vc, - pub issue_source: Vc, + pub issue_source: Vc, pub in_try: bool, } @@ -38,7 +38,7 @@ impl EsmAsyncAssetReference { origin: Vc>, request: Vc, path: Vc, - issue_source: Vc, + issue_source: Vc, in_try: bool, ) -> Vc { Self::cell(EsmAsyncAssetReference { diff --git a/crates/turbopack-ecmascript/src/references/esm/url.rs b/crates/turbopack-ecmascript/src/references/esm/url.rs index 1ebf253a5856f4..94a66a0b7e823d 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, LazyIssueSource}, + issue::{code_gen::CodeGenerationIssue, IssueExt, IssueSeverity, IssueSource}, reference::ModuleReference, reference_type::UrlReferenceSubType, resolve::{origin::ResolveOrigin, parse::Request, ModuleResolveResult}, @@ -50,7 +50,7 @@ pub struct UrlAssetReference { request: Vc, rendering: Vc, ast_path: Vc, - issue_source: Vc, + issue_source: Vc, in_try: bool, url_rewrite_behavior: Vc, } @@ -63,7 +63,7 @@ impl UrlAssetReference { request: Vc, rendering: Vc, ast_path: Vc, - issue_source: Vc, + issue_source: Vc, in_try: bool, url_rewrite_behavior: Vc, ) -> Vc { diff --git a/crates/turbopack-ecmascript/src/references/mod.rs b/crates/turbopack-ecmascript/src/references/mod.rs index 1c6144f1e98d48..facc18a34b6eb3 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, LazyIssueSource}, + issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity, IssueSource}, module::Module, reference::{ModuleReference, ModuleReferences, SourceMapReference}, reference_type::{CommonJsReferenceSubType, ReferenceType}, @@ -963,11 +963,7 @@ pub(crate) async fn analyze_ecmascript_module( Request::parse(Value::new(pat)), compile_time_info.environment().rendering(), Vc::cell(ast_path), - LazyIssueSource::from_swc_offsets( - source, - span.lo.to_usize(), - span.hi.to_usize(), - ), + IssueSource::from_swc_offsets(source, span.lo.to_usize(), span.hi.to_usize()), in_try, options .url_rewrite_behavior @@ -1764,7 +1760,7 @@ async fn handle_free_var_reference( )) }), Request::parse(Value::new(request.clone().into())), - Some(LazyIssueSource::from_swc_offsets( + Some(IssueSource::from_swc_offsets( state.source, span.lo.to_usize(), span.hi.to_usize(), @@ -1792,8 +1788,8 @@ async fn handle_free_var_reference( Ok(true) } -fn issue_source(source: Vc>, span: Span) -> Vc { - LazyIssueSource::from_swc_offsets(source, span.lo.to_usize(), span.hi.to_usize()) +fn issue_source(source: Vc>, span: Span) -> Vc { + IssueSource::from_swc_offsets(source, span.lo.to_usize(), span.hi.to_usize()) } fn analyze_amd_define( diff --git a/crates/turbopack-ecmascript/src/references/require_context.rs b/crates/turbopack-ecmascript/src/references/require_context.rs index eb8a9a5687dd1c..7c33ddb0aa256d 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, LazyIssueSource}, + 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: Option>, + 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: Option>, + pub issue_source: Option>, pub in_try: bool, } @@ -220,7 +220,7 @@ impl RequireContextAssetReference { include_subdirs: bool, filter: Vc, path: Vc, - issue_source: Option>, + 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 90567ea32b6463..9433d2a28446bd 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, LazyIssueSource}, + issue::{IssueSeverity, IssueSource}, reference_type::{ CommonJsReferenceSubType, EcmaScriptModulesReferenceSubType, ReferenceType, UrlReferenceSubType, @@ -65,7 +65,7 @@ pub async fn esm_resolve( request: Vc, ty: Value, issue_severity: Vc, - issue_source: Option>, + issue_source: Option>, ) -> Result> { let ty = Value::new(ReferenceType::EcmaScriptModules(ty.into_value())); let options = apply_esm_specific_options(origin.resolve_options(ty.clone())) @@ -78,7 +78,7 @@ pub async fn esm_resolve( pub async fn cjs_resolve( origin: Vc>, request: Vc, - issue_source: Option>, + issue_source: Option>, issue_severity: Vc, ) -> Result> { // TODO pass CommonJsReferenceSubType @@ -94,7 +94,7 @@ pub async fn url_resolve( origin: Vc>, request: Vc, ty: Value, - issue_source: Vc, + issue_source: Vc, issue_severity: Vc, ) -> Result> { let ty = Value::new(ReferenceType::Url(ty.into_value())); @@ -129,7 +129,7 @@ async fn specific_resolve( options: Vc, reference_type: Value, issue_severity: Vc, - issue_source: Option>, + issue_source: Option>, ) -> Result> { let result = origin.resolve_asset(request, options, reference_type.clone()); diff --git a/crates/turbopack-swc-utils/src/emitter.rs b/crates/turbopack-swc-utils/src/emitter.rs index ac00ec12dc8fe5..07bc7f05d4839d 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, LazyIssueSource}, + issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity, IssueSource}, source::Source, }; @@ -41,7 +41,7 @@ impl Emitter for IssueEmitter { } let source = db.span.primary_span().map(|span| { - LazyIssueSource::from_swc_offsets(self.source, span.lo.to_usize(), span.hi.to_usize()) + IssueSource::from_swc_offsets(self.source, span.lo.to_usize(), span.hi.to_usize()) }); // TODO add other primary and secondary spans with labels as sub_issues