Unverified Commit 5b0ffda2 authored by Jimmy Miller's avatar Jimmy Miller Committed by GitHub

Clean up unnecessary output asset creation (#98834)

With turbopackLazyDynamicImports enabled, I was finding that we were
emitted empty assets that slowed down warm builds. This prevents these
unnecessary output assets to remove overhead.
parent e6688470
...@@ -124,7 +124,8 @@ impl OutputAssetsReference for EcmascriptBrowserChunk { ...@@ -124,7 +124,8 @@ impl OutputAssetsReference for EcmascriptBrowserChunk {
let include_source_map = *this let include_source_map = *this
.chunking_context .chunking_context
.reference_chunk_source_maps(Vc::upcast(self)) .reference_chunk_source_maps(Vc::upcast(self))
.await?; .await?
&& *self.own_content().has_source_map().await?;
let ref_assets = chunk_references.assets.await?; let ref_assets = chunk_references.assets.await?;
let mut assets = let mut assets =
Vec::with_capacity(ref_assets.len() + if include_source_map { 1 } else { 0 }); Vec::with_capacity(ref_assets.len() + if include_source_map { 1 } else { 0 });
......
...@@ -139,6 +139,11 @@ impl EcmascriptBrowserChunkContent { ...@@ -139,6 +139,11 @@ impl EcmascriptBrowserChunkContent {
Ok(code.cell()) Ok(code.cell())
} }
#[turbo_tasks::function]
pub(crate) async fn has_source_map(self: Vc<Self>) -> Result<Vc<bool>> {
Ok(Vc::cell(self.code().await?.has_source_map()))
}
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
......
...@@ -16,7 +16,7 @@ use turbopack_core::{ ...@@ -16,7 +16,7 @@ use turbopack_core::{
}; };
use crate::{ use crate::{
async_chunk::proxy::LazyCompilationProxyModule, async_chunk::proxy::{LazyCompilationProxyModule, lazy_compilation_state},
chunk::{ chunk::{
EcmascriptChunkItemContent, EcmascriptChunkPlaceable, EcmascriptExports, EcmascriptChunkItemContent, EcmascriptChunkPlaceable, EcmascriptExports,
data::EcmascriptChunkData, ecmascript_chunk_item, data::EcmascriptChunkData, ecmascript_chunk_item,
...@@ -251,14 +251,24 @@ impl EcmascriptChunkPlaceable for ManifestAsyncModule { ...@@ -251,14 +251,24 @@ impl EcmascriptChunkPlaceable for ManifestAsyncModule {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
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>,
) -> Vc<OutputAssetsWithReferenced> { ) -> Result<Vc<OutputAssetsWithReferenced>> {
self.chunk_group() // An unactivated proxy has no references, so the chunk list would name nothing
if let Some(proxy) =
ResolvedVc::try_downcast_type::<LazyCompilationProxyModule>(self.await?.inner)
&& !lazy_compilation_state(proxy.await?.key.clone())
.await?
.is_active()
{
return Ok(self.chunk_group());
}
Ok(self
.chunk_group()
.concatenate(OutputAssetsWithReferenced::from_assets( .concatenate(OutputAssetsWithReferenced::from_assets(
self.hmr_chunk_list(), self.hmr_chunk_list(),
)) )))
} }
} }
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