Unverified Commit 2dab0ed2 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

refactor(turbopack): Use ResolvedVc for chunk graph related types (#74507)

Allows a few more `turbo_tasks::value`s to implement `NonLocalValue`, making them safe for use with local tasks.
parent c51b5368
...@@ -77,7 +77,9 @@ impl ClientReferenceManifest { ...@@ -77,7 +77,9 @@ impl ClientReferenceManifest {
let client_chunk_item = ecmascript_client_reference let client_chunk_item = ecmascript_client_reference
.client_module .client_module
.as_chunk_item(Vc::upcast(client_chunking_context)); .as_chunk_item(Vc::upcast(client_chunking_context))
.to_resolved()
.await?;
let client_module_id = client_chunk_item.id().await?; let client_module_id = client_chunk_item.id().await?;
...@@ -116,16 +118,20 @@ impl ClientReferenceManifest { ...@@ -116,16 +118,20 @@ impl ClientReferenceManifest {
if let Some(ssr_chunking_context) = ssr_chunking_context { if let Some(ssr_chunking_context) = ssr_chunking_context {
let ssr_chunk_item = ecmascript_client_reference let ssr_chunk_item = ecmascript_client_reference
.ssr_module .ssr_module
.as_chunk_item(Vc::upcast(ssr_chunking_context)); .as_chunk_item(Vc::upcast(ssr_chunking_context))
.to_resolved()
.await?;
let ssr_module_id = ssr_chunk_item.id().await?; let ssr_module_id = ssr_chunk_item.id().await?;
let rsc_chunk_item: Vc<Box<dyn ChunkItem>> = let rsc_chunk_item: ResolvedVc<Box<dyn ChunkItem>> =
ResolvedVc::try_downcast_type::<EcmascriptClientReferenceProxyModule>( ResolvedVc::try_downcast_type::<EcmascriptClientReferenceProxyModule>(
parent_module, parent_module,
) )
.await? .await?
.unwrap() .unwrap()
.as_chunk_item(Vc::upcast(ssr_chunking_context)); .as_chunk_item(Vc::upcast(ssr_chunking_context))
.to_resolved()
.await?;
let rsc_module_id = rsc_chunk_item.id().await?; let rsc_module_id = rsc_chunk_item.id().await?;
let (ssr_chunks_paths, ssr_is_async) = if runtime == NextRuntime::Edge { let (ssr_chunks_paths, ssr_is_async) = if runtime == NextRuntime::Edge {
...@@ -362,13 +368,13 @@ pub fn get_client_reference_module_key(server_path: &str, export_name: &str) -> ...@@ -362,13 +368,13 @@ pub fn get_client_reference_module_key(server_path: &str, export_name: &str) ->
async fn is_item_async( async fn is_item_async(
availability_info: &AvailabilityInfo, availability_info: &AvailabilityInfo,
chunk_item: Vc<Box<dyn ChunkItem>>, chunk_item: ResolvedVc<Box<dyn ChunkItem>>,
) -> Result<bool> { ) -> Result<bool> {
let Some(available_chunk_items) = availability_info.available_chunk_items() else { let Some(available_chunk_items) = availability_info.available_chunk_items() else {
return Ok(false); return Ok(false);
}; };
let Some(info) = &*available_chunk_items.get(chunk_item).await? else { let Some(info) = available_chunk_items.await?.get(chunk_item).await? else {
return Ok(false); return Ok(false);
}; };
......
...@@ -390,7 +390,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -390,7 +390,7 @@ impl ChunkingContext for BrowserChunkingContext {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn chunk_group( async fn chunk_group(
self: Vc<Self>, self: ResolvedVc<Self>,
ident: Vc<AssetIdent>, ident: Vc<AssetIdent>,
module: ResolvedVc<Box<dyn ChunkableModule>>, module: ResolvedVc<Box<dyn ChunkableModule>>,
availability_info: Value<AvailabilityInfo>, availability_info: Value<AvailabilityInfo>,
...@@ -403,7 +403,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -403,7 +403,7 @@ impl ChunkingContext for BrowserChunkingContext {
chunks, chunks,
availability_info, availability_info,
} = make_chunk_group( } = make_chunk_group(
Vc::upcast(self), ResolvedVc::upcast(self),
[ResolvedVc::upcast(module)], [ResolvedVc::upcast(module)],
input_availability_info, input_availability_info,
) )
...@@ -454,7 +454,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -454,7 +454,7 @@ impl ChunkingContext for BrowserChunkingContext {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn evaluated_chunk_group( async fn evaluated_chunk_group(
self: Vc<Self>, self: ResolvedVc<Self>,
ident: Vc<AssetIdent>, ident: Vc<AssetIdent>,
evaluatable_assets: Vc<EvaluatableAssets>, evaluatable_assets: Vc<EvaluatableAssets>,
availability_info: Value<AvailabilityInfo>, availability_info: Value<AvailabilityInfo>,
...@@ -476,7 +476,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -476,7 +476,7 @@ impl ChunkingContext for BrowserChunkingContext {
let MakeChunkGroupResult { let MakeChunkGroupResult {
chunks, chunks,
availability_info, availability_info,
} = make_chunk_group(Vc::upcast(self), entries, availability_info).await?; } = make_chunk_group(ResolvedVc::upcast(self), entries, availability_info).await?;
let mut assets: Vec<ResolvedVc<Box<dyn OutputAsset>>> = chunks let mut assets: Vec<ResolvedVc<Box<dyn OutputAsset>>> = chunks
.iter() .iter()
......
...@@ -59,7 +59,11 @@ impl EcmascriptDevChunkContentEntries { ...@@ -59,7 +59,11 @@ impl EcmascriptDevChunkContentEntries {
async move { async move {
Ok(( Ok((
chunk_item.id().await?, chunk_item.id().await?,
EcmascriptDevChunkContentEntry::new(chunk_item, async_module_info).await?, EcmascriptDevChunkContentEntry::new(
*chunk_item,
async_module_info.map(|info| *info),
)
.await?,
)) ))
} }
.instrument(info_span!( .instrument(info_span!(
......
...@@ -17,14 +17,14 @@ pub enum AvailabilityInfo { ...@@ -17,14 +17,14 @@ pub enum AvailabilityInfo {
} }
impl AvailabilityInfo { impl AvailabilityInfo {
pub fn available_chunk_items(&self) -> Option<Vc<AvailableChunkItems>> { pub fn available_chunk_items(&self) -> Option<ResolvedVc<AvailableChunkItems>> {
match self { match self {
Self::Untracked => None, Self::Untracked => None,
Self::Root => None, Self::Root => None,
Self::Complete { Self::Complete {
available_chunk_items, available_chunk_items,
.. ..
} => Some(**available_chunk_items), } => Some(*available_chunk_items),
} }
} }
......
...@@ -15,9 +15,6 @@ pub struct AvailableChunkItemInfo { ...@@ -15,9 +15,6 @@ pub struct AvailableChunkItemInfo {
pub is_async: bool, pub is_async: bool,
} }
#[turbo_tasks::value(transparent)]
pub struct OptionAvailableChunkItemInfo(Option<AvailableChunkItemInfo>);
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
pub struct AvailableChunkItemInfoMap( pub struct AvailableChunkItemInfoMap(
FxIndexMap<ResolvedVc<Box<dyn ChunkItem>>, AvailableChunkItemInfo>, FxIndexMap<ResolvedVc<Box<dyn ChunkItem>>, AvailableChunkItemInfo>,
...@@ -48,12 +45,13 @@ impl AvailableChunkItems { ...@@ -48,12 +45,13 @@ impl AvailableChunkItems {
self: ResolvedVc<Self>, self: ResolvedVc<Self>,
chunk_items: ResolvedVc<AvailableChunkItemInfoMap>, chunk_items: ResolvedVc<AvailableChunkItemInfoMap>,
) -> Result<Vc<Self>> { ) -> Result<Vc<Self>> {
let this = &*self.await?;
let chunk_items = chunk_items let chunk_items = chunk_items
.await? .await?
.into_iter() .into_iter()
.map(|(&chunk_item, &info)| async move { .map(|(&chunk_item, &info)| async move {
Ok(self Ok(this
.get(*chunk_item) .get(chunk_item)
.await? .await?
.is_none() .is_none()
.then_some((chunk_item, info))) .then_some((chunk_item, info)))
...@@ -87,18 +85,24 @@ impl AvailableChunkItems { ...@@ -87,18 +85,24 @@ impl AvailableChunkItems {
} }
Ok(Vc::cell(hasher.finish())) Ok(Vc::cell(hasher.finish()))
} }
}
#[turbo_tasks::function] impl AvailableChunkItems {
// This is not a turbo-tasks function because:
//
// - We want to enforce that the `chunk_item` key is a `ResolvedVc`, so that it will actually
// match the entries in the `HashMap`.
// - This is a cheap operation that's unlikely to be worth caching.
pub async fn get( pub async fn get(
&self, &self,
chunk_item: ResolvedVc<Box<dyn ChunkItem>>, chunk_item: ResolvedVc<Box<dyn ChunkItem>>,
) -> Result<Vc<OptionAvailableChunkItemInfo>> { ) -> Result<Option<AvailableChunkItemInfo>> {
if let Some(&info) = self.chunk_items.await?.get(&chunk_item) { if let Some(&info) = self.chunk_items.await?.get(&chunk_item) {
return Ok(Vc::cell(Some(info))); return Ok(Some(info));
}; };
if let Some(parent) = self.parent { if let Some(parent) = self.parent {
return Ok(parent.get(*chunk_item)); return Box::pin(parent.await?.get(chunk_item)).await;
} }
Ok(Vc::cell(None)) Ok(None)
} }
} }
...@@ -2,9 +2,7 @@ use std::collections::HashSet; ...@@ -2,9 +2,7 @@ use std::collections::HashSet;
use anyhow::Result; use anyhow::Result;
use auto_hash_map::AutoSet; use auto_hash_map::AutoSet;
use turbo_tasks::{ use turbo_tasks::{FxIndexMap, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Value, Vc};
FxIndexMap, FxIndexSet, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Value, Vc,
};
use super::{ use super::{
availability_info::AvailabilityInfo, available_chunk_items::AvailableChunkItemInfo, availability_info::AvailabilityInfo, available_chunk_items::AvailableChunkItemInfo,
...@@ -22,7 +20,7 @@ pub struct MakeChunkGroupResult { ...@@ -22,7 +20,7 @@ pub struct MakeChunkGroupResult {
/// Creates a chunk group from a set of entries. /// Creates a chunk group from a set of entries.
pub async fn make_chunk_group( pub async fn make_chunk_group(
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
chunk_group_entries: impl IntoIterator<Item = ResolvedVc<Box<dyn Module>>>, chunk_group_entries: impl IntoIterator<Item = ResolvedVc<Box<dyn Module>>>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Result<MakeChunkGroupResult> { ) -> Result<MakeChunkGroupResult> {
...@@ -53,7 +51,7 @@ pub async fn make_chunk_group( ...@@ -53,7 +51,7 @@ pub async fn make_chunk_group(
.keys() .keys()
.copied() .copied()
.chain(self_async_children.into_iter()) .chain(self_async_children.into_iter())
.map(|chunk_item| (chunk_item, AutoSet::<Vc<Box<dyn ChunkItem>>>::new())) .map(|chunk_item| (chunk_item, AutoSet::<ResolvedVc<Box<dyn ChunkItem>>>::new()))
.collect::<FxIndexMap<_, _>>(); .collect::<FxIndexMap<_, _>>();
// Propagate async inheritance // Propagate async inheritance
...@@ -86,7 +84,7 @@ pub async fn make_chunk_group( ...@@ -86,7 +84,7 @@ pub async fn make_chunk_group(
let mut chunk_items = chunk_items let mut chunk_items = chunk_items
.into_iter() .into_iter()
.map(|chunk_item| (chunk_item, None)) .map(|chunk_item| (chunk_item, None))
.collect::<FxIndexMap<_, Option<Vc<AsyncModuleInfo>>>>(); .collect::<FxIndexMap<_, Option<ResolvedVc<AsyncModuleInfo>>>>();
// Insert AsyncModuleInfo for every async module // Insert AsyncModuleInfo for every async module
for (async_item, referenced_async_modules) in async_chunk_items { for (async_item, referenced_async_modules) in async_chunk_items {
...@@ -96,13 +94,18 @@ pub async fn make_chunk_group( ...@@ -96,13 +94,18 @@ pub async fn make_chunk_group(
.iter() .iter()
.copied() .copied()
.filter(|item| referenced_async_modules.contains(item)) .filter(|item| referenced_async_modules.contains(item))
.map(|item| *item)
.collect() .collect()
} else { } else {
Default::default() Default::default()
}; };
chunk_items.insert( chunk_items.insert(
async_item, async_item,
Some(AsyncModuleInfo::new(referenced_async_modules)), Some(
AsyncModuleInfo::new(referenced_async_modules)
.to_resolved()
.await?,
),
); );
} }
...@@ -112,7 +115,7 @@ pub async fn make_chunk_group( ...@@ -112,7 +115,7 @@ pub async fn make_chunk_group(
.iter() .iter()
.map(|(&chunk_item, async_info)| async move { .map(|(&chunk_item, async_info)| async move {
Ok(( Ok((
chunk_item.to_resolved().await?, chunk_item,
AvailableChunkItemInfo { AvailableChunkItemInfo {
is_async: async_info.is_some(), is_async: async_info.is_some(),
}, },
...@@ -130,9 +133,12 @@ pub async fn make_chunk_group( ...@@ -130,9 +133,12 @@ pub async fn make_chunk_group(
let async_loaders = async_modules let async_loaders = async_modules
.into_iter() .into_iter()
.map(|module| { .map(|module| {
chunking_context.async_loader_chunk_item(*module, Value::new(availability_info)) chunking_context
.async_loader_chunk_item(*module, Value::new(availability_info))
.to_resolved()
}) })
.collect::<Vec<_>>(); .try_join()
.await?;
let has_async_loaders = !async_loaders.is_empty(); let has_async_loaders = !async_loaders.is_empty();
let async_loader_chunk_items = async_loaders.iter().map(|&chunk_item| (chunk_item, None)); let async_loader_chunk_items = async_loaders.iter().map(|&chunk_item| (chunk_item, None));
...@@ -151,7 +157,7 @@ pub async fn make_chunk_group( ...@@ -151,7 +157,7 @@ pub async fn make_chunk_group(
let mut referenced_output_assets = (*external_output_assets.await?).clone(); let mut referenced_output_assets = (*external_output_assets.await?).clone();
referenced_output_assets.extend( referenced_output_assets.extend(
references_to_output_assets(external_module_references) references_to_output_assets(&external_module_references)
.await? .await?
.await? .await?
.iter() .iter()
...@@ -175,7 +181,7 @@ pub async fn make_chunk_group( ...@@ -175,7 +181,7 @@ pub async fn make_chunk_group(
// Pass chunk items to chunking algorithm // Pass chunk items to chunking algorithm
let mut chunks = make_chunks( let mut chunks = make_chunks(
chunking_context, *chunking_context,
Vc::cell(chunk_items.into_iter().collect()), Vc::cell(chunk_items.into_iter().collect()),
"".into(), "".into(),
Vc::cell(referenced_output_assets), Vc::cell(referenced_output_assets),
...@@ -188,7 +194,7 @@ pub async fn make_chunk_group( ...@@ -188,7 +194,7 @@ pub async fn make_chunk_group(
// We want them to be separate since they are specific to this chunk group due // We want them to be separate since they are specific to this chunk group due
// to available chunk items differing // to available chunk items differing
let async_loader_chunks = make_chunks( let async_loader_chunks = make_chunks(
chunking_context, *chunking_context,
Vc::cell(async_loader_chunk_items.into_iter().collect()), Vc::cell(async_loader_chunk_items.into_iter().collect()),
"async-loader-".into(), "async-loader-".into(),
async_loader_external_module_references, async_loader_external_module_references,
...@@ -206,7 +212,7 @@ pub async fn make_chunk_group( ...@@ -206,7 +212,7 @@ pub async fn make_chunk_group(
} }
pub async fn references_to_output_assets( pub async fn references_to_output_assets(
references: FxIndexSet<Vc<Box<dyn ModuleReference>>>, references: impl IntoIterator<Item = &ResolvedVc<Box<dyn ModuleReference>>>,
) -> Result<Vc<OutputAssets>> { ) -> Result<Vc<OutputAssets>> {
let output_assets = references let output_assets = references
.into_iter() .into_iter()
......
...@@ -53,7 +53,9 @@ pub async fn make_chunks( ...@@ -53,7 +53,9 @@ pub async fn make_chunks(
.await? .await?
.iter() .iter()
.map(|&(chunk_item, async_info)| async move { .map(|&(chunk_item, async_info)| async move {
let chunk_item_info = chunk_item_info(chunking_context, chunk_item, async_info).await?; let chunk_item_info =
chunk_item_info(chunking_context, *chunk_item, async_info.map(|info| *info))
.await?;
Ok((chunk_item, async_info, chunk_item_info)) Ok((chunk_item, async_info, chunk_item_info))
}) })
.try_join() .try_join()
...@@ -118,8 +120,8 @@ pub async fn make_chunks( ...@@ -118,8 +120,8 @@ pub async fn make_chunks(
} }
type ChunkItemWithInfo = ( type ChunkItemWithInfo = (
Vc<Box<dyn ChunkItem>>, ResolvedVc<Box<dyn ChunkItem>>,
Option<Vc<AsyncModuleInfo>>, Option<ResolvedVc<AsyncModuleInfo>>,
usize, usize,
ReadRef<RcStr>, ReadRef<RcStr>,
); );
......
...@@ -3,7 +3,7 @@ pub mod source_map; ...@@ -3,7 +3,7 @@ pub mod source_map;
use std::fmt::Write; use std::fmt::Write;
use anyhow::{bail, Result}; use anyhow::{bail, Context, Result};
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexSet, ResolvedVc, TryJoinIterExt, Value, ValueDefault, ValueToString, Vc}; use turbo_tasks::{FxIndexSet, ResolvedVc, TryJoinIterExt, Value, ValueDefault, ValueToString, Vc};
use turbo_tasks_fs::{rope::Rope, File, FileSystem}; use turbo_tasks_fs::{rope::Rope, File, FileSystem};
...@@ -502,13 +502,10 @@ impl ChunkType for CssChunkType { ...@@ -502,13 +502,10 @@ impl ChunkType for CssChunkType {
chunk_items: chunk_items chunk_items: chunk_items
.iter() .iter()
.map(|(chunk_item, _async_info)| async move { .map(|(chunk_item, _async_info)| async move {
let Some(chunk_item) =
Vc::try_resolve_downcast::<Box<dyn CssChunkItem>>(*chunk_item).await?
else {
bail!("Chunk item is not an css chunk item but reporting chunk type css");
};
// CSS doesn't need to care about async_info, so we can discard it // CSS doesn't need to care about async_info, so we can discard it
chunk_item.to_resolved().await ResolvedVc::try_downcast::<Box<dyn CssChunkItem>>(*chunk_item)
.await?
.context("Chunk item is not an css chunk item but reporting chunk type css")
}) })
.try_join() .try_join()
.await?, .await?,
......
...@@ -34,11 +34,12 @@ impl AsyncLoaderChunkItem { ...@@ -34,11 +34,12 @@ impl AsyncLoaderChunkItem {
let module = self.module.await?; let module = self.module.await?;
if let Some(chunk_items) = module.availability_info.available_chunk_items() { if let Some(chunk_items) = module.availability_info.available_chunk_items() {
if chunk_items if chunk_items
.await?
.get( .get(
module module
.inner .inner
.as_chunk_item(*ResolvedVc::upcast(self.chunking_context)) .as_chunk_item(*ResolvedVc::upcast(self.chunking_context))
.resolve() .to_resolved()
.await?, .await?,
) )
.await? .await?
......
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{TryJoinIterExt, ValueDefault, ValueToString, Vc}; use turbo_tasks::{ResolvedVc, TryJoinIterExt, ValueDefault, ValueToString, Vc};
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{
round_chunk_item_size, AsyncModuleInfo, Chunk, ChunkItem, ChunkItemWithAsyncModuleInfo, round_chunk_item_size, AsyncModuleInfo, Chunk, ChunkItem, ChunkItemWithAsyncModuleInfo,
...@@ -45,9 +45,9 @@ impl ChunkType for EcmascriptChunkType { ...@@ -45,9 +45,9 @@ impl ChunkType for EcmascriptChunkType {
let content = EcmascriptChunkContent { let content = EcmascriptChunkContent {
chunk_items: chunk_items chunk_items: chunk_items
.iter() .iter()
.map(|(chunk_item, async_info)| async move { .map(|&(chunk_item, async_info)| async move {
let Some(chunk_item) = let Some(chunk_item) =
Vc::try_resolve_downcast::<Box<dyn EcmascriptChunkItem>>(*chunk_item) ResolvedVc::try_downcast::<Box<dyn EcmascriptChunkItem>>(chunk_item)
.await? .await?
else { else {
bail!( bail!(
...@@ -55,7 +55,7 @@ impl ChunkType for EcmascriptChunkType { ...@@ -55,7 +55,7 @@ impl ChunkType for EcmascriptChunkType {
ecmascript" ecmascript"
); );
}; };
Ok((chunk_item, *async_info)) Ok((chunk_item, async_info))
}) })
.try_join() .try_join()
.await?, .await?,
......
use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks::ResolvedVc;
use turbopack_core::{chunk::AsyncModuleInfo, output::OutputAsset}; use turbopack_core::{chunk::AsyncModuleInfo, output::OutputAsset};
use super::item::EcmascriptChunkItem; use super::item::EcmascriptChunkItem;
type EcmascriptChunkItemWithAsyncInfo = ( type EcmascriptChunkItemWithAsyncInfo = (
Vc<Box<dyn EcmascriptChunkItem>>, ResolvedVc<Box<dyn EcmascriptChunkItem>>,
Option<Vc<AsyncModuleInfo>>, Option<ResolvedVc<AsyncModuleInfo>>,
); );
#[turbo_tasks::value(shared, local)] #[turbo_tasks::value(shared)]
pub struct EcmascriptChunkContent { pub struct EcmascriptChunkContent {
pub chunk_items: Vec<EcmascriptChunkItemWithAsyncInfo>, pub chunk_items: Vec<EcmascriptChunkItemWithAsyncInfo>,
pub referenced_output_assets: Vec<ResolvedVc<Box<dyn OutputAsset>>>, pub referenced_output_assets: Vec<ResolvedVc<Box<dyn OutputAsset>>>,
......
...@@ -145,9 +145,8 @@ impl Chunk for EcmascriptChunk { ...@@ -145,9 +145,8 @@ impl Chunk for EcmascriptChunk {
Ok(ChunkItems( Ok(ChunkItems(
chunk_items chunk_items
.iter() .iter()
.map(|(item, _)| async move { Ok(ResolvedVc::upcast(item.to_resolved().await?)) }) .map(|&(item, _)| ResolvedVc::upcast(item))
.try_join() .collect(),
.await?,
) )
.cell()) .cell())
} }
......
...@@ -66,10 +66,11 @@ impl ManifestAsyncModule { ...@@ -66,10 +66,11 @@ impl ManifestAsyncModule {
let this = self.await?; let this = self.await?;
if let Some(chunk_items) = this.availability_info.available_chunk_items() { if let Some(chunk_items) = this.availability_info.available_chunk_items() {
if chunk_items if chunk_items
.await?
.get( .get(
this.inner this.inner
.as_chunk_item(*ResolvedVc::upcast(this.chunking_context)) .as_chunk_item(*ResolvedVc::upcast(this.chunking_context))
.resolve() .to_resolved()
.await?, .await?,
) )
.await? .await?
......
...@@ -293,7 +293,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -293,7 +293,7 @@ impl ChunkingContext for NodeJsChunkingContext {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn chunk_group( async fn chunk_group(
self: Vc<Self>, self: ResolvedVc<Self>,
_ident: Vc<AssetIdent>, _ident: Vc<AssetIdent>,
module: ResolvedVc<Box<dyn ChunkableModule>>, module: ResolvedVc<Box<dyn ChunkableModule>>,
availability_info: Value<AvailabilityInfo>, availability_info: Value<AvailabilityInfo>,
...@@ -307,7 +307,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -307,7 +307,7 @@ impl ChunkingContext for NodeJsChunkingContext {
chunks, chunks,
availability_info, availability_info,
} = make_chunk_group( } = make_chunk_group(
Vc::upcast(self), ResolvedVc::upcast(self),
[ResolvedVc::upcast(module)], [ResolvedVc::upcast(module)],
availability_info.into_value(), availability_info.into_value(),
) )
...@@ -334,7 +334,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -334,7 +334,7 @@ impl ChunkingContext for NodeJsChunkingContext {
/// * exports the result of evaluating the given module as a CommonJS default export. /// * exports the result of evaluating the given module as a CommonJS default export.
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn entry_chunk_group( pub async fn entry_chunk_group(
self: Vc<Self>, self: ResolvedVc<Self>,
path: Vc<FileSystemPath>, path: Vc<FileSystemPath>,
module: ResolvedVc<Box<dyn Module>>, module: ResolvedVc<Box<dyn Module>>,
evaluatable_assets: Vc<EvaluatableAssets>, evaluatable_assets: Vc<EvaluatableAssets>,
...@@ -347,7 +347,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -347,7 +347,7 @@ impl ChunkingContext for NodeJsChunkingContext {
chunks, chunks,
availability_info, availability_info,
} = make_chunk_group( } = make_chunk_group(
Vc::upcast(self), ResolvedVc::upcast(self),
once(module).chain( once(module).chain(
evaluatable_assets evaluatable_assets
.await? .await?
...@@ -378,7 +378,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -378,7 +378,7 @@ impl ChunkingContext for NodeJsChunkingContext {
let asset = ResolvedVc::upcast( let asset = ResolvedVc::upcast(
EcmascriptBuildNodeEntryChunk::new( EcmascriptBuildNodeEntryChunk::new(
path, path,
self, *self,
Vc::cell(other_chunks), Vc::cell(other_chunks),
evaluatable_assets, evaluatable_assets,
*module, *module,
......
...@@ -55,7 +55,7 @@ pub(super) async fn chunk_items( ...@@ -55,7 +55,7 @@ pub(super) async fn chunk_items(
.map(|&(chunk_item, async_module_info)| async move { .map(|&(chunk_item, async_module_info)| async move {
Ok(( Ok((
chunk_item.id().await?, chunk_item.id().await?,
chunk_item.code(async_module_info).await?, chunk_item.code(async_module_info.map(|info| *info)).await?,
)) ))
}) })
.try_join() .try_join()
......
...@@ -210,7 +210,7 @@ impl ChunkItem for ModuleChunkItem { ...@@ -210,7 +210,7 @@ impl ChunkItem for ModuleChunkItem {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(&self) -> Result<Vc<OutputAssets>> { async fn references(&self) -> Result<Vc<OutputAssets>> {
let loader_references = self.module.loader().references().await?; let loader_references = self.module.loader().references().await?;
references_to_output_assets(loader_references.iter().map(|r| **r).collect::<_>()).await references_to_output_assets(&*loader_references).await
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
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