Unverified Commit a50782c7 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: make IssueSource a TaskInput (#75542)

Meaning fewer cells and fewer tasks

No measureable perf difference
parent d70cac3e
...@@ -289,7 +289,7 @@ impl From<&PlainIssue> for NapiIssue { ...@@ -289,7 +289,7 @@ impl From<&PlainIssue> for NapiIssue {
.map(|styled| serde_json::to_value(StyledStringSerialize::from(styled)).unwrap()), .map(|styled| serde_json::to_value(StyledStringSerialize::from(styled)).unwrap()),
documentation_link: issue.documentation_link.to_string(), documentation_link: issue.documentation_link.to_string(),
severity: issue.severity.as_str().to_string(), severity: issue.severity.as_str().to_string(),
source: issue.source.as_deref().map(|source| source.into()), source: issue.source.as_ref().map(|source| source.into()),
title: serde_json::to_value(StyledStringSerialize::from(&issue.title)).unwrap(), title: serde_json::to_value(StyledStringSerialize::from(&issue.title)).unwrap(),
sub_issues: issue sub_issues: issue
.sub_issues .sub_issues
......
...@@ -177,7 +177,7 @@ impl NextSegmentConfig { ...@@ -177,7 +177,7 @@ impl NextSegmentConfig {
pub struct NextSegmentConfigParsingIssue { pub struct NextSegmentConfigParsingIssue {
ident: ResolvedVc<AssetIdent>, ident: ResolvedVc<AssetIdent>,
detail: ResolvedVc<StyledString>, detail: ResolvedVc<StyledString>,
source: ResolvedVc<IssueSource>, source: IssueSource,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -186,7 +186,7 @@ impl NextSegmentConfigParsingIssue { ...@@ -186,7 +186,7 @@ impl NextSegmentConfigParsingIssue {
pub fn new( pub fn new(
ident: ResolvedVc<AssetIdent>, ident: ResolvedVc<AssetIdent>,
detail: ResolvedVc<StyledString>, detail: ResolvedVc<StyledString>,
source: ResolvedVc<IssueSource>, source: IssueSource,
) -> Vc<Self> { ) -> Vc<Self> {
Self { Self {
ident, ident,
...@@ -249,15 +249,15 @@ impl Issue for NextSegmentConfigParsingIssue { ...@@ -249,15 +249,15 @@ impl Issue for NextSegmentConfigParsingIssue {
Ok(Vc::cell(Some( Ok(Vc::cell(Some(
self.source self.source
.resolve_source_map(self.ident.path()) .resolve_source_map(self.ident.path())
.to_resolved() .await?
.await?, .into_owned(),
))) )))
} }
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn parse_segment_config_from_source( pub async fn parse_segment_config_from_source(
source: Vc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
) -> Result<Vc<NextSegmentConfig>> { ) -> Result<Vc<NextSegmentConfig>> {
let path = source.ident().path().await?; let path = source.ident().path().await?;
...@@ -273,7 +273,7 @@ pub async fn parse_segment_config_from_source( ...@@ -273,7 +273,7 @@ pub async fn parse_segment_config_from_source(
} }
let result = &*parse( let result = &*parse(
source, *source,
turbo_tasks::Value::new(if path.path.ends_with(".ts") { turbo_tasks::Value::new(if path.path.ends_with(".ts") {
EcmascriptModuleAssetType::Typescript { EcmascriptModuleAssetType::Typescript {
tsx: false, tsx: false,
...@@ -348,12 +348,12 @@ pub async fn parse_segment_config_from_source( ...@@ -348,12 +348,12 @@ pub async fn parse_segment_config_from_source(
Ok(config.cell()) Ok(config.cell())
} }
fn issue_source(source: Vc<Box<dyn Source>>, span: Span) -> Vc<IssueSource> { fn issue_source(source: ResolvedVc<Box<dyn Source>>, span: Span) -> IssueSource {
IssueSource::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())
} }
async fn parse_config_value( async fn parse_config_value(
source: Vc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
config: &mut NextSegmentConfig, config: &mut NextSegmentConfig,
ident: &Ident, ident: &Ident,
init: &Expr, init: &Expr,
...@@ -361,7 +361,7 @@ async fn parse_config_value( ...@@ -361,7 +361,7 @@ async fn parse_config_value(
) -> Result<()> { ) -> Result<()> {
let span = init.span(); let span = init.span();
async fn invalid_config( async fn invalid_config(
source: Vc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
span: Span, span: Span,
detail: &str, detail: &str,
value: &JsValue, value: &JsValue,
......
...@@ -16,7 +16,7 @@ pub struct AnalyzeIssue { ...@@ -16,7 +16,7 @@ pub struct AnalyzeIssue {
pub title: ResolvedVc<RcStr>, pub title: ResolvedVc<RcStr>,
pub message: ResolvedVc<StyledString>, pub message: ResolvedVc<StyledString>,
pub code: Option<RcStr>, pub code: Option<RcStr>,
pub source: Option<ResolvedVc<IssueSource>>, pub source: Option<IssueSource>,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -28,7 +28,7 @@ impl AnalyzeIssue { ...@@ -28,7 +28,7 @@ impl AnalyzeIssue {
title: ResolvedVc<RcStr>, title: ResolvedVc<RcStr>,
message: ResolvedVc<StyledString>, message: ResolvedVc<StyledString>,
code: Option<RcStr>, code: Option<RcStr>,
source: Option<ResolvedVc<IssueSource>>, source: Option<IssueSource>,
) -> Vc<Self> { ) -> Vc<Self> {
Self { Self {
severity, severity,
...@@ -81,12 +81,12 @@ impl Issue for AnalyzeIssue { ...@@ -81,12 +81,12 @@ impl Issue for AnalyzeIssue {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn source(&self) -> Result<Vc<OptionIssueSource>> { async fn source(&self) -> Result<Vc<OptionIssueSource>> {
Ok(Vc::cell(match self.source { Ok(Vc::cell(match &self.source {
Some(source) => Some( Some(source) => Some(
source source
.resolve_source_map(self.source_ident.path()) .resolve_source_map(self.source_ident.path())
.to_resolved() .await?
.await?, .into_owned(),
), ),
None => None, None => None,
})) }))
......
...@@ -4,6 +4,7 @@ pub mod module; ...@@ -4,6 +4,7 @@ pub mod module;
pub mod resolve; pub mod resolve;
use std::{ use std::{
borrow::Cow,
cmp::{min, Ordering}, cmp::{min, Ordering},
fmt::{Display, Formatter}, fmt::{Display, Formatter},
}; };
...@@ -11,11 +12,12 @@ use std::{ ...@@ -11,11 +12,12 @@ use std::{
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use async_trait::async_trait; use async_trait::async_trait;
use auto_hash_map::AutoSet; use auto_hash_map::AutoSet;
use serde::Serialize; use serde::{Deserialize, Serialize};
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{ use turbo_tasks::{
emit, CollectiblesSource, OperationVc, RawVc, ReadRef, ResolvedVc, TransientInstance, emit, trace::TraceRawVcs, CollectiblesSource, NonLocalValue, OperationVc, RawVc, ReadRef,
TransientValue, TryJoinIterExt, Upcast, ValueToString, Vc, ResolvedVc, TaskInput, TransientInstance, TransientValue, TryJoinIterExt, Upcast,
ValueToString, Vc,
}; };
use turbo_tasks_fs::{FileContent, FileLine, FileLinesContent, FileSystemPath}; use turbo_tasks_fs::{FileContent, FileLine, FileLinesContent, FileSystemPath};
use turbo_tasks_hash::{DeterministicHash, Xxh3Hash64Hasher}; use turbo_tasks_hash::{DeterministicHash, Xxh3Hash64Hasher};
...@@ -172,7 +174,7 @@ pub trait Issue { ...@@ -172,7 +174,7 @@ pub trait Issue {
detail, detail,
documentation_link: self.documentation_link().await?.clone_value(), documentation_link: self.documentation_link().await?.clone_value(),
source: { source: {
if let Some(s) = *self.source().await? { if let Some(s) = &*self.source().await? {
Some(s.into_plain().await?) Some(s.into_plain().await?)
} else { } else {
None None
...@@ -435,79 +437,71 @@ impl CapturedIssues { ...@@ -435,79 +437,71 @@ impl CapturedIssues {
} }
} }
#[turbo_tasks::value] #[derive(
#[derive(Clone, Debug)] Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash, TaskInput, TraceRawVcs, NonLocalValue,
)]
pub struct IssueSource { pub struct IssueSource {
source: ResolvedVc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
range: Option<ResolvedVc<SourceRange>>, range: Option<SourceRange>,
} }
/// The end position is the first character after the range /// The end position is the first character after the range
#[turbo_tasks::value] #[derive(
#[derive(Clone, Debug)] Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash, TaskInput, TraceRawVcs, NonLocalValue,
)]
enum SourceRange { enum SourceRange {
LineColumn(SourcePos, SourcePos), LineColumn(SourcePos, SourcePos),
ByteOffset(usize, usize), ByteOffset(usize, usize),
} }
#[turbo_tasks::value_impl]
impl IssueSource { impl IssueSource {
// Sometimes we only have the source file that causes an issue, not the // Sometimes we only have the source file that causes an issue, not the
// exact location, such as as in some generated code. // exact location, such as as in some generated code.
#[turbo_tasks::function] pub fn from_source_only(source: ResolvedVc<Box<dyn Source>>) -> Self {
pub fn from_source_only(source: ResolvedVc<Box<dyn Source>>) -> Vc<Self> { IssueSource {
Self::cell(IssueSource {
source, source,
range: None, range: None,
}) }
} }
#[turbo_tasks::function]
pub fn from_line_col( pub fn from_line_col(
source: ResolvedVc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
start: SourcePos, start: SourcePos,
end: SourcePos, end: SourcePos,
) -> Vc<Self> { ) -> Self {
Self::cell(IssueSource { IssueSource {
source, source,
range: Some(SourceRange::LineColumn(start, end).resolved_cell()), range: Some(SourceRange::LineColumn(start, end)),
}) }
} }
#[turbo_tasks::function] pub async fn resolve_source_map(&self, origin: Vc<FileSystemPath>) -> Result<Cow<'_, Self>> {
pub async fn resolve_source_map( if let Some(range) = &self.range {
self: Vc<Self>, let (start, end) = match range {
origin: Vc<FileSystemPath>,
) -> Result<Vc<Self>> {
let this = self.await?;
if let Some(range) = this.range {
let (start, end) = match &*range.await? {
SourceRange::LineColumn(start, end) => (*start, *end), SourceRange::LineColumn(start, end) => (*start, *end),
SourceRange::ByteOffset(start, end) => { SourceRange::ByteOffset(start, end) => {
if let FileLinesContent::Lines(lines) = &*this.source.content().lines().await? { if let FileLinesContent::Lines(lines) = &*self.source.content().lines().await? {
let start = find_line_and_column(lines.as_ref(), *start); let start = find_line_and_column(lines.as_ref(), *start);
let end = find_line_and_column(lines.as_ref(), *end); let end = find_line_and_column(lines.as_ref(), *end);
(start, end) (start, end)
} else { } else {
return Ok(self); return Ok(Cow::Borrowed(self));
} }
} }
}; };
// If we have a source map, map the line/column to the original source. // If we have a source map, map the line/column to the original source.
let mapped = source_pos(this.source, origin, start, end).await?; let mapped = source_pos(self.source, origin, start, end).await?;
if let Some((source, start, end)) = mapped { if let Some((source, start, end)) = mapped {
return Ok(Self::cell(IssueSource { return Ok(Cow::Owned(IssueSource {
source, source,
range: Some(SourceRange::LineColumn(start, end).resolved_cell()), range: Some(SourceRange::LineColumn(start, end)),
})); }));
} }
} }
Ok(self) Ok(Cow::Borrowed(self))
} }
/// Create a [`IssueSource`] from byte offsets given by an swc ast node /// Create a [`IssueSource`] from byte offsets given by an swc ast node
...@@ -518,26 +512,18 @@ impl IssueSource { ...@@ -518,26 +512,18 @@ impl IssueSource {
/// * `source`: The source code in which to look up the byte offsets. /// * `source`: The source code in which to look up the byte offsets.
/// * `start`: The start index of the span. Must use **1-based** indexing. /// * `start`: The start index of the span. Must use **1-based** indexing.
/// * `end`: The end 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: ResolvedVc<Box<dyn Source>>, start: usize, end: usize) -> Self {
pub fn from_swc_offsets( IssueSource {
source: ResolvedVc<Box<dyn Source>>,
start: usize,
end: usize,
) -> Vc<Self> {
Self::cell(IssueSource {
source, source,
range: match (start == 0, end == 0) { range: match (start == 0, end == 0) {
(true, true) => None, (true, true) => None,
(false, false) => Some(SourceRange::ByteOffset(start - 1, end - 1).resolved_cell()), (false, false) => Some(SourceRange::ByteOffset(start - 1, end - 1)),
(false, true) => { (false, true) => Some(SourceRange::ByteOffset(start - 1, start - 1)),
Some(SourceRange::ByteOffset(start - 1, start - 1).resolved_cell()) (true, false) => Some(SourceRange::ByteOffset(end - 1, end - 1)),
}
(true, false) => Some(SourceRange::ByteOffset(end - 1, end - 1).resolved_cell()),
}, },
}) }
} }
#[turbo_tasks::function]
/// Returns an `IssueSource` representing a span of code in the `source`. /// Returns an `IssueSource` representing a span of code in the `source`.
/// Positions are derived from byte offsets and stored as lines and columns. /// Positions are derived from byte offsets and stored as lines and columns.
/// Requires a binary search of the source text to perform this. /// Requires a binary search of the source text to perform this.
...@@ -551,21 +537,20 @@ impl IssueSource { ...@@ -551,21 +537,20 @@ impl IssueSource {
source: ResolvedVc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
start: usize, start: usize,
end: usize, end: usize,
) -> Result<Vc<Self>> { ) -> Result<Self> {
Ok(Self::cell(IssueSource { Ok(IssueSource {
source, source,
range: if let FileLinesContent::Lines(lines) = &*source.content().lines().await? { range: if let FileLinesContent::Lines(lines) = &*source.content().lines().await? {
let start = find_line_and_column(lines.as_ref(), start); let start = find_line_and_column(lines.as_ref(), start);
let end = find_line_and_column(lines.as_ref(), end); let end = find_line_and_column(lines.as_ref(), end);
Some(SourceRange::LineColumn(start, end).resolved_cell()) Some(SourceRange::LineColumn(start, end))
} else { } else {
None None
}, },
})) })
} }
/// Returns the file path for the source file. /// Returns the file path for the source file.
#[turbo_tasks::function]
pub fn file_path(&self) -> Vc<FileSystemPath> { pub fn file_path(&self) -> Vc<FileSystemPath> {
self.source.ident().path() self.source.ident().path()
} }
...@@ -574,8 +559,8 @@ impl IssueSource { ...@@ -574,8 +559,8 @@ impl IssueSource {
impl IssueSource { impl IssueSource {
/// Returns bytes offsets corresponding the source range in the format used by swc's Spans. /// Returns bytes offsets corresponding the source range in the format used by swc's Spans.
pub async fn to_swc_offsets(&self) -> Result<Option<(usize, usize)>> { pub async fn to_swc_offsets(&self) -> Result<Option<(usize, usize)>> {
Ok(match self.range { Ok(match &self.range {
Some(range) => match &*range.await? { Some(range) => match range {
SourceRange::ByteOffset(start, end) => Some((*start + 1, *end + 1)), SourceRange::ByteOffset(start, end) => Some((*start + 1, *end + 1)),
SourceRange::LineColumn(start, end) => { SourceRange::LineColumn(start, end) => {
if let FileLinesContent::Lines(lines) = &*self.source.content().lines().await? { if let FileLinesContent::Lines(lines) = &*self.source.content().lines().await? {
...@@ -647,7 +632,7 @@ async fn source_pos( ...@@ -647,7 +632,7 @@ async fn source_pos(
} }
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
pub struct OptionIssueSource(Option<ResolvedVc<IssueSource>>); pub struct OptionIssueSource(Option<IssueSource>);
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
pub struct OptionStyledString(Option<ResolvedVc<StyledString>>); pub struct OptionStyledString(Option<ResolvedVc<StyledString>>);
...@@ -707,7 +692,7 @@ pub struct PlainIssue { ...@@ -707,7 +692,7 @@ pub struct PlainIssue {
pub detail: Option<StyledString>, pub detail: Option<StyledString>,
pub documentation_link: RcStr, pub documentation_link: RcStr,
pub source: Option<ReadRef<PlainIssueSource>>, pub source: Option<PlainIssueSource>,
pub sub_issues: Vec<ReadRef<PlainIssue>>, pub sub_issues: Vec<ReadRef<PlainIssue>>,
pub processing_path: ReadRef<PlainIssueProcessingPath>, pub processing_path: ReadRef<PlainIssueProcessingPath>,
} }
...@@ -779,14 +764,12 @@ pub struct PlainIssueSource { ...@@ -779,14 +764,12 @@ pub struct PlainIssueSource {
pub range: Option<(SourcePos, SourcePos)>, pub range: Option<(SourcePos, SourcePos)>,
} }
#[turbo_tasks::value_impl]
impl IssueSource { impl IssueSource {
#[turbo_tasks::function] pub async fn into_plain(&self) -> Result<PlainIssueSource> {
pub async fn into_plain(&self) -> Result<Vc<PlainIssueSource>> {
Ok(PlainIssueSource { Ok(PlainIssueSource {
asset: PlainSource::from_source(*self.source).await?, asset: PlainSource::from_source(*self.source).await?,
range: match self.range { range: match &self.range {
Some(range) => match &*range.await? { Some(range) => match range {
SourceRange::LineColumn(start, end) => Some((*start, *end)), SourceRange::LineColumn(start, end) => Some((*start, *end)),
SourceRange::ByteOffset(start, end) => { SourceRange::ByteOffset(start, end) => {
if let FileLinesContent::Lines(lines) = if let FileLinesContent::Lines(lines) =
...@@ -802,8 +785,7 @@ impl IssueSource { ...@@ -802,8 +785,7 @@ impl IssueSource {
}, },
_ => None, _ => None,
}, },
} })
.cell())
} }
} }
......
...@@ -23,7 +23,7 @@ pub struct ResolvingIssue { ...@@ -23,7 +23,7 @@ pub struct ResolvingIssue {
pub file_path: ResolvedVc<FileSystemPath>, pub file_path: ResolvedVc<FileSystemPath>,
pub resolve_options: ResolvedVc<ResolveOptions>, pub resolve_options: ResolvedVc<ResolveOptions>,
pub error_message: Option<String>, pub error_message: Option<String>,
pub source: Option<ResolvedVc<IssueSource>>, pub source: Option<IssueSource>,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -122,12 +122,12 @@ impl Issue for ResolvingIssue { ...@@ -122,12 +122,12 @@ impl Issue for ResolvingIssue {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn source(&self) -> Result<Vc<OptionIssueSource>> { async fn source(&self) -> Result<Vc<OptionIssueSource>> {
Ok(Vc::cell(match self.source { Ok(Vc::cell(match &self.source {
Some(source) => Some( Some(source) => Some(
source source
.resolve_source_map(*self.file_path) .resolve_source_map(*self.file_path)
.to_resolved() .await?
.await?, .into_owned(),
), ),
None => None, None => None,
})) }))
......
...@@ -12,8 +12,8 @@ use serde::{Deserialize, Serialize}; ...@@ -12,8 +12,8 @@ use serde::{Deserialize, Serialize};
use tracing::{Instrument, Level}; use tracing::{Instrument, Level};
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{ use turbo_tasks::{
fxindexmap, trace::TraceRawVcs, FxIndexMap, FxIndexSet, NonLocalValue, OptionVcExt, ResolvedVc, fxindexmap, trace::TraceRawVcs, FxIndexMap, FxIndexSet, NonLocalValue, ResolvedVc, TaskInput,
TaskInput, TryJoinIterExt, Value, ValueToString, Vc, TryJoinIterExt, Value, ValueToString, Vc,
}; };
use turbo_tasks_fs::{ use turbo_tasks_fs::{
util::normalize_request, FileSystemEntryType, FileSystemPath, RealPathResult, util::normalize_request, FileSystemEntryType, FileSystemPath, RealPathResult,
...@@ -1540,7 +1540,7 @@ pub async fn url_resolve( ...@@ -1540,7 +1540,7 @@ pub async fn url_resolve(
origin: Vc<Box<dyn ResolveOrigin>>, origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>, request: Vc<Request>,
reference_type: Value<ReferenceType>, reference_type: Value<ReferenceType>,
issue_source: Option<Vc<IssueSource>>, issue_source: Option<IssueSource>,
is_optional: bool, is_optional: bool,
) -> Result<Vc<ModuleResolveResult>> { ) -> Result<Vc<ModuleResolveResult>> {
let resolve_options = origin.resolve_options(reference_type.clone()); let resolve_options = origin.resolve_options(reference_type.clone());
...@@ -2905,7 +2905,7 @@ pub async fn handle_resolve_error( ...@@ -2905,7 +2905,7 @@ pub async fn handle_resolve_error(
request: Vc<Request>, request: Vc<Request>,
resolve_options: Vc<ResolveOptions>, resolve_options: Vc<ResolveOptions>,
is_optional: bool, is_optional: bool,
source: Option<Vc<IssueSource>>, source: Option<IssueSource>,
) -> Result<Vc<ModuleResolveResult>> { ) -> Result<Vc<ModuleResolveResult>> {
async fn is_unresolvable(result: Vc<ModuleResolveResult>) -> Result<bool> { async fn is_unresolvable(result: Vc<ModuleResolveResult>) -> Result<bool> {
Ok(*result.resolve().await?.is_unresolvable().await?) Ok(*result.resolve().await?.is_unresolvable().await?)
...@@ -2949,7 +2949,7 @@ pub async fn handle_resolve_source_error( ...@@ -2949,7 +2949,7 @@ pub async fn handle_resolve_source_error(
request: Vc<Request>, request: Vc<Request>,
resolve_options: Vc<ResolveOptions>, resolve_options: Vc<ResolveOptions>,
is_optional: bool, is_optional: bool,
source: Option<Vc<IssueSource>>, source: Option<IssueSource>,
) -> Result<Vc<ResolveResult>> { ) -> Result<Vc<ResolveResult>> {
async fn is_unresolvable(result: Vc<ResolveResult>) -> Result<bool> { async fn is_unresolvable(result: Vc<ResolveResult>) -> Result<bool> {
Ok(*result.resolve().await?.is_unresolvable().await?) Ok(*result.resolve().await?.is_unresolvable().await?)
...@@ -2993,7 +2993,7 @@ async fn emit_resolve_error_issue( ...@@ -2993,7 +2993,7 @@ async fn emit_resolve_error_issue(
request: Vc<Request>, request: Vc<Request>,
resolve_options: Vc<ResolveOptions>, resolve_options: Vc<ResolveOptions>,
err: anyhow::Error, err: anyhow::Error,
source: Option<Vc<IssueSource>>, source: Option<IssueSource>,
) -> Result<()> { ) -> Result<()> {
let severity = if is_optional || resolve_options.await?.loose_errors { let severity = if is_optional || resolve_options.await?.loose_errors {
IssueSeverity::Warning.resolved_cell() IssueSeverity::Warning.resolved_cell()
...@@ -3007,7 +3007,7 @@ async fn emit_resolve_error_issue( ...@@ -3007,7 +3007,7 @@ async fn emit_resolve_error_issue(
request: request.to_resolved().await?, request: request.to_resolved().await?,
resolve_options: resolve_options.to_resolved().await?, resolve_options: resolve_options.to_resolved().await?,
error_message: Some(format!("{}", PrettyPrintError(&err))), error_message: Some(format!("{}", PrettyPrintError(&err))),
source: source.to_resolved().await?, source,
} }
.resolved_cell() .resolved_cell()
.emit(); .emit();
...@@ -3020,7 +3020,7 @@ async fn emit_unresolvable_issue( ...@@ -3020,7 +3020,7 @@ async fn emit_unresolvable_issue(
reference_type: Value<ReferenceType>, reference_type: Value<ReferenceType>,
request: Vc<Request>, request: Vc<Request>,
resolve_options: Vc<ResolveOptions>, resolve_options: Vc<ResolveOptions>,
source: Option<Vc<IssueSource>>, source: Option<IssueSource>,
) -> Result<()> { ) -> Result<()> {
let severity = if is_optional || resolve_options.await?.loose_errors { let severity = if is_optional || resolve_options.await?.loose_errors {
IssueSeverity::Warning.resolved_cell() IssueSeverity::Warning.resolved_cell()
...@@ -3034,7 +3034,7 @@ async fn emit_unresolvable_issue( ...@@ -3034,7 +3034,7 @@ async fn emit_unresolvable_issue(
request: request.to_resolved().await?, request: request.to_resolved().await?,
resolve_options: resolve_options.to_resolved().await?, resolve_options: resolve_options.to_resolved().await?,
error_message: None, error_message: None,
source: source.to_resolved().await?, source,
} }
.resolved_cell() .resolved_cell()
.emit(); .emit();
......
...@@ -294,7 +294,7 @@ pub trait ProcessCss: ParseCss { ...@@ -294,7 +294,7 @@ pub trait ProcessCss: ParseCss {
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn parse_css( pub async fn parse_css(
source: Vc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
origin: Vc<Box<dyn ResolveOrigin>>, origin: Vc<Box<dyn ResolveOrigin>>,
import_context: Vc<ImportContext>, import_context: Vc<ImportContext>,
ty: CssModuleAssetType, ty: CssModuleAssetType,
...@@ -339,7 +339,7 @@ async fn process_content( ...@@ -339,7 +339,7 @@ async fn process_content(
code: String, code: String,
fs_path_vc: ResolvedVc<FileSystemPath>, fs_path_vc: ResolvedVc<FileSystemPath>,
filename: &str, filename: &str,
source: Vc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
origin: Vc<Box<dyn ResolveOrigin>>, origin: Vc<Box<dyn ResolveOrigin>>,
import_context: Vc<ImportContext>, import_context: Vc<ImportContext>,
ty: CssModuleAssetType, ty: CssModuleAssetType,
...@@ -416,11 +416,7 @@ async fn process_content( ...@@ -416,11 +416,7 @@ async fn process_content(
line: loc.line as _, line: loc.line as _,
column: loc.column as _, column: loc.column as _,
}; };
Some( Some(IssueSource::from_line_col(source, pos, pos))
IssueSource::from_line_col(source, pos, pos)
.to_resolved()
.await?,
)
} }
None => None, None => None,
}; };
...@@ -450,11 +446,7 @@ async fn process_content( ...@@ -450,11 +446,7 @@ async fn process_content(
line: loc.line as _, line: loc.line as _,
column: loc.column as _, column: loc.column as _,
}; };
Some( Some(IssueSource::from_line_col(source, pos, pos))
IssueSource::from_line_col(source, pos, pos)
.to_resolved()
.await?,
)
} }
None => None, None => None,
}; };
...@@ -681,7 +673,7 @@ impl GenerateSourceMap for ParseCssResultSourceMap { ...@@ -681,7 +673,7 @@ impl GenerateSourceMap for ParseCssResultSourceMap {
struct ParsingIssue { struct ParsingIssue {
msg: ResolvedVc<RcStr>, msg: ResolvedVc<RcStr>,
file: ResolvedVc<FileSystemPath>, file: ResolvedVc<FileSystemPath>,
source: Option<ResolvedVc<IssueSource>>, source: Option<IssueSource>,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -703,8 +695,8 @@ impl Issue for ParsingIssue { ...@@ -703,8 +695,8 @@ impl Issue for ParsingIssue {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn source(&self) -> Result<Vc<OptionIssueSource>> { async fn source(&self) -> Result<Vc<OptionIssueSource>> {
Ok(Vc::cell(match self.source { Ok(Vc::cell(match &self.source {
Some(s) => Some(s.resolve_source_map(*self.file).to_resolved().await?), Some(s) => Some(s.resolve_source_map(*self.file).await?.into_owned()),
None => None, None => None,
})) }))
} }
......
...@@ -87,7 +87,7 @@ pub struct ImportAssetReference { ...@@ -87,7 +87,7 @@ pub struct ImportAssetReference {
pub request: ResolvedVc<Request>, pub request: ResolvedVc<Request>,
pub attributes: ResolvedVc<ImportAttributes>, pub attributes: ResolvedVc<ImportAttributes>,
pub import_context: ResolvedVc<ImportContext>, pub import_context: ResolvedVc<ImportContext>,
pub issue_source: ResolvedVc<IssueSource>, pub issue_source: IssueSource,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -98,7 +98,7 @@ impl ImportAssetReference { ...@@ -98,7 +98,7 @@ impl ImportAssetReference {
request: ResolvedVc<Request>, request: ResolvedVc<Request>,
attributes: ResolvedVc<ImportAttributes>, attributes: ResolvedVc<ImportAttributes>,
import_context: ResolvedVc<ImportContext>, import_context: ResolvedVc<ImportContext>,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
) -> Vc<Self> { ) -> Vc<Self> {
Self::cell(ImportAssetReference { Self::cell(ImportAssetReference {
origin, origin,
...@@ -126,7 +126,7 @@ impl ModuleReference for ImportAssetReference { ...@@ -126,7 +126,7 @@ impl ModuleReference for ImportAssetReference {
*self.origin, *self.origin,
*self.request, *self.request,
Value::new(CssReferenceSubType::AtImport(Some(import_context))), Value::new(CssReferenceSubType::AtImport(Some(import_context))),
Some(*self.issue_source), Some(self.issue_source.clone()),
)) ))
} }
} }
......
...@@ -8,7 +8,7 @@ use lightningcss::{ ...@@ -8,7 +8,7 @@ use lightningcss::{
visitor::{Visit, Visitor}, visitor::{Visit, Visitor},
}; };
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{Value, Vc}; use turbo_tasks::{ResolvedVc, Value, Vc};
use turbopack_core::{ use turbopack_core::{
issue::IssueSource, issue::IssueSource,
reference::ModuleReference, reference::ModuleReference,
...@@ -39,7 +39,7 @@ pub type AnalyzedRefs = ( ...@@ -39,7 +39,7 @@ pub type AnalyzedRefs = (
/// Returns `(all_references, urls)`. /// Returns `(all_references, urls)`.
pub fn analyze_references( pub fn analyze_references(
stylesheet: &mut StyleSheetLike<'static, 'static>, stylesheet: &mut StyleSheetLike<'static, 'static>,
source: Vc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
origin: Vc<Box<dyn ResolveOrigin>>, origin: Vc<Box<dyn ResolveOrigin>>,
import_context: Vc<ImportContext>, import_context: Vc<ImportContext>,
) -> Result<AnalyzedRefs> { ) -> Result<AnalyzedRefs> {
...@@ -54,7 +54,7 @@ pub fn analyze_references( ...@@ -54,7 +54,7 @@ pub fn analyze_references(
} }
struct ModuleReferencesVisitor<'a> { struct ModuleReferencesVisitor<'a> {
source: Vc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
origin: Vc<Box<dyn ResolveOrigin>>, origin: Vc<Box<dyn ResolveOrigin>>,
import_context: Vc<ImportContext>, import_context: Vc<ImportContext>,
references: &'a mut Vec<Vc<Box<dyn ModuleReference>>>, references: &'a mut Vec<Vc<Box<dyn ModuleReference>>>,
...@@ -63,7 +63,7 @@ struct ModuleReferencesVisitor<'a> { ...@@ -63,7 +63,7 @@ struct ModuleReferencesVisitor<'a> {
impl<'a> ModuleReferencesVisitor<'a> { impl<'a> ModuleReferencesVisitor<'a> {
fn new( fn new(
source: Vc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
origin: Vc<Box<dyn ResolveOrigin>>, origin: Vc<Box<dyn ResolveOrigin>>,
import_context: Vc<ImportContext>, import_context: Vc<ImportContext>,
references: &'a mut Vec<Vc<Box<dyn ModuleReference>>>, references: &'a mut Vec<Vc<Box<dyn ModuleReference>>>,
...@@ -99,7 +99,7 @@ impl Visitor<'_> for ModuleReferencesVisitor<'_> { ...@@ -99,7 +99,7 @@ impl Visitor<'_> for ModuleReferencesVisitor<'_> {
ImportAttributes::new_from_lightningcss(&i.clone().into_owned()).into(), ImportAttributes::new_from_lightningcss(&i.clone().into_owned()).into(),
self.import_context, self.import_context,
IssueSource::from_line_col( IssueSource::from_line_col(
Vc::upcast(self.source), ResolvedVc::upcast(self.source),
SourcePos { SourcePos {
line: issue_span.line as _, line: issue_span.line as _,
column: issue_span.column as _, column: issue_span.column as _,
...@@ -134,7 +134,7 @@ impl Visitor<'_> for ModuleReferencesVisitor<'_> { ...@@ -134,7 +134,7 @@ impl Visitor<'_> for ModuleReferencesVisitor<'_> {
self.origin, self.origin,
Request::parse(Value::new(RcStr::from(src).into())), Request::parse(Value::new(RcStr::from(src).into())),
IssueSource::from_line_col( IssueSource::from_line_col(
Vc::upcast(self.source), ResolvedVc::upcast(self.source),
SourcePos { SourcePos {
line: issue_span.line as _, line: issue_span.line as _,
column: issue_span.column as _, column: issue_span.column as _,
...@@ -171,7 +171,7 @@ pub fn css_resolve( ...@@ -171,7 +171,7 @@ pub fn css_resolve(
origin: Vc<Box<dyn ResolveOrigin>>, origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>, request: Vc<Request>,
ty: Value<CssReferenceSubType>, ty: Value<CssReferenceSubType>,
issue_source: Option<Vc<IssueSource>>, issue_source: Option<IssueSource>,
) -> Vc<ModuleResolveResult> { ) -> Vc<ModuleResolveResult> {
url_resolve( url_resolve(
origin, origin,
......
...@@ -36,7 +36,7 @@ pub enum ReferencedAsset { ...@@ -36,7 +36,7 @@ pub enum ReferencedAsset {
pub struct UrlAssetReference { pub struct UrlAssetReference {
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>, pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>, pub request: ResolvedVc<Request>,
pub issue_source: ResolvedVc<IssueSource>, pub issue_source: IssueSource,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -45,7 +45,7 @@ impl UrlAssetReference { ...@@ -45,7 +45,7 @@ impl UrlAssetReference {
pub fn new( pub fn new(
origin: ResolvedVc<Box<dyn ResolveOrigin>>, origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>, request: ResolvedVc<Request>,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
) -> Vc<Self> { ) -> Vc<Self> {
Self::cell(UrlAssetReference { Self::cell(UrlAssetReference {
origin, origin,
...@@ -90,7 +90,7 @@ impl ModuleReference for UrlAssetReference { ...@@ -90,7 +90,7 @@ impl ModuleReference for UrlAssetReference {
*self.origin, *self.origin,
*self.request, *self.request,
Value::new(ReferenceType::Url(UrlReferenceSubType::CssUrl)), Value::new(ReferenceType::Url(UrlReferenceSubType::CssUrl)),
Some(*self.issue_source), Some(self.issue_source.clone()),
false, false,
) )
} }
......
...@@ -152,7 +152,7 @@ pub struct Issue<'a> { ...@@ -152,7 +152,7 @@ pub struct Issue<'a> {
impl<'a> From<&'a PlainIssue> for Issue<'a> { impl<'a> From<&'a PlainIssue> for Issue<'a> {
fn from(plain: &'a PlainIssue) -> Self { fn from(plain: &'a PlainIssue) -> Self {
let source = plain.source.as_deref().map(|source| IssueSource { let source = plain.source.as_ref().map(|source| IssueSource {
asset: Asset { asset: Asset {
path: &source.asset.ident, path: &source.asset.ident,
}, },
......
...@@ -15,7 +15,7 @@ use swc_core::{ ...@@ -15,7 +15,7 @@ use swc_core::{
}, },
}; };
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::Vc; use turbo_tasks::ResolvedVc;
use turbopack_core::source::Source; use turbopack_core::source::Source;
use super::{ use super::{
...@@ -306,7 +306,7 @@ impl EvalContext { ...@@ -306,7 +306,7 @@ impl EvalContext {
unresolved_mark: Mark, unresolved_mark: Mark,
top_level_mark: Mark, top_level_mark: Mark,
comments: Option<&dyn Comments>, comments: Option<&dyn Comments>,
source: Option<Vc<Box<dyn Source>>>, source: Option<ResolvedVc<Box<dyn Source>>>,
) -> Self { ) -> Self {
Self { Self {
unresolved_mark, unresolved_mark,
......
...@@ -11,7 +11,7 @@ use swc_core::{ ...@@ -11,7 +11,7 @@ use swc_core::{
}, },
}; };
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexMap, FxIndexSet, Vc}; use turbo_tasks::{FxIndexMap, FxIndexSet, ResolvedVc};
use turbopack_core::{issue::IssueSource, source::Source}; use turbopack_core::{issue::IssueSource, source::Source};
use super::{top_level_await::has_top_level_await, JsValue, ModuleValue}; use super::{top_level_await::has_top_level_await, JsValue, ModuleValue};
...@@ -237,7 +237,7 @@ pub(crate) struct ImportMapReference { ...@@ -237,7 +237,7 @@ pub(crate) struct ImportMapReference {
pub module_path: JsWord, pub module_path: JsWord,
pub imported_symbol: ImportedSymbol, pub imported_symbol: ImportedSymbol,
pub annotations: ImportAnnotations, pub annotations: ImportAnnotations,
pub issue_source: Option<Vc<IssueSource>>, pub issue_source: Option<IssueSource>,
} }
impl ImportMap { impl ImportMap {
...@@ -302,7 +302,7 @@ impl ImportMap { ...@@ -302,7 +302,7 @@ impl ImportMap {
/// Analyze ES import /// Analyze ES import
pub(super) fn analyze( pub(super) fn analyze(
m: &Program, m: &Program,
source: Option<Vc<Box<dyn Source>>>, source: Option<ResolvedVc<Box<dyn Source>>>,
comments: Option<&dyn Comments>, comments: Option<&dyn Comments>,
) -> Self { ) -> Self {
let mut data = ImportMap::default(); let mut data = ImportMap::default();
...@@ -412,7 +412,7 @@ impl Visit for StarImportAnalyzer<'_> { ...@@ -412,7 +412,7 @@ impl Visit for StarImportAnalyzer<'_> {
struct Analyzer<'a> { struct Analyzer<'a> {
data: &'a mut ImportMap, data: &'a mut ImportMap,
source: Option<Vc<Box<dyn Source>>>, source: Option<ResolvedVc<Box<dyn Source>>>,
comments: Option<&'a dyn Comments>, comments: Option<&'a dyn Comments>,
} }
......
...@@ -434,7 +434,7 @@ async fn parse_file_content( ...@@ -434,7 +434,7 @@ async fn parse_file_content(
unresolved_mark, unresolved_mark,
top_level_mark, top_level_mark,
Some(&comments), Some(&comments),
Some(*source), Some(source),
); );
Ok::<ParseResult, anyhow::Error>(ParseResult::Ok { Ok::<ParseResult, anyhow::Error>(ParseResult::Ok {
......
...@@ -39,7 +39,7 @@ use crate::{ ...@@ -39,7 +39,7 @@ use crate::{
pub struct AmdDefineAssetReference { pub struct AmdDefineAssetReference {
origin: ResolvedVc<Box<dyn ResolveOrigin>>, origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>, request: ResolvedVc<Request>,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
in_try: bool, in_try: bool,
} }
...@@ -49,7 +49,7 @@ impl AmdDefineAssetReference { ...@@ -49,7 +49,7 @@ impl AmdDefineAssetReference {
pub fn new( pub fn new(
origin: ResolvedVc<Box<dyn ResolveOrigin>>, origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>, request: ResolvedVc<Request>,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
in_try: bool, in_try: bool,
) -> Vc<Self> { ) -> Vc<Self> {
Self::cell(AmdDefineAssetReference { Self::cell(AmdDefineAssetReference {
...@@ -68,7 +68,7 @@ impl ModuleReference for AmdDefineAssetReference { ...@@ -68,7 +68,7 @@ impl ModuleReference for AmdDefineAssetReference {
cjs_resolve( cjs_resolve(
*self.origin, *self.origin,
*self.request, *self.request,
Some(*self.issue_source), Some(self.issue_source.clone()),
self.in_try, self.in_try,
) )
} }
...@@ -132,7 +132,7 @@ pub struct AmdDefineWithDependenciesCodeGen { ...@@ -132,7 +132,7 @@ pub struct AmdDefineWithDependenciesCodeGen {
origin: ResolvedVc<Box<dyn ResolveOrigin>>, origin: ResolvedVc<Box<dyn ResolveOrigin>>,
path: AstPath, path: AstPath,
factory_type: AmdDefineFactoryType, factory_type: AmdDefineFactoryType,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
in_try: bool, in_try: bool,
} }
...@@ -142,7 +142,7 @@ impl AmdDefineWithDependenciesCodeGen { ...@@ -142,7 +142,7 @@ impl AmdDefineWithDependenciesCodeGen {
origin: ResolvedVc<Box<dyn ResolveOrigin>>, origin: ResolvedVc<Box<dyn ResolveOrigin>>,
path: AstPath, path: AstPath,
factory_type: AmdDefineFactoryType, factory_type: AmdDefineFactoryType,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
in_try: bool, in_try: bool,
) -> Self { ) -> Self {
AmdDefineWithDependenciesCodeGen { AmdDefineWithDependenciesCodeGen {
...@@ -179,7 +179,7 @@ impl AmdDefineWithDependenciesCodeGen { ...@@ -179,7 +179,7 @@ impl AmdDefineWithDependenciesCodeGen {
cjs_resolve( cjs_resolve(
*self.origin, *self.origin,
**request, **request,
Some(*self.issue_source), Some(self.issue_source.clone()),
self.in_try, self.in_try,
), ),
ResolveType::ChunkItem, ResolveType::ChunkItem,
......
...@@ -33,7 +33,7 @@ use crate::{ ...@@ -33,7 +33,7 @@ use crate::{
pub struct CjsAssetReference { pub struct CjsAssetReference {
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>, pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>, pub request: ResolvedVc<Request>,
pub issue_source: ResolvedVc<IssueSource>, pub issue_source: IssueSource,
pub in_try: bool, pub in_try: bool,
} }
...@@ -43,7 +43,7 @@ impl CjsAssetReference { ...@@ -43,7 +43,7 @@ impl CjsAssetReference {
pub async fn new( pub async fn new(
origin: ResolvedVc<Box<dyn ResolveOrigin>>, origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>, request: ResolvedVc<Request>,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
in_try: bool, in_try: bool,
) -> Result<Vc<Self>> { ) -> Result<Vc<Self>> {
Ok(Self::cell(CjsAssetReference { Ok(Self::cell(CjsAssetReference {
...@@ -62,7 +62,7 @@ impl ModuleReference for CjsAssetReference { ...@@ -62,7 +62,7 @@ impl ModuleReference for CjsAssetReference {
cjs_resolve( cjs_resolve(
*self.origin, *self.origin,
*self.request, *self.request,
Some(*self.issue_source), Some(self.issue_source.clone()),
self.in_try, self.in_try,
) )
} }
...@@ -87,7 +87,7 @@ pub struct CjsRequireAssetReference { ...@@ -87,7 +87,7 @@ pub struct CjsRequireAssetReference {
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>, pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>, pub request: ResolvedVc<Request>,
pub path: ResolvedVc<AstPath>, pub path: ResolvedVc<AstPath>,
pub issue_source: ResolvedVc<IssueSource>, pub issue_source: IssueSource,
pub in_try: bool, pub in_try: bool,
} }
...@@ -98,7 +98,7 @@ impl CjsRequireAssetReference { ...@@ -98,7 +98,7 @@ impl CjsRequireAssetReference {
origin: ResolvedVc<Box<dyn ResolveOrigin>>, origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>, request: ResolvedVc<Request>,
path: ResolvedVc<AstPath>, path: ResolvedVc<AstPath>,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
in_try: bool, in_try: bool,
) -> Vc<Self> { ) -> Vc<Self> {
Self::cell(CjsRequireAssetReference { Self::cell(CjsRequireAssetReference {
...@@ -118,7 +118,7 @@ impl ModuleReference for CjsRequireAssetReference { ...@@ -118,7 +118,7 @@ impl ModuleReference for CjsRequireAssetReference {
cjs_resolve( cjs_resolve(
*self.origin, *self.origin,
*self.request, *self.request,
Some(*self.issue_source), Some(self.issue_source.clone()),
self.in_try, self.in_try,
) )
} }
...@@ -153,7 +153,7 @@ impl CodeGenerateable for CjsRequireAssetReference { ...@@ -153,7 +153,7 @@ impl CodeGenerateable for CjsRequireAssetReference {
cjs_resolve( cjs_resolve(
*self.origin, *self.origin,
*self.request, *self.request,
Some(*self.issue_source), Some(self.issue_source.clone()),
self.in_try, self.in_try,
), ),
ResolveType::ChunkItem, ResolveType::ChunkItem,
...@@ -196,7 +196,7 @@ pub struct CjsRequireResolveAssetReference { ...@@ -196,7 +196,7 @@ pub struct CjsRequireResolveAssetReference {
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>, pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>, pub request: ResolvedVc<Request>,
pub path: ResolvedVc<AstPath>, pub path: ResolvedVc<AstPath>,
pub issue_source: ResolvedVc<IssueSource>, pub issue_source: IssueSource,
pub in_try: bool, pub in_try: bool,
} }
...@@ -207,7 +207,7 @@ impl CjsRequireResolveAssetReference { ...@@ -207,7 +207,7 @@ impl CjsRequireResolveAssetReference {
origin: ResolvedVc<Box<dyn ResolveOrigin>>, origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>, request: ResolvedVc<Request>,
path: ResolvedVc<AstPath>, path: ResolvedVc<AstPath>,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
in_try: bool, in_try: bool,
) -> Vc<Self> { ) -> Vc<Self> {
Self::cell(CjsRequireResolveAssetReference { Self::cell(CjsRequireResolveAssetReference {
...@@ -227,7 +227,7 @@ impl ModuleReference for CjsRequireResolveAssetReference { ...@@ -227,7 +227,7 @@ impl ModuleReference for CjsRequireResolveAssetReference {
cjs_resolve( cjs_resolve(
*self.origin, *self.origin,
*self.request, *self.request,
Some(*self.issue_source), Some(self.issue_source.clone()),
self.in_try, self.in_try,
) )
} }
...@@ -262,7 +262,7 @@ impl CodeGenerateable for CjsRequireResolveAssetReference { ...@@ -262,7 +262,7 @@ impl CodeGenerateable for CjsRequireResolveAssetReference {
cjs_resolve( cjs_resolve(
*self.origin, *self.origin,
*self.request, *self.request,
Some(*self.issue_source), Some(self.issue_source.clone()),
self.in_try, self.in_try,
), ),
ResolveType::ChunkItem, ResolveType::ChunkItem,
......
...@@ -116,7 +116,7 @@ pub struct EsmAssetReference { ...@@ -116,7 +116,7 @@ pub struct EsmAssetReference {
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>, pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>, pub request: ResolvedVc<Request>,
pub annotations: ImportAnnotations, pub annotations: ImportAnnotations,
pub issue_source: ResolvedVc<IssueSource>, pub issue_source: IssueSource,
pub export_name: Option<ResolvedVc<ModulePart>>, pub export_name: Option<ResolvedVc<ModulePart>>,
pub import_externals: bool, pub import_externals: bool,
} }
...@@ -135,7 +135,7 @@ impl EsmAssetReference { ...@@ -135,7 +135,7 @@ impl EsmAssetReference {
pub fn new( pub fn new(
origin: ResolvedVc<Box<dyn ResolveOrigin>>, origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>, request: ResolvedVc<Request>,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
annotations: Value<ImportAnnotations>, annotations: Value<ImportAnnotations>,
export_name: Option<ResolvedVc<ModulePart>>, export_name: Option<ResolvedVc<ModulePart>>,
import_externals: bool, import_externals: bool,
...@@ -195,7 +195,7 @@ impl ModuleReference for EsmAssetReference { ...@@ -195,7 +195,7 @@ impl ModuleReference for EsmAssetReference {
*self.request, *self.request,
Value::new(ty), Value::new(ty),
false, false,
Some(*self.issue_source), Some(self.issue_source.clone()),
) )
.await?; .await?;
...@@ -209,7 +209,7 @@ impl ModuleReference for EsmAssetReference { ...@@ -209,7 +209,7 @@ impl ModuleReference for EsmAssetReference {
InvalidExport { InvalidExport {
export: export_name, export: export_name,
module, module,
source: self.issue_source, source: self.issue_source.clone(),
} }
.resolved_cell() .resolved_cell()
.emit(); .emit();
...@@ -285,7 +285,6 @@ impl CodeGenerateable for EsmAssetReference { ...@@ -285,7 +285,6 @@ impl CodeGenerateable for EsmAssetReference {
{ {
let span = this let span = this
.issue_source .issue_source
.await?
.to_swc_offsets() .to_swc_offsets()
.await? .await?
.map_or(DUMMY_SP, |(start, end)| { .map_or(DUMMY_SP, |(start, end)| {
...@@ -416,7 +415,7 @@ fn var_decl_with_span(mut decl: Stmt, span: Span) -> Stmt { ...@@ -416,7 +415,7 @@ fn var_decl_with_span(mut decl: Stmt, span: Span) -> Stmt {
pub struct InvalidExport { pub struct InvalidExport {
export: ResolvedVc<RcStr>, export: ResolvedVc<RcStr>,
module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>, module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
source: ResolvedVc<IssueSource>, source: IssueSource,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -504,6 +503,6 @@ impl Issue for InvalidExport { ...@@ -504,6 +503,6 @@ impl Issue for InvalidExport {
#[turbo_tasks::function] #[turbo_tasks::function]
fn source(&self) -> Vc<OptionIssueSource> { fn source(&self) -> Vc<OptionIssueSource> {
Vc::cell(Some(self.source)) Vc::cell(Some(self.source.clone()))
} }
} }
...@@ -36,7 +36,7 @@ pub struct EsmAsyncAssetReference { ...@@ -36,7 +36,7 @@ pub struct EsmAsyncAssetReference {
pub request: ResolvedVc<Request>, pub request: ResolvedVc<Request>,
pub path: ResolvedVc<AstPath>, pub path: ResolvedVc<AstPath>,
pub annotations: ImportAnnotations, pub annotations: ImportAnnotations,
pub issue_source: ResolvedVc<IssueSource>, pub issue_source: IssueSource,
pub in_try: bool, pub in_try: bool,
pub import_externals: bool, pub import_externals: bool,
} }
...@@ -58,7 +58,7 @@ impl EsmAsyncAssetReference { ...@@ -58,7 +58,7 @@ impl EsmAsyncAssetReference {
origin: ResolvedVc<Box<dyn ResolveOrigin>>, origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>, request: ResolvedVc<Request>,
path: ResolvedVc<AstPath>, path: ResolvedVc<AstPath>,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
annotations: Value<ImportAnnotations>, annotations: Value<ImportAnnotations>,
in_try: bool, in_try: bool,
import_externals: bool, import_externals: bool,
...@@ -84,7 +84,7 @@ impl ModuleReference for EsmAsyncAssetReference { ...@@ -84,7 +84,7 @@ impl ModuleReference for EsmAsyncAssetReference {
*self.request, *self.request,
Value::new(EcmaScriptModulesReferenceSubType::DynamicImport), Value::new(EcmaScriptModulesReferenceSubType::DynamicImport),
self.in_try, self.in_try,
Some(*self.issue_source), Some(self.issue_source.clone()),
) )
.await .await
} }
...@@ -126,7 +126,7 @@ impl CodeGenerateable for EsmAsyncAssetReference { ...@@ -126,7 +126,7 @@ impl CodeGenerateable for EsmAsyncAssetReference {
*self.request, *self.request,
Value::new(EcmaScriptModulesReferenceSubType::DynamicImport), Value::new(EcmaScriptModulesReferenceSubType::DynamicImport),
self.in_try, self.in_try,
Some(*self.issue_source), Some(self.issue_source.clone()),
) )
.await?, .await?,
if matches!( if matches!(
......
...@@ -70,7 +70,7 @@ pub struct UrlAssetReference { ...@@ -70,7 +70,7 @@ pub struct UrlAssetReference {
request: ResolvedVc<Request>, request: ResolvedVc<Request>,
rendering: ResolvedVc<Rendering>, rendering: ResolvedVc<Rendering>,
ast_path: ResolvedVc<AstPath>, ast_path: ResolvedVc<AstPath>,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
in_try: bool, in_try: bool,
url_rewrite_behavior: UrlRewriteBehavior, url_rewrite_behavior: UrlRewriteBehavior,
} }
...@@ -83,7 +83,7 @@ impl UrlAssetReference { ...@@ -83,7 +83,7 @@ impl UrlAssetReference {
request: ResolvedVc<Request>, request: ResolvedVc<Request>,
rendering: ResolvedVc<Rendering>, rendering: ResolvedVc<Rendering>,
ast_path: ResolvedVc<AstPath>, ast_path: ResolvedVc<AstPath>,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
in_try: bool, in_try: bool,
url_rewrite_behavior: UrlRewriteBehavior, url_rewrite_behavior: UrlRewriteBehavior,
) -> Vc<Self> { ) -> Vc<Self> {
...@@ -113,7 +113,7 @@ impl ModuleReference for UrlAssetReference { ...@@ -113,7 +113,7 @@ impl ModuleReference for UrlAssetReference {
*self.origin, *self.origin,
*self.request, *self.request,
Value::new(ReferenceType::Url(UrlReferenceSubType::EcmaScriptNewUrl)), Value::new(ReferenceType::Url(UrlReferenceSubType::EcmaScriptNewUrl)),
Some(*self.issue_source), Some(self.issue_source.clone()),
self.in_try, self.in_try,
) )
} }
......
...@@ -606,11 +606,9 @@ pub(crate) async fn analyse_ecmascript_module_internal( ...@@ -606,11 +606,9 @@ pub(crate) async fn analyse_ecmascript_module_internal(
Request::parse(Value::new(RcStr::from(&*r.module_path).into())) Request::parse(Value::new(RcStr::from(&*r.module_path).into()))
.to_resolved() .to_resolved()
.await?, .await?,
if let Some(issue_source) = r.issue_source { r.issue_source
issue_source.to_resolved().await? .clone()
} else { .unwrap_or_else(|| IssueSource::from_source_only(source)),
IssueSource::from_source_only(*source).to_resolved().await?
},
Value::new(r.annotations.clone()), Value::new(r.annotations.clone()),
match options.tree_shaking_mode { match options.tree_shaking_mode {
Some(TreeShakingMode::ModuleFragments) => match &r.imported_symbol { Some(TreeShakingMode::ModuleFragments) => match &r.imported_symbol {
...@@ -878,7 +876,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( ...@@ -878,7 +876,7 @@ pub(crate) async fn analyse_ecmascript_module_internal(
StyledString::Text("top level await is only supported in ESM modules.".into()) StyledString::Text("top level await is only supported in ESM modules.".into())
.cell(), .cell(),
None, None,
Some(issue_source(*source, span)), Some(issue_source(source, span)),
) )
.to_resolved() .to_resolved()
.await? .await?
...@@ -1262,7 +1260,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( ...@@ -1262,7 +1260,7 @@ pub(crate) async fn analyse_ecmascript_module_internal(
EsmAssetReference::new( EsmAssetReference::new(
r_ref.origin, r_ref.origin,
r_ref.request, r_ref.request,
r_ref.issue_source, r_ref.issue_source.clone(),
Value::new(r_ref.annotations.clone()), Value::new(r_ref.annotations.clone()),
Some(ModulePart::export(export).to_resolved().await?), Some(ModulePart::export(export).to_resolved().await?),
r_ref.import_externals, r_ref.import_externals,
...@@ -1463,7 +1461,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>( ...@@ -1463,7 +1461,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
Request::parse(Value::new(pat)), Request::parse(Value::new(pat)),
compile_time_info.environment().rendering(), compile_time_info.environment().rendering(),
Vc::cell(ast_path.to_vec()), Vc::cell(ast_path.to_vec()),
issue_source(*source, span), issue_source(source, span),
in_try, in_try,
url_rewrite_behavior.unwrap_or(UrlRewriteBehavior::Relative), url_rewrite_behavior.unwrap_or(UrlRewriteBehavior::Relative),
) )
...@@ -1498,7 +1496,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>( ...@@ -1498,7 +1496,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
*origin, *origin,
Request::parse(Value::new(pat)), Request::parse(Value::new(pat)),
Vc::cell(ast_path.to_vec()), Vc::cell(ast_path.to_vec()),
issue_source(*source, span), issue_source(source, span),
in_try, in_try,
) )
.to_resolved() .to_resolved()
...@@ -1597,7 +1595,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>( ...@@ -1597,7 +1595,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
*origin, *origin,
Request::parse(Value::new(pat)), Request::parse(Value::new(pat)),
Vc::cell(ast_path.to_vec()), Vc::cell(ast_path.to_vec()),
issue_source(*source, span), issue_source(source, span),
Value::new(import_annotations), Value::new(import_annotations),
in_try, in_try,
state.import_externals, state.import_externals,
...@@ -1639,7 +1637,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>( ...@@ -1639,7 +1637,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
*origin, *origin,
Request::parse(Value::new(pat)), Request::parse(Value::new(pat)),
Vc::cell(ast_path.to_vec()), Vc::cell(ast_path.to_vec()),
issue_source(*source, span), issue_source(source, span),
in_try, in_try,
) )
.to_resolved() .to_resolved()
...@@ -1693,7 +1691,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>( ...@@ -1693,7 +1691,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
*origin, *origin,
Request::parse(Value::new(pat)), Request::parse(Value::new(pat)),
Vc::cell(ast_path.to_vec()), Vc::cell(ast_path.to_vec()),
issue_source(*source, span), issue_source(source, span),
in_try, in_try,
) )
.to_resolved() .to_resolved()
...@@ -1739,7 +1737,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>( ...@@ -1739,7 +1737,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
options.include_subdirs, options.include_subdirs,
Vc::cell(options.filter), Vc::cell(options.filter),
Vc::cell(ast_path.to_vec()), Vc::cell(ast_path.to_vec()),
Some(issue_source(*source, span)), Some(issue_source(source, span)),
in_try, in_try,
) )
.to_resolved() .to_resolved()
...@@ -1883,7 +1881,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>( ...@@ -1883,7 +1881,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
CjsAssetReference::new( CjsAssetReference::new(
*origin, *origin,
Request::parse(Value::new(pat)), Request::parse(Value::new(pat)),
issue_source(*source, span), issue_source(source, span),
in_try, in_try,
) )
.to_resolved() .to_resolved()
...@@ -1945,7 +1943,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>( ...@@ -1945,7 +1943,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
CjsAssetReference::new( CjsAssetReference::new(
*origin, *origin,
Request::parse(Value::new(pat)), Request::parse(Value::new(pat)),
issue_source(*source, span), issue_source(source, span),
in_try, in_try,
) )
.to_resolved() .to_resolved()
...@@ -2122,7 +2120,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>( ...@@ -2122,7 +2120,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
CjsAssetReference::new( CjsAssetReference::new(
*origin, *origin,
Request::parse(Value::new(pat)), Request::parse(Value::new(pat)),
issue_source(*source, span), issue_source(source, span),
in_try, in_try,
) )
.to_resolved() .to_resolved()
...@@ -2194,7 +2192,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>( ...@@ -2194,7 +2192,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
CjsAssetReference::new( CjsAssetReference::new(
*origin, *origin,
Request::parse(Value::new(js_value_to_pattern(&args[1]))), Request::parse(Value::new(js_value_to_pattern(&args[1]))),
issue_source(*source, span), issue_source(source, span),
in_try, in_try,
) )
.to_resolved() .to_resolved()
...@@ -2427,13 +2425,7 @@ async fn handle_free_var_reference( ...@@ -2427,13 +2425,7 @@ async fn handle_free_var_reference(
Request::parse(Value::new(request.clone().into())) Request::parse(Value::new(request.clone().into()))
.to_resolved() .to_resolved()
.await?, .await?,
IssueSource::from_swc_offsets( IssueSource::from_swc_offsets(state.source, span.lo.to_usize(), span.hi.to_usize()),
*state.source,
span.lo.to_usize(),
span.hi.to_usize(),
)
.to_resolved()
.await?,
Default::default(), Default::default(),
match state.tree_shaking_mode { match state.tree_shaking_mode {
Some(TreeShakingMode::ModuleFragments) Some(TreeShakingMode::ModuleFragments)
...@@ -2461,7 +2453,7 @@ async fn handle_free_var_reference( ...@@ -2461,7 +2453,7 @@ async fn handle_free_var_reference(
Ok(true) Ok(true)
} }
fn issue_source(source: Vc<Box<dyn Source>>, span: Span) -> Vc<IssueSource> { fn issue_source(source: ResolvedVc<Box<dyn Source>>, span: Span) -> IssueSource {
IssueSource::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())
} }
...@@ -2506,7 +2498,7 @@ async fn analyze_amd_define( ...@@ -2506,7 +2498,7 @@ async fn analyze_amd_define(
origin, origin,
ast_path.to_vec().into(), ast_path.to_vec().into(),
AmdDefineFactoryType::Function, AmdDefineFactoryType::Function,
issue_source(*source, span).to_resolved().await?, issue_source(source, span),
in_try, in_try,
)); ));
} }
...@@ -2520,7 +2512,7 @@ async fn analyze_amd_define( ...@@ -2520,7 +2512,7 @@ async fn analyze_amd_define(
origin, origin,
ast_path.to_vec().into(), ast_path.to_vec().into(),
AmdDefineFactoryType::Unknown, AmdDefineFactoryType::Unknown,
issue_source(*source, span).to_resolved().await?, issue_source(source, span),
in_try, in_try,
)); ));
} }
...@@ -2534,7 +2526,7 @@ async fn analyze_amd_define( ...@@ -2534,7 +2526,7 @@ async fn analyze_amd_define(
origin, origin,
ast_path.to_vec().into(), ast_path.to_vec().into(),
AmdDefineFactoryType::Function, AmdDefineFactoryType::Function,
issue_source(*source, span).to_resolved().await?, issue_source(source, span),
in_try, in_try,
)); ));
} }
...@@ -2544,7 +2536,7 @@ async fn analyze_amd_define( ...@@ -2544,7 +2536,7 @@ async fn analyze_amd_define(
origin, origin,
ast_path.to_vec().into(), ast_path.to_vec().into(),
AmdDefineFactoryType::Value, AmdDefineFactoryType::Value,
issue_source(*source, span).to_resolved().await?, issue_source(source, span),
in_try, in_try,
)); ));
} }
...@@ -2558,7 +2550,7 @@ async fn analyze_amd_define( ...@@ -2558,7 +2550,7 @@ async fn analyze_amd_define(
origin, origin,
ast_path.to_vec().into(), ast_path.to_vec().into(),
AmdDefineFactoryType::Unknown, AmdDefineFactoryType::Unknown,
issue_source(*source, span).to_resolved().await?, issue_source(source, span),
in_try, in_try,
)); ));
} }
...@@ -2610,7 +2602,7 @@ async fn analyze_amd_define_with_deps( ...@@ -2610,7 +2602,7 @@ async fn analyze_amd_define_with_deps(
let reference = AmdDefineAssetReference::new( let reference = AmdDefineAssetReference::new(
*origin, *origin,
*request, *request,
issue_source(*source, span), issue_source(source, span),
in_try, in_try,
) )
.to_resolved() .to_resolved()
...@@ -2646,7 +2638,7 @@ async fn analyze_amd_define_with_deps( ...@@ -2646,7 +2638,7 @@ async fn analyze_amd_define_with_deps(
origin, origin,
ast_path.to_vec().into(), ast_path.to_vec().into(),
AmdDefineFactoryType::Function, AmdDefineFactoryType::Function,
issue_source(*source, span).to_resolved().await?, issue_source(source, span),
in_try, in_try,
)); ));
......
...@@ -168,7 +168,7 @@ impl RequireContextMap { ...@@ -168,7 +168,7 @@ impl RequireContextMap {
dir: Vc<FileSystemPath>, dir: Vc<FileSystemPath>,
recursive: bool, recursive: bool,
filter: Vc<Regex>, filter: Vc<Regex>,
issue_source: Option<ResolvedVc<IssueSource>>, issue_source: Option<IssueSource>,
is_optional: bool, is_optional: bool,
) -> Result<Vc<Self>> { ) -> Result<Vc<Self>> {
let origin_path = &*origin.origin_path().parent().await?; let origin_path = &*origin.origin_path().parent().await?;
...@@ -182,7 +182,7 @@ impl RequireContextMap { ...@@ -182,7 +182,7 @@ impl RequireContextMap {
let request = Request::parse(Value::new(origin_relative.clone().into())) let request = Request::parse(Value::new(origin_relative.clone().into()))
.to_resolved() .to_resolved()
.await?; .await?;
let result = cjs_resolve(origin, *request, issue_source.map(|v| *v), is_optional) let result = cjs_resolve(origin, *request, issue_source.clone(), is_optional)
.to_resolved() .to_resolved()
.await?; .await?;
...@@ -213,7 +213,7 @@ pub struct RequireContextAssetReference { ...@@ -213,7 +213,7 @@ pub struct RequireContextAssetReference {
pub include_subdirs: bool, pub include_subdirs: bool,
pub path: ResolvedVc<AstPath>, pub path: ResolvedVc<AstPath>,
pub issue_source: Option<ResolvedVc<IssueSource>>, pub issue_source: Option<IssueSource>,
pub in_try: bool, pub in_try: bool,
} }
...@@ -227,7 +227,7 @@ impl RequireContextAssetReference { ...@@ -227,7 +227,7 @@ impl RequireContextAssetReference {
include_subdirs: bool, include_subdirs: bool,
filter: Vc<Regex>, filter: Vc<Regex>,
path: ResolvedVc<AstPath>, path: ResolvedVc<AstPath>,
issue_source: Option<ResolvedVc<IssueSource>>, issue_source: Option<IssueSource>,
in_try: bool, in_try: bool,
) -> Result<Vc<Self>> { ) -> Result<Vc<Self>> {
let map = RequireContextMap::generate( let map = RequireContextMap::generate(
...@@ -235,7 +235,7 @@ impl RequireContextAssetReference { ...@@ -235,7 +235,7 @@ impl RequireContextAssetReference {
origin.origin_path().parent().join(dir.clone()), origin.origin_path().parent().join(dir.clone()),
include_subdirs, include_subdirs,
filter, filter,
issue_source.map(|v| *v), issue_source.clone(),
in_try, in_try,
) )
.to_resolved() .to_resolved()
......
...@@ -30,7 +30,7 @@ pub struct WorkerAssetReference { ...@@ -30,7 +30,7 @@ pub struct WorkerAssetReference {
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>, pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>, pub request: ResolvedVc<Request>,
pub path: ResolvedVc<AstPath>, pub path: ResolvedVc<AstPath>,
pub issue_source: ResolvedVc<IssueSource>, pub issue_source: IssueSource,
pub in_try: bool, pub in_try: bool,
} }
...@@ -41,7 +41,7 @@ impl WorkerAssetReference { ...@@ -41,7 +41,7 @@ impl WorkerAssetReference {
origin: ResolvedVc<Box<dyn ResolveOrigin>>, origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>, request: ResolvedVc<Request>,
path: ResolvedVc<AstPath>, path: ResolvedVc<AstPath>,
issue_source: ResolvedVc<IssueSource>, issue_source: IssueSource,
in_try: bool, in_try: bool,
) -> Vc<Self> { ) -> Vc<Self> {
Self::cell(WorkerAssetReference { Self::cell(WorkerAssetReference {
...@@ -63,7 +63,7 @@ impl WorkerAssetReference { ...@@ -63,7 +63,7 @@ impl WorkerAssetReference {
*self.request, *self.request,
// TODO support more worker types // TODO support more worker types
Value::new(ReferenceType::Worker(WorkerReferenceSubType::WebWorker)), Value::new(ReferenceType::Worker(WorkerReferenceSubType::WebWorker)),
Some(*self.issue_source), Some(self.issue_source.clone()),
self.in_try, self.in_try,
); );
......
...@@ -480,7 +480,7 @@ pub(super) async fn split_module(asset: Vc<EcmascriptModuleAsset>) -> Result<Vc< ...@@ -480,7 +480,7 @@ pub(super) async fn split_module(asset: Vc<EcmascriptModuleAsset>) -> Result<Vc<
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) async fn split( pub(super) async fn split(
ident: ResolvedVc<AssetIdent>, ident: ResolvedVc<AssetIdent>,
source: Vc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
parsed: ResolvedVc<ParseResult>, parsed: ResolvedVc<ParseResult>,
) -> Result<Vc<SplitResult>> { ) -> Result<Vc<SplitResult>> {
// Do not split already split module // Do not split already split module
......
...@@ -219,11 +219,7 @@ impl MdxTransformedAsset { ...@@ -219,11 +219,7 @@ impl MdxTransformedAsset {
} }
}; };
Some( Some(IssueSource::from_line_col(self.source, start, end))
IssueSource::from_line_col(*self.source, start, end)
.to_resolved()
.await?,
)
} }
None => None, None => None,
}; };
...@@ -257,7 +253,7 @@ struct MdxTransformResult { ...@@ -257,7 +253,7 @@ struct MdxTransformResult {
struct MdxIssue { struct MdxIssue {
/// Place of message. /// Place of message.
path: ResolvedVc<FileSystemPath>, path: ResolvedVc<FileSystemPath>,
loc: Option<ResolvedVc<IssueSource>>, loc: Option<IssueSource>,
/// Reason for message (should use markdown). /// Reason for message (should use markdown).
reason: String, reason: String,
/// Category of message. /// Category of message.
...@@ -276,7 +272,7 @@ impl Issue for MdxIssue { ...@@ -276,7 +272,7 @@ impl Issue for MdxIssue {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn source(&self) -> Result<Vc<OptionIssueSource>> { async fn source(&self) -> Result<Vc<OptionIssueSource>> {
Ok(Vc::cell(match &self.loc { Ok(Vc::cell(match &self.loc {
Some(loc) => Some(loc.resolve_source_map(*self.path).to_resolved().await?), Some(loc) => Some(loc.resolve_source_map(*self.path).await?.into_owned()),
None => None, None => None,
})) }))
} }
......
...@@ -89,7 +89,7 @@ pub async fn esm_resolve( ...@@ -89,7 +89,7 @@ pub async fn esm_resolve(
request: Vc<Request>, request: Vc<Request>,
ty: Value<EcmaScriptModulesReferenceSubType>, ty: Value<EcmaScriptModulesReferenceSubType>,
is_optional: bool, is_optional: bool,
issue_source: Option<Vc<IssueSource>>, issue_source: Option<IssueSource>,
) -> Result<Vc<ModuleResolveResult>> { ) -> Result<Vc<ModuleResolveResult>> {
let ty = Value::new(ReferenceType::EcmaScriptModules(ty.into_value())); let ty = Value::new(ReferenceType::EcmaScriptModules(ty.into_value()));
let options = apply_esm_specific_options(origin.resolve_options(ty.clone()), ty.clone()) let options = apply_esm_specific_options(origin.resolve_options(ty.clone()), ty.clone())
...@@ -102,7 +102,7 @@ pub async fn esm_resolve( ...@@ -102,7 +102,7 @@ pub async fn esm_resolve(
pub async fn cjs_resolve( pub async fn cjs_resolve(
origin: Vc<Box<dyn ResolveOrigin>>, origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>, request: Vc<Request>,
issue_source: Option<Vc<IssueSource>>, issue_source: Option<IssueSource>,
is_optional: bool, is_optional: bool,
) -> Result<Vc<ModuleResolveResult>> { ) -> Result<Vc<ModuleResolveResult>> {
// TODO pass CommonJsReferenceSubType // TODO pass CommonJsReferenceSubType
...@@ -117,7 +117,7 @@ pub async fn cjs_resolve( ...@@ -117,7 +117,7 @@ pub async fn cjs_resolve(
pub async fn cjs_resolve_source( pub async fn cjs_resolve_source(
origin: ResolvedVc<Box<dyn ResolveOrigin>>, origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>, request: ResolvedVc<Request>,
issue_source: Option<Vc<IssueSource>>, issue_source: Option<IssueSource>,
is_optional: bool, is_optional: bool,
) -> Result<Vc<ResolveResult>> { ) -> Result<Vc<ResolveResult>> {
// TODO pass CommonJsReferenceSubType // TODO pass CommonJsReferenceSubType
...@@ -150,7 +150,7 @@ async fn specific_resolve( ...@@ -150,7 +150,7 @@ async fn specific_resolve(
options: Vc<ResolveOptions>, options: Vc<ResolveOptions>,
reference_type: Value<ReferenceType>, reference_type: Value<ReferenceType>,
is_optional: bool, is_optional: bool,
issue_source: Option<Vc<IssueSource>>, issue_source: Option<IssueSource>,
) -> Result<Vc<ModuleResolveResult>> { ) -> Result<Vc<ModuleResolveResult>> {
let result = origin let result = origin
.resolve_asset(request, options, reference_type.clone()) .resolve_asset(request, options, reference_type.clone())
......
...@@ -114,7 +114,7 @@ impl Emitter for IssueEmitter { ...@@ -114,7 +114,7 @@ impl Emitter for IssueEmitter {
} }
let source = db.span.primary_span().map(|span| { let source = db.span.primary_span().map(|span| {
IssueSource::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 // TODO add other primary and secondary spans with labels as sub_issues
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment