Unverified Commit 560923d1 authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Make `ChunkItem`s reference only `OutputAssets` (#73824)

This:

- Changes `ChunkItem`’s `references` implementation to only allow items
to reference `OutputAssets`
- Implements a default `references` that returns an empty set of output
assets
- Updates logic for using these output assets in `make_chunk_group`
- [x] Moves logic for using the inner module’s references into areas
that need it

---------
Co-authored-by: 's avatarTobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
parent 56ea9e9c
...@@ -154,11 +154,6 @@ impl ChunkItem for HmrEntryChunkItem { ...@@ -154,11 +154,6 @@ impl ChunkItem for HmrEntryChunkItem {
self.module.ident() self.module.ident()
} }
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.module.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn ty(&self) -> Vc<Box<dyn ChunkType>> { fn ty(&self) -> Vc<Box<dyn ChunkType>> {
Vc::upcast(Vc::<EcmascriptChunkType>::default()) Vc::upcast(Vc::<EcmascriptChunkType>::default())
......
...@@ -111,11 +111,6 @@ impl ChunkItem for IncludeModulesChunkItem { ...@@ -111,11 +111,6 @@ impl ChunkItem for IncludeModulesChunkItem {
self.module.ident() self.module.ident()
} }
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.module.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn ty(&self) -> Vc<Box<dyn ChunkType>> { fn ty(&self) -> Vc<Box<dyn ChunkType>> {
Vc::upcast(Vc::<EcmascriptChunkType>::default()) Vc::upcast(Vc::<EcmascriptChunkType>::default())
......
...@@ -283,11 +283,6 @@ impl ChunkItem for ProxyModuleChunkItem { ...@@ -283,11 +283,6 @@ impl ChunkItem for ProxyModuleChunkItem {
self.client_proxy_asset.ident() self.client_proxy_asset.ident()
} }
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.client_proxy_asset.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> { fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(*self.chunking_context) Vc::upcast(*self.chunking_context)
......
...@@ -178,11 +178,6 @@ impl ChunkItem for NextServerComponentChunkItem { ...@@ -178,11 +178,6 @@ impl ChunkItem for NextServerComponentChunkItem {
self.inner.ident() self.inner.ident()
} }
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.inner.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> { fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
*self.chunking_context *self.chunking_context
......
...@@ -156,11 +156,6 @@ impl ChunkItem for NextServerComponentChunkItem { ...@@ -156,11 +156,6 @@ impl ChunkItem for NextServerComponentChunkItem {
self.inner.ident() self.inner.ident()
} }
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.inner.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> { fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
*self.chunking_context *self.chunking_context
......
...@@ -28,9 +28,10 @@ pub async fn make_chunk_group( ...@@ -28,9 +28,10 @@ pub async fn make_chunk_group(
) -> Result<MakeChunkGroupResult> { ) -> Result<MakeChunkGroupResult> {
let ChunkContentResult { let ChunkContentResult {
chunk_items, chunk_items,
external_output_assets,
external_module_references,
async_modules, async_modules,
traced_modules, traced_modules,
external_module_references,
forward_edges_inherit_async, forward_edges_inherit_async,
local_back_edges_inherit_async, local_back_edges_inherit_async,
available_async_modules_back_edges_inherit_async, available_async_modules_back_edges_inherit_async,
...@@ -141,16 +142,21 @@ pub async fn make_chunk_group( ...@@ -141,16 +142,21 @@ pub async fn make_chunk_group(
.map(|&loader| loader.references()) .map(|&loader| loader.references())
.try_join() .try_join()
.await?; .await?;
let async_loader_external_module_references = async_loader_references let async_loader_external_module_references = Vc::cell(
.iter() async_loader_references
.flat_map(|references| references.iter().copied()) .iter()
.map(|v| *v) .flat_map(|references| references.iter().copied())
.collect(); .collect(),
);
let mut referenced_output_assets = references_to_output_assets(external_module_references) let mut referenced_output_assets = (*external_output_assets.await?).clone();
.await? referenced_output_assets.extend(
.await? references_to_output_assets(external_module_references)
.clone_value(); .await?
.await?
.iter()
.copied(),
);
let rebased_modules = traced_modules let rebased_modules = traced_modules
.into_iter() .into_iter()
...@@ -185,7 +191,7 @@ pub async fn make_chunk_group( ...@@ -185,7 +191,7 @@ pub async fn make_chunk_group(
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(),
references_to_output_assets(async_loader_external_module_references).await?, async_loader_external_module_references,
) )
.await?; .await?;
...@@ -199,7 +205,7 @@ pub async fn make_chunk_group( ...@@ -199,7 +205,7 @@ pub async fn make_chunk_group(
}) })
} }
async fn references_to_output_assets( pub async fn references_to_output_assets(
references: FxIndexSet<Vc<Box<dyn ModuleReference>>>, references: FxIndexSet<Vc<Box<dyn ModuleReference>>>,
) -> Result<Vc<OutputAssets>> { ) -> Result<Vc<OutputAssets>> {
let output_assets = references let output_assets = references
......
...@@ -45,8 +45,8 @@ use crate::{ ...@@ -45,8 +45,8 @@ use crate::{
environment::ChunkLoading, environment::ChunkLoading,
ident::AssetIdent, ident::AssetIdent,
module::Module, module::Module,
output::OutputAssets, output::{OutputAsset, OutputAssets},
reference::{ModuleReference, ModuleReferences}, reference::ModuleReference,
}; };
/// A module id, which can be a number or string /// A module id, which can be a number or string
...@@ -215,6 +215,7 @@ pub struct ChunkContentResult { ...@@ -215,6 +215,7 @@ pub struct ChunkContentResult {
pub chunk_items: FxIndexSet<Vc<Box<dyn ChunkItem>>>, pub chunk_items: FxIndexSet<Vc<Box<dyn ChunkItem>>>,
pub async_modules: FxIndexSet<ResolvedVc<Box<dyn ChunkableModule>>>, pub async_modules: FxIndexSet<ResolvedVc<Box<dyn ChunkableModule>>>,
pub traced_modules: FxIndexSet<ResolvedVc<Box<dyn Module>>>, pub traced_modules: FxIndexSet<ResolvedVc<Box<dyn Module>>>,
pub external_output_assets: Vc<OutputAssets>,
pub external_module_references: FxIndexSet<Vc<Box<dyn ModuleReference>>>, pub external_module_references: FxIndexSet<Vc<Box<dyn ModuleReference>>>,
/// A map from local module to all children from which the async module /// A map from local module to all children from which the async module
/// status is inherited /// status is inherited
...@@ -269,6 +270,7 @@ enum ChunkContentGraphNode { ...@@ -269,6 +270,7 @@ enum ChunkContentGraphNode {
TracedModule { TracedModule {
module: Vc<Box<dyn Module>>, module: Vc<Box<dyn Module>>,
}, },
ExternalOutputAssets(ResolvedVc<OutputAssets>),
// ModuleReferences that are not placed in the current chunk group // ModuleReferences that are not placed in the current chunk group
ExternalModuleReference(ResolvedVc<Box<dyn ModuleReference>>), ExternalModuleReference(ResolvedVc<Box<dyn ModuleReference>>),
/// A list of directly referenced chunk items from which `is_async_module` /// A list of directly referenced chunk items from which `is_async_module`
...@@ -361,13 +363,17 @@ async fn graph_node_to_referenced_nodes( ...@@ -361,13 +363,17 @@ async fn graph_node_to_referenced_nodes(
node: ChunkGraphNodeToReferences, node: ChunkGraphNodeToReferences,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<ChunkGraphEdges>> { ) -> Result<Vc<ChunkGraphEdges>> {
let (parent, references) = match &node { let (parent, module_references, output_asset_references) = match &node {
ChunkGraphNodeToReferences::PassthroughChunkItem(item) => (None, item.references()), ChunkGraphNodeToReferences::PassthroughChunkItem(item) => {
ChunkGraphNodeToReferences::ChunkItem(item) => (Some(*item), item.references()), (None, item.module().references(), item.references())
}
ChunkGraphNodeToReferences::ChunkItem(item) => {
(Some(*item), item.module().references(), item.references())
}
}; };
let references = references.await?; let module_references = module_references.await?;
let graph_nodes = references let mut graph_nodes = module_references
.iter() .iter()
.map(|reference| async { .map(|reference| async {
let reference = *reference; let reference = *reference;
...@@ -543,6 +549,13 @@ async fn graph_node_to_referenced_nodes( ...@@ -543,6 +549,13 @@ async fn graph_node_to_referenced_nodes(
.try_flat_join() .try_flat_join()
.await?; .await?;
graph_nodes.push(ChunkGraphEdge {
key: None,
node: ChunkContentGraphNode::ExternalOutputAssets(
output_asset_references.to_resolved().await?,
),
});
Ok(Vc::cell(graph_nodes)) Ok(Vc::cell(graph_nodes))
} }
...@@ -662,6 +675,8 @@ async fn chunk_content_internal_parallel( ...@@ -662,6 +675,8 @@ async fn chunk_content_internal_parallel(
let mut chunk_items = FxIndexSet::default(); let mut chunk_items = FxIndexSet::default();
let mut async_modules = FxIndexSet::default(); let mut async_modules = FxIndexSet::default();
let mut external_module_references = FxIndexSet::default(); let mut external_module_references = FxIndexSet::default();
let mut external_output_assets: FxIndexSet<ResolvedVc<Box<dyn OutputAsset>>> =
FxIndexSet::default();
let mut forward_edges_inherit_async = FxIndexMap::default(); let mut forward_edges_inherit_async = FxIndexMap::default();
let mut local_back_edges_inherit_async = FxIndexMap::default(); let mut local_back_edges_inherit_async = FxIndexMap::default();
let mut available_async_modules_back_edges_inherit_async = FxIndexMap::default(); let mut available_async_modules_back_edges_inherit_async = FxIndexMap::default();
...@@ -685,6 +700,11 @@ async fn chunk_content_internal_parallel( ...@@ -685,6 +700,11 @@ async fn chunk_content_internal_parallel(
let reference = reference.resolve().await?; let reference = reference.resolve().await?;
external_module_references.insert(*reference); external_module_references.insert(*reference);
} }
ChunkContentGraphNode::ExternalOutputAssets(reference) => {
for output_asset in reference.await? {
external_output_assets.insert(*output_asset);
}
}
ChunkContentGraphNode::InheritAsyncInfo { item, references } => { ChunkContentGraphNode::InheritAsyncInfo { item, references } => {
for &(reference, ty) in &references { for &(reference, ty) in &references {
match ty { match ty {
...@@ -712,6 +732,7 @@ async fn chunk_content_internal_parallel( ...@@ -712,6 +732,7 @@ async fn chunk_content_internal_parallel(
chunk_items, chunk_items,
async_modules, async_modules,
traced_modules, traced_modules,
external_output_assets: Vc::cell(external_output_assets.into_iter().collect()),
external_module_references, external_module_references,
forward_edges_inherit_async, forward_edges_inherit_async,
local_back_edges_inherit_async, local_back_edges_inherit_async,
...@@ -732,11 +753,10 @@ pub trait ChunkItem { ...@@ -732,11 +753,10 @@ pub trait ChunkItem {
fn content_ident(self: Vc<Self>) -> Vc<AssetIdent> { fn content_ident(self: Vc<Self>) -> Vc<AssetIdent> {
self.asset_ident() self.asset_ident()
} }
/// A [ChunkItem] can describe different `references` than its original /// A [ChunkItem] can reference OutputAssets, unlike [Module]s referencing other [Module]s.
/// [Module]. fn references(self: Vc<Self>) -> Vc<OutputAssets> {
/// TODO(alexkirsz) This should have a default impl that returns empty OutputAssets::empty()
/// references. }
fn references(self: Vc<Self>) -> Vc<ModuleReferences>;
/// The type of chunk this item should be assembled into. /// The type of chunk this item should be assembled into.
fn ty(self: Vc<Self>) -> Vc<Box<dyn ChunkType>>; fn ty(self: Vc<Self>) -> Vc<Box<dyn ChunkType>>;
......
...@@ -184,11 +184,6 @@ impl ChunkItem for CssModuleChunkItem { ...@@ -184,11 +184,6 @@ impl ChunkItem for CssModuleChunkItem {
self.module.ident() self.module.ident()
} }
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.module.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> { fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(*self.chunking_context) Vc::upcast(*self.chunking_context)
......
...@@ -287,11 +287,6 @@ impl ChunkItem for ModuleChunkItem { ...@@ -287,11 +287,6 @@ impl ChunkItem for ModuleChunkItem {
self.module.ident() self.module.ident()
} }
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.module.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> { fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(*self.chunking_context) Vc::upcast(*self.chunking_context)
......
...@@ -10,7 +10,6 @@ use turbopack_core::{ ...@@ -10,7 +10,6 @@ use turbopack_core::{
ident::AssetIdent, ident::AssetIdent,
module::Module, module::Module,
output::OutputAssets, output::OutputAssets,
reference::{ModuleReferences, SingleOutputAssetReference},
}; };
use crate::{ use crate::{
...@@ -178,24 +177,8 @@ impl ChunkItem for AsyncLoaderChunkItem { ...@@ -178,24 +177,8 @@ impl ChunkItem for AsyncLoaderChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> { fn references(self: Vc<Self>) -> Vc<OutputAssets> {
let chunks = self.chunks(); self.chunks()
Ok(Vc::cell(
chunks
.await?
.iter()
.copied()
.map(|chunk| async move {
Ok(ResolvedVc::upcast(
SingleOutputAssetReference::new(*chunk, chunk_reference_description())
.to_resolved()
.await?,
))
})
.try_join()
.await?,
))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -15,9 +15,7 @@ use turbopack_core::{ ...@@ -15,9 +15,7 @@ use turbopack_core::{
}, },
module::Module, module::Module,
output::{OutputAsset, OutputAssets}, output::{OutputAsset, OutputAssets},
reference::{ reference::{ModuleReference, ModuleReferences, SingleModuleReference},
ModuleReference, ModuleReferences, SingleModuleReference, SingleOutputAssetReference,
},
}; };
use crate::{ use crate::{
...@@ -209,27 +207,8 @@ impl ChunkItem for ChunkGroupFilesChunkItem { ...@@ -209,27 +207,8 @@ impl ChunkItem for ChunkGroupFilesChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> { fn references(self: Vc<Self>) -> Vc<OutputAssets> {
let chunks = self.chunks(); self.chunks()
Ok(Vc::cell(
chunks
.await?
.iter()
.copied()
.map(|chunk| async move {
Ok(ResolvedVc::upcast(
SingleOutputAssetReference::new(
*chunk,
chunk_group_chunk_reference_description(),
)
.to_resolved()
.await?,
))
})
.try_join()
.await?,
))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -627,11 +627,6 @@ impl ChunkItem for ModuleChunkItem { ...@@ -627,11 +627,6 @@ impl ChunkItem for ModuleChunkItem {
self.module.ident() self.module.ident()
} }
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.module.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> { fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
*ResolvedVc::upcast(self.chunking_context) *ResolvedVc::upcast(self.chunking_context)
......
...@@ -5,7 +5,7 @@ use turbopack_core::{ ...@@ -5,7 +5,7 @@ use turbopack_core::{
chunk::{ChunkData, ChunkItem, ChunkType, ChunkingContext, ChunksData}, chunk::{ChunkData, ChunkItem, ChunkType, ChunkingContext, ChunksData},
ident::AssetIdent, ident::AssetIdent,
module::Module, module::Module,
reference::{ModuleReferences, SingleOutputAssetReference}, output::OutputAssets,
}; };
use super::chunk_asset::ManifestAsyncModule; use super::chunk_asset::ManifestAsyncModule;
...@@ -78,28 +78,10 @@ impl ChunkItem for ManifestChunkItem { ...@@ -78,28 +78,10 @@ impl ChunkItem for ManifestChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> { async fn references(self: Vc<Self>) -> Result<Vc<OutputAssets>> {
let this = self.await?; let mut references = vec![];
let mut references = this.manifest.references().await?.clone_value();
let key = Vc::cell("chunk data reference".into());
for chunk_data in &*self.chunks_data().await? { for chunk_data in &*self.chunks_data().await? {
references.extend( references.extend(chunk_data.references().await?.iter());
chunk_data
.references()
.await?
.iter()
.map(|&output_asset| async move {
Ok(ResolvedVc::upcast(
SingleOutputAssetReference::new(*output_asset, key)
.to_resolved()
.await?,
))
})
.try_join()
.await?,
);
} }
Ok(Vc::cell(references)) Ok(Vc::cell(references))
......
...@@ -10,7 +10,7 @@ use turbopack_core::{ ...@@ -10,7 +10,7 @@ use turbopack_core::{
}, },
ident::AssetIdent, ident::AssetIdent,
module::Module, module::Module,
reference::{ModuleReference, ModuleReferences, SingleOutputAssetReference}, output::OutputAssets,
}; };
use super::chunk_asset::ManifestAsyncModule; use super::chunk_asset::ManifestAsyncModule;
...@@ -95,46 +95,11 @@ impl ChunkItem for ManifestLoaderChunkItem { ...@@ -95,46 +95,11 @@ impl ChunkItem for ManifestLoaderChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> { async fn references(self: Vc<Self>) -> Result<Vc<OutputAssets>> {
let this = self.await?; let this = self.await?;
let mut references = (*this.manifest.manifest_chunks().await?).clone();
let chunks = this.manifest.manifest_chunks();
let mut references: Vec<ResolvedVc<Box<dyn ModuleReference>>> = chunks
.await?
.iter()
.map(|&chunk| async move {
Ok(ResolvedVc::upcast(
SingleOutputAssetReference::new(
*chunk,
manifest_loader_chunk_reference_description(),
)
.to_resolved()
.await?,
))
})
.try_join()
.await?;
for chunk_data in &*self.chunks_data().await? { for chunk_data in &*self.chunks_data().await? {
references.extend( references.extend(chunk_data.references().await?);
chunk_data
.references()
.await?
.iter()
.map(|&output_asset| async move {
Ok(ResolvedVc::upcast(
SingleOutputAssetReference::new(
*output_asset,
chunk_data_reference_description(),
)
.to_resolved()
.await?,
))
})
.try_join()
.await?,
);
} }
Ok(Vc::cell(references)) Ok(Vc::cell(references))
......
...@@ -126,6 +126,11 @@ impl Module for CachedExternalModule { ...@@ -126,6 +126,11 @@ impl Module for CachedExternalModule {
.with_modifier(Vc::cell(self.request.clone())) .with_modifier(Vc::cell(self.request.clone()))
.with_modifier(Vc::cell(self.external_type.to_string().into())) .with_modifier(Vc::cell(self.external_type.to_string().into()))
} }
#[turbo_tasks::function]
async fn references(&self) -> Result<Vc<ModuleReferences>> {
Ok(Vc::cell(self.additional_references.clone()))
}
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -210,18 +215,6 @@ impl ChunkItem for CachedExternalModuleChunkItem { ...@@ -210,18 +215,6 @@ impl ChunkItem for CachedExternalModuleChunkItem {
self.module.ident() self.module.ident()
} }
#[turbo_tasks::function]
async fn references(&self) -> Result<Vc<ModuleReferences>> {
let additional_references = &self.module.await?.additional_references;
if !additional_references.is_empty() {
let mut module_references = self.module.references().await?.clone_value();
module_references.extend(additional_references.iter().copied());
Ok(Vc::cell(module_references))
} else {
Ok(self.module.references())
}
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn ty(self: Vc<Self>) -> Vc<Box<dyn ChunkType>> { fn ty(self: Vc<Self>) -> Vc<Box<dyn ChunkType>> {
Vc::upcast(Vc::<EcmascriptChunkType>::default()) Vc::upcast(Vc::<EcmascriptChunkType>::default())
......
...@@ -513,11 +513,6 @@ impl ChunkItem for RequireContextChunkItem { ...@@ -513,11 +513,6 @@ impl ChunkItem for RequireContextChunkItem {
self.inner.ident() self.inner.ident()
} }
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.inner.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> { fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
*ResolvedVc::upcast(self.chunking_context) *ResolvedVc::upcast(self.chunking_context)
......
...@@ -14,7 +14,6 @@ use turbopack_core::{ ...@@ -14,7 +14,6 @@ use turbopack_core::{
chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkingContext}, chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkingContext},
ident::AssetIdent, ident::AssetIdent,
module::Module, module::Module,
reference::ModuleReferences,
}; };
use super::module::EcmascriptModuleFacadeModule; use super::module::EcmascriptModuleFacadeModule;
...@@ -130,11 +129,6 @@ impl EcmascriptChunkItem for EcmascriptModuleFacadeChunkItem { ...@@ -130,11 +129,6 @@ impl EcmascriptChunkItem for EcmascriptModuleFacadeChunkItem {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ChunkItem for EcmascriptModuleFacadeChunkItem { impl ChunkItem for EcmascriptModuleFacadeChunkItem {
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.module.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn asset_ident(&self) -> Vc<AssetIdent> { fn asset_ident(&self) -> Vc<AssetIdent> {
self.module.ident() self.module.ident()
......
...@@ -4,7 +4,6 @@ use turbopack_core::{ ...@@ -4,7 +4,6 @@ use turbopack_core::{
chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkingContext}, chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkingContext},
ident::AssetIdent, ident::AssetIdent,
module::Module, module::Module,
reference::ModuleReferences,
}; };
use super::module::EcmascriptModuleLocalsModule; use super::module::EcmascriptModuleLocalsModule;
...@@ -77,11 +76,6 @@ impl EcmascriptChunkItem for EcmascriptModuleLocalsChunkItem { ...@@ -77,11 +76,6 @@ impl EcmascriptChunkItem for EcmascriptModuleLocalsChunkItem {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ChunkItem for EcmascriptModuleLocalsChunkItem { impl ChunkItem for EcmascriptModuleLocalsChunkItem {
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.module.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn asset_ident(&self) -> Vc<AssetIdent> { fn asset_ident(&self) -> Vc<AssetIdent> {
self.module.ident() self.module.ident()
......
...@@ -5,7 +5,6 @@ use turbopack_core::{ ...@@ -5,7 +5,6 @@ use turbopack_core::{
chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkingContext}, chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkingContext},
ident::AssetIdent, ident::AssetIdent,
module::Module, module::Module,
reference::ModuleReferences,
}; };
use super::{asset::EcmascriptModulePartAsset, part_of_module, split_module}; use super::{asset::EcmascriptModulePartAsset, part_of_module, split_module};
...@@ -81,11 +80,6 @@ impl EcmascriptChunkItem for EcmascriptModulePartChunkItem { ...@@ -81,11 +80,6 @@ impl EcmascriptChunkItem for EcmascriptModulePartChunkItem {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ChunkItem for EcmascriptModulePartChunkItem { impl ChunkItem for EcmascriptModulePartChunkItem {
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.module.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn asset_ident(&self) -> Vc<AssetIdent> { fn asset_ident(&self) -> Vc<AssetIdent> {
self.module.ident() self.module.ident()
...@@ -122,11 +116,6 @@ pub(super) struct SideEffectsModuleChunkItem { ...@@ -122,11 +116,6 @@ pub(super) struct SideEffectsModuleChunkItem {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ChunkItem for SideEffectsModuleChunkItem { impl ChunkItem for SideEffectsModuleChunkItem {
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.module.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn asset_ident(&self) -> Vc<AssetIdent> { fn asset_ident(&self) -> Vc<AssetIdent> {
self.module.ident() self.module.ident()
......
...@@ -10,7 +10,6 @@ use turbopack_core::{ ...@@ -10,7 +10,6 @@ use turbopack_core::{
ident::AssetIdent, ident::AssetIdent,
module::Module, module::Module,
output::OutputAssets, output::OutputAssets,
reference::{ModuleReferences, SingleOutputAssetReference},
}; };
use super::module::WorkerLoaderModule; use super::module::WorkerLoaderModule;
...@@ -118,24 +117,8 @@ impl ChunkItem for WorkerLoaderChunkItem { ...@@ -118,24 +117,8 @@ impl ChunkItem for WorkerLoaderChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> { fn references(self: Vc<Self>) -> Vc<OutputAssets> {
let chunks = self.chunks(); self.chunks()
Ok(Vc::cell(
chunks
.await?
.iter()
.copied()
.map(|chunk| async move {
Ok(ResolvedVc::upcast(
SingleOutputAssetReference::new(*chunk, chunk_reference_description())
.to_resolved()
.await?,
))
})
.try_join()
.await?,
))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -20,7 +20,6 @@ use turbopack_core::{ ...@@ -20,7 +20,6 @@ use turbopack_core::{
chunk::{ChunkItem, ChunkType, ChunkableModule, ChunkingContext}, chunk::{ChunkItem, ChunkType, ChunkableModule, ChunkingContext},
ident::AssetIdent, ident::AssetIdent,
module::Module, module::Module,
reference::ModuleReferences,
source::Source, source::Source,
}; };
use turbopack_ecmascript::chunk::{ use turbopack_ecmascript::chunk::{
...@@ -97,11 +96,6 @@ impl ChunkItem for JsonChunkItem { ...@@ -97,11 +96,6 @@ impl ChunkItem for JsonChunkItem {
self.module.ident() self.module.ident()
} }
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
self.module.references()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> { fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(*self.chunking_context) Vc::upcast(*self.chunking_context)
......
...@@ -17,15 +17,14 @@ pub mod output_asset; ...@@ -17,15 +17,14 @@ pub mod output_asset;
use anyhow::Result; use anyhow::Result;
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{ResolvedVc, ValueToString, Vc}; use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::{ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
chunk::{ChunkItem, ChunkType, ChunkableModule, ChunkingContext}, chunk::{ChunkItem, ChunkType, ChunkableModule, ChunkingContext},
context::AssetContext, context::AssetContext,
ident::AssetIdent, ident::AssetIdent,
module::Module, module::Module,
output::OutputAsset, output::{OutputAsset, OutputAssets},
reference::{ModuleReferences, SingleOutputAssetReference},
source::Source, source::Source,
}; };
use turbopack_css::embed::CssEmbed; use turbopack_css::embed::CssEmbed;
...@@ -133,21 +132,8 @@ impl ChunkItem for ModuleChunkItem { ...@@ -133,21 +132,8 @@ impl ChunkItem for ModuleChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(&self) -> Result<Vc<ModuleReferences>> { fn references(&self) -> Vc<OutputAssets> {
Ok(Vc::cell(vec![ResolvedVc::upcast( Vc::cell(vec![ResolvedVc::upcast(self.static_asset)])
SingleOutputAssetReference::new(
*ResolvedVc::upcast(self.static_asset),
Vc::cell(
format!(
"static(url) {}",
self.static_asset.ident().to_string().await?
)
.into(),
),
)
.to_resolved()
.await?,
)]))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -4,11 +4,15 @@ use turbo_tasks::{fxindexmap, ResolvedVc, Value, Vc}; ...@@ -4,11 +4,15 @@ use turbo_tasks::{fxindexmap, ResolvedVc, Value, Vc};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbopack_core::{ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkableModule, ChunkingContext}, chunk::{
chunk_group::references_to_output_assets, AsyncModuleInfo, ChunkItem, ChunkType,
ChunkableModule, ChunkingContext,
},
context::AssetContext, context::AssetContext,
ident::AssetIdent, ident::AssetIdent,
module::{Module, OptionModule}, module::{Module, OptionModule},
reference::ModuleReferences, output::OutputAssets,
reference::{ModuleReferences, SingleChunkableModuleReference},
reference_type::ReferenceType, reference_type::ReferenceType,
resolve::{origin::ResolveOrigin, parse::Request}, resolve::{origin::ResolveOrigin, parse::Request},
source::Source, source::Source,
...@@ -104,6 +108,18 @@ impl WebAssemblyModuleAsset { ...@@ -104,6 +108,18 @@ impl WebAssemblyModuleAsset {
Ok(esm_asset) Ok(esm_asset)
} }
#[turbo_tasks::function]
async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> {
Ok(Vc::cell(vec![ResolvedVc::upcast(
SingleChunkableModuleReference::new(
Vc::upcast(self.loader()),
Vc::cell("wasm loader".into()),
)
.to_resolved()
.await?,
)]))
}
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -192,13 +208,9 @@ impl ChunkItem for ModuleChunkItem { ...@@ -192,13 +208,9 @@ impl ChunkItem for ModuleChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> { async fn references(&self) -> Result<Vc<OutputAssets>> {
let loader = self let loader_references = self.module.loader().references().await?;
.module references_to_output_assets(loader_references.iter().map(|r| **r).collect::<_>()).await
.loader()
.as_chunk_item(Vc::upcast(*self.chunking_context));
loader.references()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{ResolvedVc, ValueToString, Vc}; use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::{ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
chunk::{ChunkItem, ChunkType, ChunkableModule, ChunkingContext}, chunk::{ChunkItem, ChunkType, ChunkableModule, ChunkingContext},
context::AssetContext, context::AssetContext,
ident::AssetIdent, ident::AssetIdent,
module::Module, module::Module,
output::OutputAsset, output::{OutputAsset, OutputAssets},
reference::{ModuleReferences, SingleOutputAssetReference},
source::Source, source::Source,
}; };
use turbopack_ecmascript::{ use turbopack_ecmascript::{
...@@ -116,17 +115,8 @@ impl ChunkItem for RawModuleChunkItem { ...@@ -116,17 +115,8 @@ impl ChunkItem for RawModuleChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(&self) -> Result<Vc<ModuleReferences>> { async fn references(&self) -> Result<Vc<OutputAssets>> {
Ok(Vc::cell(vec![ResolvedVc::upcast( Ok(Vc::cell(vec![ResolvedVc::upcast(self.wasm_asset)]))
SingleOutputAssetReference::new(
Vc::upcast(*self.wasm_asset),
Vc::cell(
format!("wasm(url) {}", self.wasm_asset.ident().to_string().await?).into(),
),
)
.to_resolved()
.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