Unverified Commit acd89db7 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

codemod(turbopack): Rewrite Vc fields in structs as ResolvedVc (part 5) (#71861)

Generated using a version of https://github.com/vercel/turbopack-resolved-vc-codemod . This uses Anthropic Claude Sonnet 3.5 for more complicated errors we don't have hardcoded logic for.

- Part 1: #70927
- Part 2: #71172
- Part 3: #71665
- Part 4: #71804

Closes PACK-3339
parent 0105f6bf
...@@ -576,8 +576,10 @@ async fn create_module_asset( ...@@ -576,8 +576,10 @@ async fn create_module_asset(
..Default::default() ..Default::default()
} }
.into(), .into(),
))); )))
let compile_time_info = CompileTimeInfo::builder(env).cell(); .to_resolved()
.await?;
let compile_time_info = CompileTimeInfo::builder(*env).cell();
let glob_mappings = vec![ let glob_mappings = vec![
( (
root, root,
......
...@@ -17,7 +17,7 @@ pub struct AssetIdent { ...@@ -17,7 +17,7 @@ pub struct AssetIdent {
/// The fragment of the asset (e.g. `#foo`) /// The fragment of the asset (e.g. `#foo`)
pub fragment: Option<ResolvedVc<RcStr>>, pub fragment: Option<ResolvedVc<RcStr>>,
/// The assets that are nested in this asset /// The assets that are nested in this asset
pub assets: Vec<(Vc<RcStr>, Vc<AssetIdent>)>, pub assets: Vec<(ResolvedVc<RcStr>, ResolvedVc<AssetIdent>)>,
/// The modifiers of this asset (e.g. `client chunks`) /// The modifiers of this asset (e.g. `client chunks`)
pub modifiers: Vec<Vc<RcStr>>, pub modifiers: Vec<Vc<RcStr>>,
/// The part of the asset that is a (ECMAScript) module /// The part of the asset that is a (ECMAScript) module
...@@ -31,7 +31,7 @@ impl AssetIdent { ...@@ -31,7 +31,7 @@ impl AssetIdent {
self.modifiers.push(modifier); self.modifiers.push(modifier);
} }
pub fn add_asset(&mut self, key: Vc<RcStr>, asset: Vc<AssetIdent>) { pub fn add_asset(&mut self, key: ResolvedVc<RcStr>, asset: ResolvedVc<AssetIdent>) {
self.assets.push((key, asset)); self.assets.push((key, asset));
} }
......
...@@ -252,7 +252,7 @@ impl OutputAsset for CssChunk { ...@@ -252,7 +252,7 @@ impl OutputAsset for CssChunk {
let CssChunkContent { chunk_items, .. } = &*self.content.await?; let CssChunkContent { chunk_items, .. } = &*self.content.await?;
let mut common_path = if let Some(chunk_item) = chunk_items.first() { let mut common_path = if let Some(chunk_item) = chunk_items.first() {
let path = chunk_item.asset_ident().path().resolve().await?; let path = chunk_item.asset_ident().path().to_resolved().await?;
Some((path, path.await?)) Some((path, path.await?))
} else { } else {
None None
...@@ -265,7 +265,7 @@ impl OutputAsset for CssChunk { ...@@ -265,7 +265,7 @@ impl OutputAsset for CssChunk {
if let Some((common_path_vc, common_path_ref)) = common_path.as_mut() { if let Some((common_path_vc, common_path_ref)) = common_path.as_mut() {
let path = chunk_item.asset_ident().path().await?; let path = chunk_item.asset_ident().path().await?;
while !path.is_inside_or_equal_ref(common_path_ref) { while !path.is_inside_or_equal_ref(common_path_ref) {
let parent = common_path_vc.parent().resolve().await?; let parent = common_path_vc.parent().to_resolved().await?;
if parent == *common_path_vc { if parent == *common_path_vc {
common_path = None; common_path = None;
break; break;
...@@ -274,19 +274,17 @@ impl OutputAsset for CssChunk { ...@@ -274,19 +274,17 @@ impl OutputAsset for CssChunk {
*common_path_ref = (*common_path_vc).await?; *common_path_ref = (*common_path_vc).await?;
} }
} }
assets.push((chunk_item_key, chunk_item.content_ident())); assets.push((
} chunk_item_key.to_resolved().await?,
chunk_item.content_ident().to_resolved().await?,
// Make sure the idents are resolved ));
for (_, ident) in assets.iter_mut() {
*ident = ident.resolve().await?;
} }
let ident = AssetIdent { let ident = AssetIdent {
path: if let Some((common_path, _)) = common_path { path: if let Some((common_path, _)) = common_path {
common_path *common_path
} else { } else {
ServerFileSystem::new().root() *ServerFileSystem::new().root().to_resolved().await?
}, },
query: Vc::<RcStr>::default(), query: Vc::<RcStr>::default(),
fragment: None, fragment: None,
......
...@@ -24,7 +24,7 @@ use super::{ ...@@ -24,7 +24,7 @@ use super::{
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "none")]
pub enum ResolveSourceRequestResult { pub enum ResolveSourceRequestResult {
NotFound, NotFound,
Static(Vc<StaticContent>, ResolvedVc<HeaderList>), Static(ResolvedVc<StaticContent>, ResolvedVc<HeaderList>),
HttpProxy(Vc<ProxyResult>), HttpProxy(Vc<ProxyResult>),
} }
...@@ -107,7 +107,7 @@ pub async fn resolve_source_request( ...@@ -107,7 +107,7 @@ pub async fn resolve_source_request(
} }
ContentSourceContent::Static(static_content) => { ContentSourceContent::Static(static_content) => {
return Ok(ResolveSourceRequestResult::Static( return Ok(ResolveSourceRequestResult::Static(
**static_content, *static_content,
HeaderList::new(response_header_overwrites) HeaderList::new(response_header_overwrites)
.to_resolved() .to_resolved()
.await?, .await?,
......
...@@ -3,7 +3,8 @@ use std::{fmt::Write, mem::replace}; ...@@ -3,7 +3,8 @@ use std::{fmt::Write, mem::replace};
use anyhow::Result; use anyhow::Result;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_tasks::{ use turbo_tasks::{
fxindexmap, trace::TraceRawVcs, FxIndexMap, RcStr, TaskInput, TryJoinIterExt, ValueToString, Vc, fxindexmap, trace::TraceRawVcs, FxIndexMap, RcStr, ResolvedVc, TaskInput, TryJoinIterExt,
ValueToString, Vc,
}; };
use super::{GetContentSourceContent, GetContentSourceContents}; use super::{GetContentSourceContent, GetContentSourceContents};
...@@ -101,7 +102,7 @@ pub struct RouteTree { ...@@ -101,7 +102,7 @@ pub struct RouteTree {
base: Vec<BaseSegment>, base: Vec<BaseSegment>,
sources: Vec<Vc<Box<dyn GetContentSourceContent>>>, sources: Vec<Vc<Box<dyn GetContentSourceContent>>>,
static_segments: FxIndexMap<RcStr, Vc<RouteTree>>, static_segments: FxIndexMap<RcStr, Vc<RouteTree>>,
dynamic_segments: Vec<Vc<RouteTree>>, dynamic_segments: Vec<ResolvedVc<RouteTree>>,
catch_all_sources: Vec<Vc<Box<dyn GetContentSourceContent>>>, catch_all_sources: Vec<Vc<Box<dyn GetContentSourceContent>>>,
fallback_sources: Vec<Vc<Box<dyn GetContentSourceContent>>>, fallback_sources: Vec<Vc<Box<dyn GetContentSourceContent>>>,
not_found_sources: Vec<Vc<Box<dyn GetContentSourceContent>>>, not_found_sources: Vec<Vc<Box<dyn GetContentSourceContent>>>,
...@@ -339,7 +340,7 @@ impl RouteTree { ...@@ -339,7 +340,7 @@ impl RouteTree {
.cell()), .cell()),
BaseSegment::Dynamic => Ok(RouteTree { BaseSegment::Dynamic => Ok(RouteTree {
base, base,
dynamic_segments: vec![inner.cell()], dynamic_segments: vec![inner.resolved_cell()],
..Default::default() ..Default::default()
} }
.cell()), .cell()),
...@@ -366,24 +367,26 @@ impl RouteTree { ...@@ -366,24 +367,26 @@ impl RouteTree {
fallback_sources, fallback_sources,
not_found_sources, not_found_sources,
} = &mut this; } = &mut this;
sources
.iter_mut() for s in sources.iter_mut() {
.for_each(|s| *s = mapper.map_get_content(*s)); *s = mapper.map_get_content(*s);
catch_all_sources }
.iter_mut() for s in catch_all_sources.iter_mut() {
.for_each(|s| *s = mapper.map_get_content(*s)); *s = mapper.map_get_content(*s);
fallback_sources }
.iter_mut() for s in fallback_sources.iter_mut() {
.for_each(|s| *s = mapper.map_get_content(*s)); *s = mapper.map_get_content(*s);
not_found_sources }
.iter_mut() for s in not_found_sources.iter_mut() {
.for_each(|s| *s = mapper.map_get_content(*s)); *s = mapper.map_get_content(*s);
static_segments }
.values_mut() for r in static_segments.values_mut() {
.for_each(|r| *r = r.map_routes(mapper)); *r = r.map_routes(mapper);
dynamic_segments }
.iter_mut() for r in dynamic_segments.iter_mut() {
.for_each(|r| *r = r.map_routes(mapper)); *r = r.map_routes(mapper).to_resolved().await?;
}
Ok(this.cell()) Ok(this.cell())
} }
} }
......
...@@ -78,7 +78,7 @@ impl Chunk for EcmascriptChunk { ...@@ -78,7 +78,7 @@ impl Chunk for EcmascriptChunk {
let EcmascriptChunkContent { chunk_items, .. } = &*self.content.await?; let EcmascriptChunkContent { chunk_items, .. } = &*self.content.await?;
let mut common_path = if let Some((chunk_item, _)) = chunk_items.first() { let mut common_path = if let Some((chunk_item, _)) = chunk_items.first() {
let path = chunk_item.asset_ident().path().resolve().await?; let path = chunk_item.asset_ident().path().to_resolved().await?;
Some((path, path.await?)) Some((path, path.await?))
} else { } else {
None None
...@@ -90,7 +90,7 @@ impl Chunk for EcmascriptChunk { ...@@ -90,7 +90,7 @@ impl Chunk for EcmascriptChunk {
if let Some((common_path_vc, common_path_ref)) = common_path.as_mut() { if let Some((common_path_vc, common_path_ref)) = common_path.as_mut() {
let path = chunk_item.asset_ident().path().await?; let path = chunk_item.asset_ident().path().await?;
while !path.is_inside_or_equal_ref(common_path_ref) { while !path.is_inside_or_equal_ref(common_path_ref) {
let parent = common_path_vc.parent().resolve().await?; let parent = common_path_vc.parent().to_resolved().await?;
if parent == *common_path_vc { if parent == *common_path_vc {
common_path = None; common_path = None;
break; break;
...@@ -99,21 +99,21 @@ impl Chunk for EcmascriptChunk { ...@@ -99,21 +99,21 @@ impl Chunk for EcmascriptChunk {
*common_path_ref = (*common_path_vc).await?; *common_path_ref = (*common_path_vc).await?;
} }
} }
assets.push((chunk_item_key, chunk_item.content_ident())); assets.push((
chunk_item_key.to_resolved().await?,
chunk_item.content_ident().to_resolved().await?,
));
} }
// Make sure the idents are resolved // The previous resolve loop is no longer needed since we're already using ResolvedVc
for (_, ident) in assets.iter_mut() {
*ident = ident.resolve().await?;
}
let ident = AssetIdent { let ident = AssetIdent {
path: if let Some((common_path, _)) = common_path { path: if let Some((common_path, _)) = common_path {
common_path *common_path
} else { } else {
ServerFileSystem::new().root() *ServerFileSystem::new().root().to_resolved().await?
}, },
query: Vc::<RcStr>::default(), query: *Vc::<RcStr>::default().to_resolved().await?,
fragment: None, fragment: None,
assets, assets,
modifiers: Vec::new(), modifiers: Vec::new(),
......
use anyhow::Result; use anyhow::Result;
use turbo_tasks::{FxIndexSet, RcStr, TryJoinIterExt, Value, ValueToString, Vc}; use turbo_tasks::{FxIndexSet, RcStr, ResolvedVc, TryJoinIterExt, Value, ValueToString, Vc};
use turbo_tasks_fs::{File, FileSystemPath}; use turbo_tasks_fs::{File, FileSystemPath};
use turbopack_core::{ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
...@@ -39,7 +39,7 @@ pub struct ChunkGroupFilesAsset { ...@@ -39,7 +39,7 @@ pub struct ChunkGroupFilesAsset {
pub module: Vc<Box<dyn ChunkableModule>>, pub module: Vc<Box<dyn ChunkableModule>>,
pub client_root: Vc<FileSystemPath>, pub client_root: Vc<FileSystemPath>,
pub chunking_context: Vc<Box<dyn ChunkingContext>>, pub chunking_context: Vc<Box<dyn ChunkingContext>>,
pub runtime_entries: Option<Vc<EvaluatableAssets>>, pub runtime_entries: Option<ResolvedVc<EvaluatableAssets>>,
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -132,6 +132,8 @@ impl ChunkGroupFilesChunkItem { ...@@ -132,6 +132,8 @@ impl ChunkGroupFilesChunkItem {
inner.module.ident(), inner.module.ident(),
inner inner
.runtime_entries .runtime_entries
.as_deref()
.copied()
.unwrap_or_else(EvaluatableAssets::empty) .unwrap_or_else(EvaluatableAssets::empty)
.with_entry(ecma), .with_entry(ecma),
Value::new(AvailabilityInfo::Root), Value::new(AvailabilityInfo::Root),
......
...@@ -3,7 +3,7 @@ use swc_core::ecma::{ ...@@ -3,7 +3,7 @@ use swc_core::ecma::{
ast::Stmt, ast::Stmt,
visit::{AstParentKind, VisitMut}, visit::{AstParentKind, VisitMut},
}; };
use turbo_tasks::{debug::ValueDebugFormat, trace::TraceRawVcs, RcStr, Vc}; use turbo_tasks::{debug::ValueDebugFormat, trace::TraceRawVcs, RcStr, ResolvedVc, Vc};
use turbopack_core::chunk::{AsyncModuleInfo, ChunkingContext}; use turbopack_core::chunk::{AsyncModuleInfo, ChunkingContext};
/// impl of code generation inferred from a ModuleReference. /// impl of code generation inferred from a ModuleReference.
...@@ -108,7 +108,7 @@ pub trait CodeGenerateableWithAsyncModuleInfo { ...@@ -108,7 +108,7 @@ pub trait CodeGenerateableWithAsyncModuleInfo {
#[derive(Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat)] #[derive(Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat)]
pub enum CodeGen { pub enum CodeGen {
CodeGenerateable(Vc<Box<dyn CodeGenerateable>>), CodeGenerateable(Vc<Box<dyn CodeGenerateable>>),
CodeGenerateableWithAsyncModuleInfo(Vc<Box<dyn CodeGenerateableWithAsyncModuleInfo>>), CodeGenerateableWithAsyncModuleInfo(ResolvedVc<Box<dyn CodeGenerateableWithAsyncModuleInfo>>),
} }
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
......
...@@ -523,7 +523,10 @@ impl Module for EcmascriptModuleAsset { ...@@ -523,7 +523,10 @@ impl Module for EcmascriptModuleAsset {
if let Some(inner_assets) = self.inner_assets { if let Some(inner_assets) = self.inner_assets {
let mut ident = self.source.ident().await?.clone_value(); let mut ident = self.source.ident().await?.clone_value();
for (name, asset) in inner_assets.await?.iter() { for (name, asset) in inner_assets.await?.iter() {
ident.add_asset(Vc::cell(name.to_string().into()), asset.ident()); ident.add_asset(
ResolvedVc::cell(name.to_string().into()),
asset.ident().to_resolved().await?,
);
} }
ident.add_modifier(modifier()); ident.add_modifier(modifier());
ident.layer = Some(self.asset_context.layer().to_resolved().await?); ident.layer = Some(self.asset_context.layer().to_resolved().await?);
......
...@@ -14,7 +14,9 @@ use swc_core::{ ...@@ -14,7 +14,9 @@ use swc_core::{
}, },
quote, quote_expr, quote, quote_expr,
}; };
use turbo_tasks::{trace::TraceRawVcs, FxIndexMap, RcStr, TryFlatJoinIterExt, ValueToString, Vc}; use turbo_tasks::{
trace::TraceRawVcs, FxIndexMap, RcStr, ResolvedVc, TryFlatJoinIterExt, ValueToString, Vc,
};
use turbo_tasks_fs::glob::Glob; use turbo_tasks_fs::glob::Glob;
use turbopack_core::{ use turbopack_core::{
chunk::ChunkingContext, chunk::ChunkingContext,
...@@ -425,7 +427,7 @@ pub struct EsmExports { ...@@ -425,7 +427,7 @@ pub struct EsmExports {
pub struct ExpandedExports { pub struct ExpandedExports {
pub exports: BTreeMap<RcStr, EsmExport>, pub exports: BTreeMap<RcStr, EsmExport>,
/// Modules we couldn't analyse all exports of. /// Modules we couldn't analyse all exports of.
pub dynamic_exports: Vec<Vc<Box<dyn EcmascriptChunkPlaceable>>>, pub dynamic_exports: Vec<ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>>,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -456,7 +458,7 @@ impl EsmExports { ...@@ -456,7 +458,7 @@ impl EsmExports {
} }
if export_info.has_dynamic_exports { if export_info.has_dynamic_exports {
dynamic_exports.push(**asset); dynamic_exports.push(*asset);
} }
} }
......
...@@ -240,14 +240,14 @@ impl AnalyzeEcmascriptModuleResultBuilder { ...@@ -240,14 +240,14 @@ impl AnalyzeEcmascriptModuleResultBuilder {
/// Adds a codegen to the analysis result. /// Adds a codegen to the analysis result.
#[allow(dead_code)] #[allow(dead_code)]
pub fn add_code_gen_with_availability_info<C>(&mut self, code_gen: Vc<C>) pub fn add_code_gen_with_availability_info<C>(&mut self, code_gen: ResolvedVc<C>)
where where
C: Upcast<Box<dyn CodeGenerateableWithAsyncModuleInfo>>, C: Upcast<Box<dyn CodeGenerateableWithAsyncModuleInfo>>,
{ {
self.code_gens self.code_gens
.push(CodeGen::CodeGenerateableWithAsyncModuleInfo(Vc::upcast( .push(CodeGen::CodeGenerateableWithAsyncModuleInfo(
code_gen, ResolvedVc::upcast(code_gen),
))); ));
} }
pub fn add_binding(&mut self, binding: EsmBinding) { pub fn add_binding(&mut self, binding: EsmBinding) {
...@@ -319,7 +319,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { ...@@ -319,7 +319,7 @@ impl AnalyzeEcmascriptModuleResultBuilder {
*c = c.resolve().await?; *c = c.resolve().await?;
} }
CodeGen::CodeGenerateableWithAsyncModuleInfo(c) => { CodeGen::CodeGenerateableWithAsyncModuleInfo(c) => {
*c = c.resolve().await?; *c = c.to_resolved().await?;
} }
} }
} }
......
...@@ -12,7 +12,7 @@ use swc_core::{ ...@@ -12,7 +12,7 @@ use swc_core::{
}, },
quote, quote_expr, quote, quote_expr,
}; };
use turbo_tasks::{primitives::Regex, FxIndexMap, RcStr, Value, ValueToString, Vc}; use turbo_tasks::{primitives::Regex, FxIndexMap, RcStr, ResolvedVc, Value, ValueToString, Vc};
use turbo_tasks_fs::{DirectoryContent, DirectoryEntry, FileSystemPath}; use turbo_tasks_fs::{DirectoryContent, DirectoryEntry, FileSystemPath};
use turbopack_core::{ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
...@@ -46,8 +46,8 @@ use crate::{ ...@@ -46,8 +46,8 @@ use crate::{
#[turbo_tasks::value] #[turbo_tasks::value]
#[derive(Debug)] #[derive(Debug)]
pub(crate) enum DirListEntry { pub(crate) enum DirListEntry {
File(Vc<FileSystemPath>), File(ResolvedVc<FileSystemPath>),
Dir(Vc<DirList>), Dir(ResolvedVc<DirList>),
} }
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
...@@ -83,7 +83,7 @@ impl DirList { ...@@ -83,7 +83,7 @@ impl DirList {
DirectoryEntry::File(path) => { DirectoryEntry::File(path) => {
if let Some(relative_path) = root_val.get_relative_path_to(&*path.await?) { if let Some(relative_path) = root_val.get_relative_path_to(&*path.await?) {
if regex.is_match(&relative_path) { if regex.is_match(&relative_path) {
list.insert(relative_path, DirListEntry::File(**path)); list.insert(relative_path, DirListEntry::File(*path));
} }
} }
} }
...@@ -91,9 +91,11 @@ impl DirList { ...@@ -91,9 +91,11 @@ impl DirList {
if let Some(relative_path) = root_val.get_relative_path_to(&*path.await?) { if let Some(relative_path) = root_val.get_relative_path_to(&*path.await?) {
list.insert( list.insert(
relative_path, relative_path,
DirListEntry::Dir(DirList::read_internal( DirListEntry::Dir(
root, **path, recursive, filter, DirList::read_internal(root, **path, recursive, filter)
)), .to_resolved()
.await?,
),
); );
} }
} }
...@@ -119,7 +121,7 @@ impl DirList { ...@@ -119,7 +121,7 @@ impl DirList {
for (k, entry) in &*dir { for (k, entry) in &*dir {
match entry { match entry {
DirListEntry::File(path) => { DirListEntry::File(path) => {
list.insert(k.clone(), *path); list.insert(k.clone(), **path);
} }
DirListEntry::Dir(d) => { DirListEntry::Dir(d) => {
queue.push_back(d.await?); queue.push_back(d.await?);
......
...@@ -10,7 +10,7 @@ use anyhow::{bail, Result}; ...@@ -10,7 +10,7 @@ use anyhow::{bail, Result};
pub use node_entry::{NodeEntry, NodeRenderingEntries, NodeRenderingEntry}; pub use node_entry::{NodeEntry, NodeRenderingEntries, NodeRenderingEntry};
use turbo_tasks::{ use turbo_tasks::{
graph::{AdjacencyMap, GraphTraversal}, graph::{AdjacencyMap, GraphTraversal},
Completion, Completions, FxIndexSet, RcStr, TryJoinIterExt, ValueToString, Vc, Completion, Completions, FxIndexSet, RcStr, ResolvedVc, TryJoinIterExt, ValueToString, Vc,
}; };
use turbo_tasks_env::ProcessEnv; use turbo_tasks_env::ProcessEnv;
use turbo_tasks_fs::{to_sys_path, File, FileSystemPath}; use turbo_tasks_fs::{to_sys_path, File, FileSystemPath};
...@@ -127,14 +127,14 @@ pub async fn external_asset_entrypoints( ...@@ -127,14 +127,14 @@ pub async fn external_asset_entrypoints(
/// assets. /// assets.
#[turbo_tasks::function] #[turbo_tasks::function]
async fn separate_assets( async fn separate_assets(
intermediate_asset: Vc<Box<dyn OutputAsset>>, intermediate_asset: ResolvedVc<Box<dyn OutputAsset>>,
intermediate_output_path: Vc<FileSystemPath>, intermediate_output_path: Vc<FileSystemPath>,
) -> Result<Vc<SeparatedAssets>> { ) -> Result<Vc<SeparatedAssets>> {
let intermediate_output_path = &*intermediate_output_path.await?; let intermediate_output_path = &*intermediate_output_path.await?;
#[derive(PartialEq, Eq, Hash, Clone, Copy)] #[derive(PartialEq, Eq, Hash, Clone, Copy)]
enum Type { enum Type {
Internal(Vc<Box<dyn OutputAsset>>), Internal(ResolvedVc<Box<dyn OutputAsset>>),
External(Vc<Box<dyn OutputAsset>>), External(ResolvedVc<Box<dyn OutputAsset>>),
} }
let get_asset_children = |asset| async move { let get_asset_children = |asset| async move {
let Type::Internal(asset) = asset else { let Type::Internal(asset) = asset else {
...@@ -155,9 +155,9 @@ async fn separate_assets( ...@@ -155,9 +155,9 @@ async fn separate_assets(
.await? .await?
.is_inside_ref(intermediate_output_path) .is_inside_ref(intermediate_output_path)
{ {
Ok(Type::Internal(*asset)) Ok(Type::Internal(asset.to_resolved().await?))
} else { } else {
Ok(Type::External(*asset)) Ok(Type::External(asset.to_resolved().await?))
} }
}) })
.try_join() .try_join()
...@@ -177,10 +177,10 @@ async fn separate_assets( ...@@ -177,10 +177,10 @@ async fn separate_assets(
for item in graph.into_reverse_topological() { for item in graph.into_reverse_topological() {
match item { match item {
Type::Internal(asset) => { Type::Internal(asset) => {
internal_assets.insert(asset); internal_assets.insert(*asset);
} }
Type::External(asset) => { Type::External(asset) => {
external_asset_entrypoints.insert(asset); external_asset_entrypoints.insert(*asset);
} }
} }
} }
......
...@@ -114,7 +114,7 @@ pub async fn render_static( ...@@ -114,7 +114,7 @@ pub async fn render_static(
}; };
Ok(match first { Ok(match first {
RenderItem::Response(response) => response, RenderItem::Response(response) => *response,
RenderItem::Headers(data) => { RenderItem::Headers(data) => {
let body = stream.map(|item| match item { let body = stream.map(|item| match item {
Ok(RenderItem::BodyChunk(b)) => Ok(b), Ok(RenderItem::BodyChunk(b)) => Ok(b),
...@@ -183,7 +183,7 @@ async fn static_error( ...@@ -183,7 +183,7 @@ async fn static_error(
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
#[turbo_tasks::value] #[turbo_tasks::value]
enum RenderItem { enum RenderItem {
Response(Vc<StaticResult>), Response(ResolvedVc<StaticResult>),
Headers(ResponseHeaders), Headers(ResponseHeaders),
BodyChunk(Bytes), BodyChunk(Bytes),
} }
...@@ -317,7 +317,9 @@ async fn render_stream_internal( ...@@ -317,7 +317,9 @@ async fn render_stream_internal(
RenderStaticIncomingMessage::Headers { data } => yield RenderItem::Headers(data), RenderStaticIncomingMessage::Headers { data } => yield RenderItem::Headers(data),
RenderStaticIncomingMessage::Rewrite { path } => { RenderStaticIncomingMessage::Rewrite { path } => {
drop(guard); drop(guard);
yield RenderItem::Response(StaticResult::rewrite(RewriteBuilder::new(path).build())); yield RenderItem::Response(
StaticResult::rewrite(RewriteBuilder::new(path).build()).to_resolved().await?
);
return; return;
} }
RenderStaticIncomingMessage::Response { RenderStaticIncomingMessage::Response {
...@@ -326,11 +328,13 @@ async fn render_stream_internal( ...@@ -326,11 +328,13 @@ async fn render_stream_internal(
body, body,
} => { } => {
drop(guard); drop(guard);
yield RenderItem::Response(StaticResult::content( yield RenderItem::Response(
AssetContent::file(File::from(body).into()), StaticResult::content(
status_code, AssetContent::file(File::from(body).into()),
Vc::cell(headers), status_code,
)); Vc::cell(headers),
).to_resolved().await?
);
return; return;
} }
RenderStaticIncomingMessage::Error(error) => { RenderStaticIncomingMessage::Error(error) => {
...@@ -349,7 +353,7 @@ async fn render_stream_internal( ...@@ -349,7 +353,7 @@ async fn render_stream_internal(
static_error(path, anyhow!(trace), Some(operation), fallback_page).await?, static_error(path, anyhow!(trace), Some(operation), fallback_page).await?,
500, 500,
HeaderList::empty(), HeaderList::empty(),
) ).to_resolved().await?
); );
return; return;
} }
......
...@@ -2,8 +2,8 @@ use anyhow::{bail, Context, Result}; ...@@ -2,8 +2,8 @@ use anyhow::{bail, Context, Result};
use indoc::formatdoc; use indoc::formatdoc;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_tasks::{ use turbo_tasks::{
fxindexmap, trace::TraceRawVcs, Completion, Completions, RcStr, TaskInput, TryFlatJoinIterExt, fxindexmap, trace::TraceRawVcs, Completion, Completions, RcStr, ResolvedVc, TaskInput,
Value, Vc, TryFlatJoinIterExt, Value, Vc,
}; };
use turbo_tasks_bytes::stream::SingleValue; use turbo_tasks_bytes::stream::SingleValue;
use turbo_tasks_fs::{ use turbo_tasks_fs::{
...@@ -164,7 +164,7 @@ impl Asset for PostCssTransformedAsset { ...@@ -164,7 +164,7 @@ impl Asset for PostCssTransformedAsset {
#[turbo_tasks::value] #[turbo_tasks::value]
struct ProcessPostCssResult { struct ProcessPostCssResult {
content: Vc<AssetContent>, content: Vc<AssetContent>,
assets: Vec<Vc<VirtualSource>>, assets: Vec<ResolvedVc<VirtualSource>>,
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -458,7 +458,7 @@ impl PostCssTransformedAsset { ...@@ -458,7 +458,7 @@ impl PostCssTransformedAsset {
}; };
let FileContent::Content(content) = &*file.await? else { let FileContent::Content(content) = &*file.await? else {
return Ok(ProcessPostCssResult { return Ok(ProcessPostCssResult {
content: AssetContent::File(FileContent::NotFound.cell()).cell(), content: AssetContent::File(*FileContent::NotFound.resolved_cell()).cell(),
assets: Vec::new(), assets: Vec::new(),
} }
.cell()); .cell());
...@@ -501,7 +501,7 @@ impl PostCssTransformedAsset { ...@@ -501,7 +501,7 @@ impl PostCssTransformedAsset {
let SingleValue::Single(val) = config_value.try_into_single().await? else { let SingleValue::Single(val) = config_value.try_into_single().await? else {
// An error happened, which has already been converted into an issue. // An error happened, which has already been converted into an issue.
return Ok(ProcessPostCssResult { return Ok(ProcessPostCssResult {
content: AssetContent::File(FileContent::NotFound.cell()).cell(), content: AssetContent::File(*FileContent::NotFound.resolved_cell()).cell(),
assets: Vec::new(), assets: Vec::new(),
} }
.cell()); .cell());
...@@ -511,7 +511,7 @@ impl PostCssTransformedAsset { ...@@ -511,7 +511,7 @@ impl PostCssTransformedAsset {
// TODO handle SourceMap // TODO handle SourceMap
let file = File::from(processed_css.css); let file = File::from(processed_css.css);
let assets = emitted_assets_to_virtual_sources(processed_css.assets); let assets = emitted_assets_to_virtual_sources(processed_css.assets).await?;
let content = AssetContent::File(FileContent::Content(file).cell()).cell(); let content = AssetContent::File(FileContent::Content(file).cell()).cell();
Ok(ProcessPostCssResult { content, assets }.cell()) Ok(ProcessPostCssResult { content, assets }.cell())
} }
......
use std::collections::BTreeMap; use std::collections::BTreeMap;
use anyhow::Result;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;
use turbo_tasks::{RcStr, Vc}; use turbo_tasks::{RcStr, ResolvedVc, TryJoinIterExt};
use turbo_tasks_fs::{File, FileContent, FileSystem}; use turbo_tasks_fs::{File, FileContent, FileSystem};
use turbopack_core::{ use turbopack_core::{
asset::AssetContent, server_fs::ServerFileSystem, virtual_source::VirtualSource, asset::AssetContent, server_fs::ServerFileSystem, virtual_source::VirtualSource,
...@@ -16,9 +17,9 @@ pub struct EmittedAsset { ...@@ -16,9 +17,9 @@ pub struct EmittedAsset {
source_map: Option<JsonValue>, source_map: Option<JsonValue>,
} }
pub fn emitted_assets_to_virtual_sources( pub async fn emitted_assets_to_virtual_sources(
assets: Option<Vec<EmittedAsset>>, assets: Option<Vec<EmittedAsset>>,
) -> Vec<Vc<VirtualSource>> { ) -> Result<Vec<ResolvedVc<VirtualSource>>> {
assets assets
.into_iter() .into_iter()
.flatten() .flatten()
...@@ -38,6 +39,8 @@ pub fn emitted_assets_to_virtual_sources( ...@@ -38,6 +39,8 @@ pub fn emitted_assets_to_virtual_sources(
ServerFileSystem::new().root().join(file), ServerFileSystem::new().root().join(file),
AssetContent::File(FileContent::Content(File::from(content)).cell()).cell(), AssetContent::File(FileContent::Content(File::from(content)).cell()).cell(),
) )
.to_resolved()
}) })
.collect() .try_join()
.await
} }
...@@ -268,7 +268,11 @@ impl WebpackLoadersProcessedAsset { ...@@ -268,7 +268,11 @@ impl WebpackLoadersProcessedAsset {
Either::Left(str) => File::from(str), Either::Left(str) => File::from(str),
Either::Right(bytes) => File::from(bytes.binary), Either::Right(bytes) => File::from(bytes.binary),
}; };
let assets = emitted_assets_to_virtual_sources(processed.assets); let assets = emitted_assets_to_virtual_sources(processed.assets)
.await?
.into_iter()
.map(|asset| *asset)
.collect();
let content = AssetContent::File(FileContent::Content(file).cell()).cell(); let content = AssetContent::File(FileContent::Content(file).cell()).cell();
Ok(ProcessWebpackLoadersResult { Ok(ProcessWebpackLoadersResult {
content, content,
......
use anyhow::Result; use anyhow::Result;
use turbo_tasks::{RcStr, ValueDefault, Vc}; use turbo_tasks::{RcStr, ResolvedVc, ValueDefault, Vc};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbopack_core::{ use turbopack_core::{
condition::ContextCondition, condition::ContextCondition,
...@@ -14,7 +14,7 @@ use turbopack_core::{ ...@@ -14,7 +14,7 @@ use turbopack_core::{
#[derive(Default, Clone)] #[derive(Default, Clone)]
pub struct ResolveOptionsContext { pub struct ResolveOptionsContext {
#[serde(default)] #[serde(default)]
pub emulate_environment: Option<Vc<Environment>>, pub emulate_environment: Option<ResolvedVc<Environment>>,
#[serde(default)] #[serde(default)]
pub enable_types: bool, pub enable_types: bool,
#[serde(default)] #[serde(default)]
......
...@@ -98,7 +98,9 @@ fn bench_emit(b: &mut Bencher, bench_input: &BenchInput) { ...@@ -98,7 +98,9 @@ fn bench_emit(b: &mut Bencher, bench_input: &BenchInput) {
} }
.cell(), .cell(),
ResolveOptionsContext { ResolveOptionsContext {
emulate_environment: Some(compile_time_info.environment().resolve().await?), emulate_environment: Some(
compile_time_info.environment().to_resolved().await?,
),
..Default::default() ..Default::default()
} }
.cell(), .cell(),
......
...@@ -51,7 +51,7 @@ impl AggregatedGraph { ...@@ -51,7 +51,7 @@ impl AggregatedGraph {
for reference in asset.references().await?.iter() { for reference in asset.references().await?.iter() {
let reference = reference.resolve().await?; let reference = reference.resolve().await?;
if asset != reference.to_resolved().await? { if asset != reference.to_resolved().await? {
refs.insert(AggregatedGraph::leaf(reference)); refs.insert(AggregatedGraph::leaf(reference).to_resolved().await?);
} }
} }
AggregatedGraphsSet { set: refs }.into() AggregatedGraphsSet { set: refs }.into()
...@@ -64,7 +64,7 @@ impl AggregatedGraph { ...@@ -64,7 +64,7 @@ impl AggregatedGraph {
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_iter() .into_iter()
{ {
set.insert(item.resolve().await?); set.insert(item.to_resolved().await?);
} }
AggregatedGraphsSet { set }.into() AggregatedGraphsSet { set }.into()
} }
...@@ -152,20 +152,20 @@ async fn aggregate_more(node: Vc<AggregatedGraph>) -> Result<Vc<AggregatedGraph> ...@@ -152,20 +152,20 @@ async fn aggregate_more(node: Vc<AggregatedGraph>) -> Result<Vc<AggregatedGraph>
for valued_refs in valued_refs { for valued_refs in valued_refs {
let valued_refs = valued_refs.await?; let valued_refs = valued_refs.await?;
for &reference in valued_refs.inner.iter() { for &reference in valued_refs.inner.iter() {
content.insert(reference); content.insert(*reference);
} }
for &reference in valued_refs.references.iter() { for &reference in valued_refs.references.iter() {
if content.contains(&reference) { if content.contains(&reference) {
continue; continue;
} }
references.insert(reference); references.insert(*reference);
} }
for &reference in valued_refs.outer.iter() { for &reference in valued_refs.outer.iter() {
if content.contains(&reference) { if content.contains(&reference) {
continue; continue;
} }
references.remove(&reference); references.remove(&reference);
in_progress.insert(reference); in_progress.insert(*reference);
} }
} }
} }
...@@ -182,7 +182,7 @@ async fn aggregate_more(node: Vc<AggregatedGraph>) -> Result<Vc<AggregatedGraph> ...@@ -182,7 +182,7 @@ async fn aggregate_more(node: Vc<AggregatedGraph>) -> Result<Vc<AggregatedGraph>
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
struct AggregatedGraphsSet { struct AggregatedGraphsSet {
pub set: HashSet<Vc<AggregatedGraph>>, pub set: HashSet<ResolvedVc<AggregatedGraph>>,
} }
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
...@@ -193,7 +193,7 @@ pub enum AggregatedGraphNodeContent { ...@@ -193,7 +193,7 @@ pub enum AggregatedGraphNodeContent {
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
struct AggregatedGraphsValuedReferences { struct AggregatedGraphsValuedReferences {
pub inner: HashSet<Vc<AggregatedGraph>>, pub inner: HashSet<ResolvedVc<AggregatedGraph>>,
pub outer: HashSet<Vc<AggregatedGraph>>, pub outer: HashSet<ResolvedVc<AggregatedGraph>>,
pub references: HashSet<Vc<AggregatedGraph>>, pub references: HashSet<ResolvedVc<AggregatedGraph>>,
} }
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