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

Turbopack: remove ModuleResolveResultItem::OutputAsset (#93349)

It never made sense to have module references that point to an output
asset, and the `ChunkingType` value on those made even less sense. We
had already migrated almost everything off anyway
parent 5eec78a1
use std::{collections::HashSet, sync::atomic::AtomicBool}; use std::sync::atomic::AtomicBool;
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
...@@ -26,11 +26,7 @@ use crate::{ ...@@ -26,11 +26,7 @@ use crate::{
}, },
module_batches::{BatchingConfig, ModuleBatchesGraphEdge}, module_batches::{BatchingConfig, ModuleBatchesGraphEdge},
}, },
output::{ output::{OutputAsset, OutputAssetsReference},
OutputAsset, OutputAssets, OutputAssetsReference, OutputAssetsReferences,
OutputAssetsWithReferenced,
},
reference::ModuleReference,
traced_asset::TracedAsset, traced_asset::TracedAsset,
}; };
...@@ -170,29 +166,6 @@ pub async fn make_chunk_group( ...@@ -170,29 +166,6 @@ pub async fn make_chunk_group(
}) })
} }
pub async fn references_to_output_assets(
references: impl IntoIterator<Item = &ResolvedVc<Box<dyn ModuleReference>>>,
) -> Result<Vc<OutputAssetsWithReferenced>> {
let output_assets = references
.into_iter()
.map(|reference| reference.resolve_reference().primary_output_assets())
.try_join()
.await?;
let mut set = HashSet::new();
let output_assets = output_assets
.iter()
.flatten()
.copied()
.filter(|&asset| set.insert(asset))
.collect::<Vec<_>>();
Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(output_assets),
referenced_assets: OutputAssets::empty_resolved(),
references: OutputAssetsReferences::empty_resolved(),
}
.cell())
}
pub struct ChunkGroupContentOptions { pub struct ChunkGroupContentOptions {
/// The availability info of the chunk group /// The availability info of the chunk group
pub availability_info: AvailabilityInfo, pub availability_info: AvailabilityInfo,
......
...@@ -97,19 +97,6 @@ pub async fn children_from_module_references( ...@@ -97,19 +97,6 @@ pub async fn children_from_module_references(
IntrospectableModule::new(*module).to_resolved().await?, IntrospectableModule::new(*module).to_resolved().await?,
)); ));
} }
for &output_asset in reference
.resolve_reference()
.primary_output_assets()
.await?
.iter()
{
children.insert((
key.clone(),
IntrospectableOutputAsset::new(*output_asset)
.to_resolved()
.await?,
));
}
} }
Ok(Vc::cell(children)) Ok(Vc::cell(children))
} }
......
...@@ -32,7 +32,6 @@ use crate::{ ...@@ -32,7 +32,6 @@ use crate::{
resolve::ResolvingIssue, resolve::ResolvingIssue,
}, },
module::{Module, Modules, OptionModule}, module::{Module, Modules, OptionModule},
output::{OutputAsset, OutputAssets},
package_json::{PackageJsonIssue, read_package_json}, package_json::{PackageJsonIssue, read_package_json},
raw_module::RawModule, raw_module::RawModule,
reference_type::ReferenceType, reference_type::ReferenceType,
...@@ -91,7 +90,6 @@ type AfterResolvePluginWithCondition = ( ...@@ -91,7 +90,6 @@ type AfterResolvePluginWithCondition = (
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum ModuleResolveResultItem { pub enum ModuleResolveResultItem {
Module(ResolvedVc<Box<dyn Module>>), Module(ResolvedVc<Box<dyn Module>>),
OutputAsset(ResolvedVc<Box<dyn OutputAsset>>),
External { External {
/// uri, path, reference, etc. /// uri, path, reference, etc.
name: RcStr, name: RcStr,
...@@ -242,21 +240,6 @@ impl ModuleResolveResult { ...@@ -242,21 +240,6 @@ impl ModuleResolveResult {
.resolved_cell() .resolved_cell()
} }
pub fn output_asset(
request_key: RequestKey,
output_asset: ResolvedVc<Box<dyn OutputAsset>>,
) -> ResolvedVc<Self> {
ModuleResolveResult {
primary: vec![(
request_key,
ModuleResolveResultItem::OutputAsset(output_asset),
)]
.into_boxed_slice(),
affecting_sources: Default::default(),
}
.resolved_cell()
}
pub fn modules( pub fn modules(
modules: impl IntoIterator<Item = (RequestKey, ResolvedVc<Box<dyn Module>>)>, modules: impl IntoIterator<Item = (RequestKey, ResolvedVc<Box<dyn Module>>)>,
) -> ResolvedVc<Self> { ) -> ResolvedVc<Self> {
...@@ -414,19 +397,6 @@ impl ModuleResolveResult { ...@@ -414,19 +397,6 @@ impl ModuleResolveResult {
} }
Ok(Vc::cell(set.into_iter().collect())) Ok(Vc::cell(set.into_iter().collect()))
} }
#[turbo_tasks::function]
pub fn primary_output_assets(&self) -> Vc<OutputAssets> {
Vc::cell(
self.primary
.iter()
.filter_map(|(_, item)| match item {
&ModuleResolveResultItem::OutputAsset(a) => Some(a),
_ => None,
})
.collect(),
)
}
} }
#[derive( #[derive(
......
...@@ -328,9 +328,7 @@ async fn to_single_pattern_mapping( ...@@ -328,9 +328,7 @@ async fn to_single_pattern_mapping(
.to_unstyled_string(), .to_unstyled_string(),
)); ));
} }
ModuleResolveResultItem::OutputAsset(_) ModuleResolveResultItem::Empty | ModuleResolveResultItem::Custom(_) => {
| ModuleResolveResultItem::Empty
| ModuleResolveResultItem::Custom(_) => {
// TODO implement mapping // TODO implement mapping
CodeGenerationIssue { CodeGenerationIssue {
severity: IssueSeverity::Bug, severity: IssueSeverity::Bug,
......
...@@ -3,9 +3,7 @@ use turbo_rcstr::rcstr; ...@@ -3,9 +3,7 @@ use turbo_rcstr::rcstr;
use turbo_tasks::{ResolvedVc, Vc, fxindexmap}; use turbo_tasks::{ResolvedVc, Vc, fxindexmap};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{AsyncModuleInfo, ChunkableModule, ChunkingContext},
AsyncModuleInfo, ChunkableModule, ChunkingContext, chunk_group::references_to_output_assets,
},
context::AssetContext, context::AssetContext,
ident::AssetIdent, ident::AssetIdent,
module::{Module, ModuleSideEffects}, module::{Module, ModuleSideEffects},
...@@ -196,11 +194,13 @@ impl EcmascriptChunkPlaceable for WebAssemblyModuleAsset { ...@@ -196,11 +194,13 @@ impl EcmascriptChunkPlaceable for WebAssemblyModuleAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn chunk_item_output_assets( async fn chunk_item_output_assets(
self: Vc<Self>, self: Vc<Self>,
_chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
_module_graph: Vc<ModuleGraph>, _module_graph: Vc<ModuleGraph>,
) -> Result<Vc<OutputAssetsWithReferenced>> { ) -> Result<Vc<OutputAssetsWithReferenced>> {
let loader_references = self.loader().references().await?; let wasm_asset = self.wasm_asset(chunking_context).to_resolved().await?;
references_to_output_assets(&*loader_references).await Ok(OutputAssetsWithReferenced::from_assets(Vc::cell(vec![
ResolvedVc::upcast(wasm_asset),
])))
} }
} }
......
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