Commit ae93bed8 authored by Matt Mastracci's avatar Matt Mastracci

Remove chunkable module

parent ec5056c4
...@@ -9803,6 +9803,7 @@ dependencies = [ ...@@ -9803,6 +9803,7 @@ dependencies = [
"turbo-tasks-fs", "turbo-tasks-fs",
"turbo-tasks-hash", "turbo-tasks-hash",
"turbopack-core", "turbopack-core",
"turbopack-css",
"turbopack-ecmascript", "turbopack-ecmascript",
"turbopack-ecmascript-runtime", "turbopack-ecmascript-runtime",
"turbopack-resolve", "turbopack-resolve",
...@@ -10221,6 +10222,7 @@ dependencies = [ ...@@ -10221,6 +10222,7 @@ dependencies = [
"turbo-tasks-fs", "turbo-tasks-fs",
"turbo-tasks-hash", "turbo-tasks-hash",
"turbopack-core", "turbopack-core",
"turbopack-css",
"turbopack-ecmascript", "turbopack-ecmascript",
"turbopack-ecmascript-runtime", "turbopack-ecmascript-runtime",
"urlencoding", "urlencoding",
......
...@@ -30,7 +30,7 @@ use turbo_tasks::{ ...@@ -30,7 +30,7 @@ use turbo_tasks::{
debug::ValueDebugFormat, trace::TraceRawVcs, debug::ValueDebugFormat, trace::TraceRawVcs,
}; };
use turbopack_core::{ use turbopack_core::{
chunk::{ChunkableModule, ChunkingContext, availability_info::AvailabilityInfo}, chunk::{ChunkingContext, availability_info::AvailabilityInfo},
module::Module, module::Module,
module_graph::{ModuleGraph, ModuleGraphLayer}, module_graph::{ModuleGraph, ModuleGraphLayer},
output::{OutputAssetsReference, OutputAssetsWithReferenced}, output::{OutputAssetsReference, OutputAssetsWithReferenced},
...@@ -55,7 +55,7 @@ pub(crate) async fn collect_next_dynamic_chunks( ...@@ -55,7 +55,7 @@ pub(crate) async fn collect_next_dynamic_chunks(
let dynamic_import_chunks = dynamic_import_entries let dynamic_import_chunks = dynamic_import_entries
.iter() .iter()
.map(|(dynamic_entry, parent_client_reference)| async move { .map(|(dynamic_entry, parent_client_reference)| async move {
let module = ResolvedVc::upcast::<Box<dyn ChunkableModule>>(*dynamic_entry); let module = ResolvedVc::upcast::<Box<dyn Module>>(*dynamic_entry);
// This is the availability info for the parent chunk group, i.e. the client reference // This is the availability info for the parent chunk group, i.e. the client reference
// containing the next/dynamic imports // containing the next/dynamic imports
......
...@@ -658,18 +658,28 @@ impl PageEndpoint { ...@@ -658,18 +658,28 @@ impl PageEndpoint {
Vc::upcast(this.pages_project.client_module_context()), Vc::upcast(this.pages_project.client_module_context()),
self.source(), self.source(),
this.pathname.clone(), this.pathname.clone(),
); )
.to_resolved()
.await?;
let is_chunkable = this
.pages_project
.project()
.client_chunking_context()
.chunking_configs()
.await?
.is_chunkable(page_loader)
.await;
if matches!( if matches!(
*this.pages_project.project().next_mode().await?, *this.pages_project.project().next_mode().await?,
NextMode::Development NextMode::Development
) && let Some(chunkable) = ResolvedVc::try_downcast(page_loader.to_resolved().await?) ) && is_chunkable
{ {
return Ok(Vc::upcast(HmrEntryModule::new( return Ok(Vc::upcast(HmrEntryModule::new(
AssetIdent::from_path(this.page.await?.base_path.clone()), AssetIdent::from_path(this.page.await?.base_path.clone()),
*chunkable, *page_loader,
))); )));
} }
Ok(page_loader) Ok(*page_loader)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -26,7 +26,7 @@ use turbo_tasks::{ ...@@ -26,7 +26,7 @@ use turbo_tasks::{
use turbo_tasks_fs::{self, File, FileContent, FileSystemPath, rope::RopeBuilder}; use turbo_tasks_fs::{self, File, FileContent, FileSystemPath, rope::RopeBuilder};
use turbopack_core::{ use turbopack_core::{
asset::AssetContent, asset::AssetContent,
chunk::{ChunkItem, ChunkingContext, ChunkingContextExt, EvaluatableAsset, ModuleId}, chunk::{ChunkItem, ChunkItemExt, ChunkingContext, EvaluatableAsset, ModuleId},
context::AssetContext, context::AssetContext,
file_source::FileSource, file_source::FileSource,
ident::AssetIdent, ident::AssetIdent,
...@@ -76,7 +76,7 @@ pub(crate) async fn create_server_actions_manifest( ...@@ -76,7 +76,7 @@ pub(crate) async fn create_server_actions_manifest(
ResolvedVc::try_sidecast::<Box<dyn EvaluatableAsset>>(loader.to_resolved().await?) ResolvedVc::try_sidecast::<Box<dyn EvaluatableAsset>>(loader.to_resolved().await?)
.context("loader module must be evaluatable")?; .context("loader module must be evaluatable")?;
let chunk_item = chunking_context.chunk_item(Vc::upcast(loader), module_graph); let chunk_item = ChunkItem::new(Vc::upcast(loader), module_graph, chunking_context);
let manifest = build_manifest( let manifest = build_manifest(
node_root, node_root,
page_name, page_name,
......
...@@ -7,8 +7,8 @@ use turbo_tasks_fs::{FileSystem, VirtualFileSystem, rope::RopeBuilder}; ...@@ -7,8 +7,8 @@ use turbo_tasks_fs::{FileSystem, VirtualFileSystem, rope::RopeBuilder};
use turbopack_core::{ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
chunk::{ chunk::{
AsyncModuleInfo, ChunkableModule, ChunkingContext, ChunkingContextExt, ChunkingType, AsyncModuleInfo, ChunkItem, ChunkingContext, ChunkingType, ChunkingTypeOption,
ChunkingTypeOption, EvaluatableAsset, EvaluatableAsset,
}, },
ident::AssetIdent, ident::AssetIdent,
module::{Module, ModuleSideEffects}, module::{Module, ModuleSideEffects},
...@@ -41,16 +41,13 @@ async fn hmr_entry_point_base_ident() -> Result<Vc<AssetIdent>> { ...@@ -41,16 +41,13 @@ async fn hmr_entry_point_base_ident() -> Result<Vc<AssetIdent>> {
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
pub struct HmrEntryModule { pub struct HmrEntryModule {
pub ident: ResolvedVc<AssetIdent>, pub ident: ResolvedVc<AssetIdent>,
pub module: ResolvedVc<Box<dyn ChunkableModule>>, pub module: ResolvedVc<Box<dyn Module>>,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl HmrEntryModule { impl HmrEntryModule {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn new( pub fn new(ident: ResolvedVc<AssetIdent>, module: ResolvedVc<Box<dyn Module>>) -> Vc<Self> {
ident: ResolvedVc<AssetIdent>,
module: ResolvedVc<Box<dyn ChunkableModule>>,
) -> Vc<Self> {
Self { ident, module }.cell() Self { ident, module }.cell()
} }
} }
...@@ -70,7 +67,7 @@ impl Module for HmrEntryModule { ...@@ -70,7 +67,7 @@ impl Module for HmrEntryModule {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(&self) -> Result<Vc<ModuleReferences>> { async fn references(&self) -> Result<Vc<ModuleReferences>> {
Ok(Vc::cell(vec![ResolvedVc::upcast( Ok(Vc::cell(vec![ResolvedVc::upcast(
HmrEntryModuleReference::new(Vc::upcast(*self.module)) HmrEntryModuleReference::new(*self.module)
.to_resolved() .to_resolved()
.await?, .await?,
)])) )]))
...@@ -81,8 +78,6 @@ impl Module for HmrEntryModule { ...@@ -81,8 +78,6 @@ impl Module for HmrEntryModule {
} }
} }
turbopack_core::chunk_item!(HmrEntryModule, ecmascript);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl Asset for HmrEntryModule { impl Asset for HmrEntryModule {
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -108,7 +103,7 @@ impl EcmascriptChunkPlaceable for HmrEntryModule { ...@@ -108,7 +103,7 @@ impl EcmascriptChunkPlaceable for HmrEntryModule {
) -> Result<Vc<EcmascriptChunkItemContent>> { ) -> Result<Vc<EcmascriptChunkItemContent>> {
let this = self.await?; let this = self.await?;
let module = this.module; let module = this.module;
let chunk_item = chunking_context.chunk_item(Vc::upcast(*module), module_graph); let chunk_item = ChunkItem::new(*module, module_graph, chunking_context);
let id = chunking_context let id = chunking_context
.chunk_item_id_strategy() .chunk_item_id_strategy()
.await? .await?
......
use std::{io::Write, iter::once}; use std::{io::Write, iter::once};
use anyhow::{Context, Result, bail}; use anyhow::{Result, bail};
use indoc::writedoc; use indoc::writedoc;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{IntoTraitRef, ResolvedVc, ValueToString, Vc}; use turbo_tasks::{IntoTraitRef, ResolvedVc, ValueToString, Vc};
use turbo_tasks_fs::{File, FileContent}; use turbo_tasks_fs::{File, FileContent};
use turbopack_core::{ use turbopack_core::{
asset::AssetContent, asset::AssetContent,
chunk::{ chunk::{AsyncModuleInfo, ChunkGroupType, ChunkingContext, ChunkingType, ChunkingTypeOption},
AsyncModuleInfo, ChunkGroupType, ChunkItem, ChunkType, ChunkableModule, ChunkedItem,
ChunkingContext, ChunkingContextExt, ChunkingType, ChunkingTypeOption,
},
code_builder::CodeBuilder, code_builder::CodeBuilder,
context::AssetContext, context::AssetContext,
ident::AssetIdent, ident::AssetIdent,
module::{Module, ModuleSideEffects}, module::{Module, ModuleSideEffects},
module_graph::{ModuleGraph, binding_usage_info::ModuleExportUsageInfo}, module_graph::{ModuleGraph, binding_usage_info::ModuleExportUsageInfo},
output::OutputAssetsReference,
reference::{ModuleReference, ModuleReferences}, reference::{ModuleReference, ModuleReferences},
reference_type::ReferenceType, reference_type::ReferenceType,
resolve::ModuleResolveResult, resolve::ModuleResolveResult,
...@@ -24,10 +20,7 @@ use turbopack_core::{ ...@@ -24,10 +20,7 @@ use turbopack_core::{
virtual_source::VirtualSource, virtual_source::VirtualSource,
}; };
use turbopack_ecmascript::{ use turbopack_ecmascript::{
chunk::{ chunk::{EcmascriptChunkItemContent, EcmascriptChunkPlaceable, EcmascriptExports},
EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkPlaceable,
EcmascriptChunkType, EcmascriptExports,
},
runtime_functions::TURBOPACK_EXPORT_NAMESPACE, runtime_functions::TURBOPACK_EXPORT_NAMESPACE,
utils::StringifyJs, utils::StringifyJs,
}; };
...@@ -249,31 +242,6 @@ impl Module for EcmascriptClientReferenceModule { ...@@ -249,31 +242,6 @@ impl Module for EcmascriptClientReferenceModule {
} }
} }
#[turbo_tasks::value_impl]
impl ChunkableModule for EcmascriptClientReferenceModule {
#[turbo_tasks::function]
async fn as_chunk_item(
self: ResolvedVc<Self>,
module_graph: Vc<ModuleGraph>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Result<Vc<ChunkItem>> {
let item = chunking_context.chunk_item(Vc::upcast(self.proxy_module()), module_graph);
let inner: ResolvedVc<Box<dyn ChunkedItem>> = *item.await?;
let ecmascript_item = ResolvedVc::try_downcast::<Box<dyn EcmascriptChunkItem>>(inner)
.context("EcmascriptModuleAsset must implement EcmascriptChunkItem")?;
let chunked: Vc<Box<dyn ChunkedItem>> = Vc::upcast(
EcmascriptClientReferenceProxyChunkItem {
inner_module: self,
inner_chunk_item: ecmascript_item,
chunking_context,
}
.cell(),
);
Ok(ChunkItem::from_trait(chunked))
}
}
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for EcmascriptClientReferenceModule { impl EcmascriptChunkPlaceable for EcmascriptClientReferenceModule {
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -284,67 +252,17 @@ impl EcmascriptChunkPlaceable for EcmascriptClientReferenceModule { ...@@ -284,67 +252,17 @@ impl EcmascriptChunkPlaceable for EcmascriptClientReferenceModule {
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunk_item_content( fn chunk_item_content(
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>,
_async_module_info: Option<Vc<AsyncModuleInfo>>,
_estimated: bool,
) -> Result<Vc<EcmascriptChunkItemContent>> {
bail!("Attempted to get chunk_item_content for EcmascriptClientReferenceModule")
}
}
/// This wrapper only exists to overwrite the `asset_ident` method of the
/// wrapped [`Vc<Box<dyn EcmascriptChunkItem>>`]. Otherwise, the asset ident of
/// the chunk item would not be the same as the asset ident of the
/// [`Vc<EcmascriptClientReferenceModule>`].
#[turbo_tasks::value]
struct EcmascriptClientReferenceProxyChunkItem {
inner_module: ResolvedVc<EcmascriptClientReferenceModule>,
inner_chunk_item: ResolvedVc<Box<dyn EcmascriptChunkItem>>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
}
#[turbo_tasks::value_impl]
impl OutputAssetsReference for EcmascriptClientReferenceProxyChunkItem {}
#[turbo_tasks::value_impl]
impl ChunkedItem for EcmascriptClientReferenceProxyChunkItem {
#[turbo_tasks::function]
fn asset_ident(&self) -> Vc<AssetIdent> {
self.inner_module.ident()
}
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
*self.chunking_context
}
#[turbo_tasks::function]
fn ty(&self) -> Vc<Box<dyn ChunkType>> {
Vc::upcast(Vc::<EcmascriptChunkType>::default())
}
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(*self.inner_module)
}
}
#[turbo_tasks::value_impl]
impl EcmascriptChunkItem for EcmascriptClientReferenceProxyChunkItem {
#[turbo_tasks::function]
fn content(&self) -> Vc<EcmascriptChunkItemContent> {
self.inner_chunk_item.content()
}
#[turbo_tasks::function]
fn content_with_async_module_info(
&self,
async_module_info: Option<Vc<AsyncModuleInfo>>, async_module_info: Option<Vc<AsyncModuleInfo>>,
estimated: bool, estimated: bool,
) -> Vc<EcmascriptChunkItemContent> { ) -> Vc<EcmascriptChunkItemContent> {
self.inner_chunk_item self.proxy_module().chunk_item_content(
.content_with_async_module_info(async_module_info, estimated) chunking_context,
module_graph,
async_module_info,
estimated,
)
} }
} }
......
...@@ -70,8 +70,6 @@ impl Module for NextDynamicEntryModule { ...@@ -70,8 +70,6 @@ impl Module for NextDynamicEntryModule {
} }
} }
turbopack_core::chunk_item!(NextDynamicEntryModule, ecmascript);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for NextDynamicEntryModule { impl EcmascriptChunkPlaceable for NextDynamicEntryModule {
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -87,8 +87,6 @@ impl Module for NextServerComponentModule { ...@@ -87,8 +87,6 @@ impl Module for NextServerComponentModule {
} }
} }
turbopack_core::chunk_item!(NextServerComponentModule, ecmascript);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for NextServerComponentModule { impl EcmascriptChunkPlaceable for NextServerComponentModule {
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -68,8 +68,6 @@ impl Module for NextServerUtilityModule { ...@@ -68,8 +68,6 @@ impl Module for NextServerUtilityModule {
} }
} }
turbopack_core::chunk_item!(NextServerUtilityModule, ecmascript);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for NextServerUtilityModule { impl EcmascriptChunkPlaceable for NextServerUtilityModule {
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -104,8 +104,6 @@ impl Module for RawEcmascriptModule { ...@@ -104,8 +104,6 @@ impl Module for RawEcmascriptModule {
} }
} }
turbopack_core::chunk_item!(RawEcmascriptModule, ecmascript);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for RawEcmascriptModule { impl EcmascriptChunkPlaceable for RawEcmascriptModule {
#[turbo_tasks::function] #[turbo_tasks::function]
......
repo = "next.js"
name = "mmastrac__slash__associated-tuples"
branch = "mmastrac/associated-tuples"
path = "/Users/matt/Library/Application Support/clydra/__slash__Users__slash__matt__slash__Documents__slash__github__slash__vercel.toml/worktrees/next.js/mmastrac__slash__associated-tuples"
terminals = 1
...@@ -35,6 +35,7 @@ turbo-tasks = { workspace = true } ...@@ -35,6 +35,7 @@ turbo-tasks = { workspace = true }
turbo-tasks-fs = { workspace = true } turbo-tasks-fs = { workspace = true }
turbo-tasks-hash = { workspace = true } turbo-tasks-hash = { workspace = true }
turbopack-core = { workspace = true } turbopack-core = { workspace = true }
turbopack-css = { workspace = true }
turbopack-ecmascript = { workspace = true } turbopack-ecmascript = { workspace = true }
turbopack-ecmascript-runtime = { workspace = true } turbopack-ecmascript-runtime = { workspace = true }
turbopack-resolve = { workspace = true } turbopack-resolve = { workspace = true }
......
...@@ -11,10 +11,10 @@ use turbo_tasks_hash::{DeterministicHash, HashAlgorithm}; ...@@ -11,10 +11,10 @@ use turbo_tasks_hash::{DeterministicHash, HashAlgorithm};
use turbopack_core::{ use turbopack_core::{
asset::Asset, asset::Asset,
chunk::{ chunk::{
AssetSuffix, Chunk, ChunkGroupResult, ChunkItem, ChunkType, ChunkableModule, AssetSuffix, Chunk, ChunkGroupResult, ChunkItem, ChunkType, ChunkingConfig,
ChunkingConfig, ChunkingConfigs, ChunkingContext, ChunkingContextExt, ChunkingConfigs, ChunkingContext, EntryChunkGroupResult, EvaluatableAsset,
EntryChunkGroupResult, EvaluatableAsset, EvaluatableAssets, MinifyType, EvaluatableAssets, MinifyType, SourceMapSourceType, SourceMapsType, UnusedReferences,
SourceMapSourceType, SourceMapsType, UnusedReferences, UrlBehavior, UrlBehavior,
availability_info::AvailabilityInfo, availability_info::AvailabilityInfo,
chunk_group::{MakeChunkGroupResult, make_chunk_group}, chunk_group::{MakeChunkGroupResult, make_chunk_group},
chunk_id_strategy::ModuleIdStrategy, chunk_id_strategy::ModuleIdStrategy,
...@@ -29,9 +29,10 @@ use turbopack_core::{ ...@@ -29,9 +29,10 @@ use turbopack_core::{
}, },
output::{OutputAsset, OutputAssets}, output::{OutputAsset, OutputAssets},
}; };
use turbopack_css::chunk::CssChunkType;
use turbopack_ecmascript::{ use turbopack_ecmascript::{
async_chunk::module::AsyncLoaderModule, async_chunk::module::AsyncLoaderModule,
chunk::EcmascriptChunk, chunk::{EcmascriptChunk, EcmascriptChunkType},
manifest::{chunk_asset::ManifestAsyncModule, loader_module::ManifestLoaderModule}, manifest::{chunk_asset::ManifestAsyncModule, loader_module::ManifestLoaderModule},
}; };
use turbopack_ecmascript_runtime::RuntimeType; use turbopack_ecmascript_runtime::RuntimeType;
...@@ -692,8 +693,19 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -692,8 +693,19 @@ impl ChunkingContext for BrowserChunkingContext {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_configs(&self) -> Result<Vc<ChunkingConfigs>> { async fn chunking_configs(&self) -> Result<Vc<ChunkingConfigs>> {
Ok(Vc::cell(self.chunking_configs.iter().cloned().collect())) let mut configs = self.chunking_configs.clone();
let ecma_type: ResolvedVc<Box<dyn ChunkType>> =
ResolvedVc::upcast(Vc::<EcmascriptChunkType>::default().to_resolved().await?);
if !configs.iter().any(|(ty, _)| *ty == ecma_type) {
configs.push((ecma_type, ChunkingConfig::default()));
}
let css_type: ResolvedVc<Box<dyn ChunkType>> =
ResolvedVc::upcast(Vc::<CssChunkType>::default().to_resolved().await?);
if !configs.iter().any(|(ty, _)| *ty == css_type) {
configs.push((css_type, ChunkingConfig::default()));
}
Ok(ChunkingConfigs::new(configs))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -904,7 +916,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -904,7 +916,7 @@ impl ChunkingContext for BrowserChunkingContext {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn async_loader_chunk_item( async fn async_loader_chunk_item(
self: ResolvedVc<Self>, self: ResolvedVc<Self>,
module: Vc<Box<dyn ChunkableModule>>, module: Vc<Box<dyn Module>>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Result<Vc<ChunkItem>> { ) -> Result<Vc<ChunkItem>> {
...@@ -917,17 +929,17 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -917,17 +929,17 @@ impl ChunkingContext for BrowserChunkingContext {
availability_info, availability_info,
); );
let loader_module = ManifestLoaderModule::new(manifest_asset); let loader_module = ManifestLoaderModule::new(manifest_asset);
chunking_context.chunk_item(Vc::upcast(loader_module), module_graph) ChunkItem::new(Vc::upcast(loader_module), module_graph, *chunking_context)
} else { } else {
let module = AsyncLoaderModule::new(module, *chunking_context, availability_info); let module = AsyncLoaderModule::new(module, *chunking_context, availability_info);
chunking_context.chunk_item(Vc::upcast(module), module_graph) ChunkItem::new(Vc::upcast(module), module_graph, *chunking_context)
}) })
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn async_loader_chunk_item_ident( async fn async_loader_chunk_item_ident(
self: Vc<Self>, self: Vc<Self>,
module: Vc<Box<dyn ChunkableModule>>, module: Vc<Box<dyn Module>>,
) -> Result<Vc<AssetIdent>> { ) -> Result<Vc<AssetIdent>> {
Ok(if self.await?.manifest_chunks { Ok(if self.await?.manifest_chunks {
ManifestLoaderModule::asset_ident_for(module) ManifestLoaderModule::asset_ident_for(module)
......
...@@ -2,20 +2,19 @@ use anyhow::Result; ...@@ -2,20 +2,19 @@ use anyhow::Result;
use either::Either; use either::Either;
use turbo_tasks::{FxIndexMap, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc}; use turbo_tasks::{FxIndexMap, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc};
use turbopack_core::{ use turbopack_core::{
chunk::{AsyncModuleInfo, ChunkItemExt, ModuleId}, chunk::{ChunkItemExt, ModuleId},
code_builder::Code, code_builder::Code,
}; };
use turbopack_ecmascript::chunk::{ use turbopack_ecmascript::chunk::{
EcmascriptChunkContent, EcmascriptChunkItem, EcmascriptChunkItemExt, EcmascriptChunkContent, EcmascriptChunkItemOrBatchWithAsyncInfo,
EcmascriptChunkItemOrBatchWithAsyncInfo, EcmascriptChunkItemWithAsyncInfo, EcmascriptChunkItemWithAsyncInfo, ecmascript_chunk_item_code,
}; };
/// A chunk item's content entry. /// A chunk item's content entry.
/// ///
/// Instead of storing the [`Vc<Box<dyn EcmascriptChunkItem>>`] itself from /// Instead of storing the module itself from which `code` and `hash` are
/// which `code` and `hash` are derived, we store `Vc`s directly. This avoids /// derived, we store `Vc`s directly. This avoids creating tasks in a hot
/// creating tasks in a hot loop when iterating over thousands of entries when /// loop when iterating over thousands of entries when computing updates.
/// computing updates.
#[turbo_tasks::value] #[turbo_tasks::value]
#[derive(Debug)] #[derive(Debug)]
pub struct EcmascriptDevChunkContentEntry { pub struct EcmascriptDevChunkContentEntry {
...@@ -24,11 +23,15 @@ pub struct EcmascriptDevChunkContentEntry { ...@@ -24,11 +23,15 @@ pub struct EcmascriptDevChunkContentEntry {
} }
impl EcmascriptDevChunkContentEntry { impl EcmascriptDevChunkContentEntry {
pub async fn new( pub async fn new(info: &EcmascriptChunkItemWithAsyncInfo) -> Result<Self> {
chunk_item: ResolvedVc<Box<dyn EcmascriptChunkItem>>, let code = ecmascript_chunk_item_code(
async_module_info: Option<Vc<AsyncModuleInfo>>, info.module,
) -> Result<Self> { info.chunking_context,
let code = chunk_item.code(async_module_info).to_resolved().await?; info.module_graph,
info.async_info.map(|info| *info),
)
.to_resolved()
.await?;
Ok(EcmascriptDevChunkContentEntry { Ok(EcmascriptDevChunkContentEntry {
code, code,
hash: code.source_code_hash().to_resolved().await?, hash: code.source_code_hash().to_resolved().await?,
...@@ -55,19 +58,12 @@ impl EcmascriptBrowserChunkContentEntries { ...@@ -55,19 +58,12 @@ impl EcmascriptBrowserChunkContentEntries {
.iter() .iter()
.map(async |item| { .map(async |item| {
Ok(match item { Ok(match item {
&EcmascriptChunkItemOrBatchWithAsyncInfo::ChunkItem( EcmascriptChunkItemOrBatchWithAsyncInfo::ChunkItem(info) => {
EcmascriptChunkItemWithAsyncInfo { Either::Left(std::iter::once((
chunk_item, info.chunk_item().await?.id().await?,
async_info, EcmascriptDevChunkContentEntry::new(info).await?,
}, )))
) => Either::Left(std::iter::once(( }
chunk_item.id().await?,
EcmascriptDevChunkContentEntry::new(
chunk_item,
async_info.map(|info| *info),
)
.await?,
))),
EcmascriptChunkItemOrBatchWithAsyncInfo::Batch(batch) => { EcmascriptChunkItemOrBatchWithAsyncInfo::Batch(batch) => {
let batch = batch.await?; let batch = batch.await?;
Either::Right( Either::Right(
...@@ -76,12 +72,8 @@ impl EcmascriptBrowserChunkContentEntries { ...@@ -76,12 +72,8 @@ impl EcmascriptBrowserChunkContentEntries {
.iter() .iter()
.map(|item| async move { .map(|item| async move {
Ok(( Ok((
item.chunk_item.id().await?, item.chunk_item().await?.id().await?,
EcmascriptDevChunkContentEntry::new( EcmascriptDevChunkContentEntry::new(item).await?,
item.chunk_item,
item.async_info.map(|info| *info),
)
.await?,
)) ))
}) })
.try_join() .try_join()
......
use anyhow::{Result, anyhow}; use anyhow::{Context, Result};
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc}; use turbo_tasks::{ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc};
use turbo_tasks_env::ProcessEnv; use turbo_tasks_env::ProcessEnv;
...@@ -6,9 +6,7 @@ use turbo_tasks_fs::FileSystemPath; ...@@ -6,9 +6,7 @@ use turbo_tasks_fs::FileSystemPath;
use turbopack_browser::{BrowserChunkingContext, react_refresh::assert_can_resolve_react_refresh}; use turbopack_browser::{BrowserChunkingContext, react_refresh::assert_can_resolve_react_refresh};
use turbopack_cli_utils::runtime_entry::{RuntimeEntries, RuntimeEntry}; use turbopack_cli_utils::runtime_entry::{RuntimeEntries, RuntimeEntry};
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{ChunkItem, ChunkingContext, EvaluatableAsset, SourceMapSourceType, SourceMapsType},
ChunkableModule, ChunkingContext, EvaluatableAsset, SourceMapSourceType, SourceMapsType,
},
environment::Environment, environment::Environment,
file_source::FileSource, file_source::FileSource,
module::Module, module::Module,
...@@ -171,33 +169,25 @@ pub async fn create_web_entry_source( ...@@ -171,33 +169,25 @@ pub async fn create_web_entry_source(
let entries: Vec<_> = entries let entries: Vec<_> = entries
.into_iter() .into_iter()
.map(|module| async move { .map(|module| async move {
if let (Some(chunkable_module), Some(entry)) = ( let chunk_item = ChunkItem::new(*module, *module_graph, *chunking_context)
ResolvedVc::try_sidecast::<Box<dyn ChunkableModule>>(module), .to_resolved()
ResolvedVc::try_sidecast::<Box<dyn EvaluatableAsset>>(module), .await
) { .context(
"Entry module is not chunkable, so it can't be used to bootstrap the \
application",
)?;
if let Some(entry) = ResolvedVc::try_sidecast::<Box<dyn EvaluatableAsset>>(module) {
Ok(DevHtmlEntry { Ok(DevHtmlEntry {
chunkable_module, chunk_item,
module_graph,
chunking_context,
runtime_entries: Some(runtime_entries.with_entry(*entry).to_resolved().await?), runtime_entries: Some(runtime_entries.with_entry(*entry).to_resolved().await?),
}) })
} else if let Some(chunkable_module) = } else {
ResolvedVc::try_sidecast::<Box<dyn ChunkableModule>>(module)
{
// TODO this is missing runtime code, so it's probably broken and we should also // TODO this is missing runtime code, so it's probably broken and we should also
// add an ecmascript chunk with the runtime code // add an ecmascript chunk with the runtime code
Ok(DevHtmlEntry { Ok(DevHtmlEntry {
chunkable_module, chunk_item,
module_graph,
chunking_context,
runtime_entries: None, runtime_entries: None,
}) })
} else {
// TODO convert into a serve-able asset
Err(anyhow!(
"Entry module is not chunkable, so it can't be used to bootstrap the \
application"
))
} }
}) })
.try_join() .try_join()
......
...@@ -7,7 +7,6 @@ use turbo_tasks::{ ...@@ -7,7 +7,6 @@ use turbo_tasks::{
use turbo_tasks_hash::Xxh3Hash64Hasher; use turbo_tasks_hash::Xxh3Hash64Hasher;
use crate::{ use crate::{
chunk::ChunkableModule,
module::Module, module::Module,
module_graph::module_batch::{ChunkableModuleOrBatch, IdentStrings, ModuleBatch}, module_graph::module_batch::{ChunkableModuleOrBatch, IdentStrings, ModuleBatch},
}; };
...@@ -16,9 +15,9 @@ use crate::{ ...@@ -16,9 +15,9 @@ use crate::{
Debug, Copy, Clone, Hash, PartialEq, Eq, TraceRawVcs, NonLocalValue, TaskInput, Encode, Decode, Debug, Copy, Clone, Hash, PartialEq, Eq, TraceRawVcs, NonLocalValue, TaskInput, Encode, Decode,
)] )]
pub enum AvailableModuleItem { pub enum AvailableModuleItem {
Module(ResolvedVc<Box<dyn ChunkableModule>>), Module(ResolvedVc<Box<dyn Module>>),
Batch(ResolvedVc<ModuleBatch>), Batch(ResolvedVc<ModuleBatch>),
AsyncLoader(ResolvedVc<Box<dyn ChunkableModule>>), AsyncLoader(ResolvedVc<Box<dyn Module>>),
} }
impl AvailableModuleItem { impl AvailableModuleItem {
......
use std::{collections::HashSet, sync::atomic::AtomicBool}; use std::{collections::HashSet, sync::atomic::AtomicBool};
use anyhow::{Context, Result}; use anyhow::Result;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use turbo_rcstr::rcstr; use turbo_rcstr::rcstr;
use turbo_tasks::{FxIndexSet, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc}; use turbo_tasks::{FxIndexSet, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc};
...@@ -11,7 +11,7 @@ use super::{ ...@@ -11,7 +11,7 @@ use super::{
}; };
use crate::{ use crate::{
chunk::{ chunk::{
ChunkableModule, ChunkingType, Chunks, ChunkingConfigs, ChunkingType, Chunks,
available_modules::AvailableModuleItem, available_modules::AvailableModuleItem,
chunk_item_batch::{ChunkItemBatchGroup, ChunkItemOrBatchWithAsyncModuleInfo}, chunk_item_batch::{ChunkItemBatchGroup, ChunkItemOrBatchWithAsyncModuleInfo},
}, },
...@@ -24,7 +24,7 @@ use crate::{ ...@@ -24,7 +24,7 @@ use crate::{
ChunkableModuleBatchGroup, ChunkableModuleOrBatch, ModuleBatch, ModuleBatchGroup, ChunkableModuleBatchGroup, ChunkableModuleOrBatch, ModuleBatch, ModuleBatchGroup,
ModuleOrBatch, ModuleOrBatch,
}, },
module_batches::{BatchingConfig, ModuleBatchesGraphEdge}, module_batches::ModuleBatchesGraphEdge,
}, },
output::{ output::{
OutputAsset, OutputAssets, OutputAssetsReference, OutputAssetsReferences, OutputAsset, OutputAssets, OutputAssetsReference, OutputAssetsReferences,
...@@ -60,7 +60,7 @@ pub async fn make_chunk_group( ...@@ -60,7 +60,7 @@ pub async fn make_chunk_group(
.await?; .await?;
let should_trace = *chunking_context.is_tracing_enabled().await?; let should_trace = *chunking_context.is_tracing_enabled().await?;
let should_merge_modules = *chunking_context.is_module_merging_enabled().await?; let should_merge_modules = *chunking_context.is_module_merging_enabled().await?;
let batching_config = chunking_context.batching_config(); let chunking_configs = chunking_context.chunking_configs();
let ChunkGroupContent { let ChunkGroupContent {
chunkable_items, chunkable_items,
...@@ -76,7 +76,7 @@ pub async fn make_chunk_group( ...@@ -76,7 +76,7 @@ pub async fn make_chunk_group(
can_split_async, can_split_async,
should_trace, should_trace,
should_merge_modules, should_merge_modules,
batching_config, chunking_configs,
}, },
) )
.await?; .await?;
...@@ -202,8 +202,8 @@ pub struct ChunkGroupContentOptions { ...@@ -202,8 +202,8 @@ pub struct ChunkGroupContentOptions {
pub should_trace: bool, pub should_trace: bool,
/// Whether module merging is enabled /// Whether module merging is enabled
pub should_merge_modules: bool, pub should_merge_modules: bool,
/// The batching config to use /// The chunking configs
pub batching_config: Vc<BatchingConfig>, pub chunking_configs: Vc<ChunkingConfigs>,
} }
/// Computes the content of a chunk group. /// Computes the content of a chunk group.
...@@ -217,17 +217,17 @@ pub async fn chunk_group_content( ...@@ -217,17 +217,17 @@ pub async fn chunk_group_content(
can_split_async, can_split_async,
should_trace, should_trace,
should_merge_modules, should_merge_modules,
batching_config, chunking_configs,
}: ChunkGroupContentOptions, }: ChunkGroupContentOptions,
) -> Result<ChunkGroupContent> { ) -> Result<ChunkGroupContent> {
let module_batches_graph = module_graph.module_batches(batching_config).await?; let module_batches_graph = module_graph.module_batches(chunking_configs).await?;
type ModuleToChunkableMap = FxHashMap<ModuleOrBatch, ChunkableModuleOrBatch>; type ModuleToChunkableMap = FxHashMap<ModuleOrBatch, ChunkableModuleOrBatch>;
struct TraverseState { struct TraverseState {
unsorted_items: ModuleToChunkableMap, unsorted_items: ModuleToChunkableMap,
chunkable_items: FxIndexSet<ChunkableModuleOrBatch>, chunkable_items: FxIndexSet<ChunkableModuleOrBatch>,
async_modules: FxIndexSet<ResolvedVc<Box<dyn ChunkableModule>>>, async_modules: FxIndexSet<ResolvedVc<Box<dyn Module>>>,
traced_modules: FxIndexSet<ResolvedVc<Box<dyn Module>>>, traced_modules: FxIndexSet<ResolvedVc<Box<dyn Module>>>,
} }
...@@ -313,15 +313,13 @@ pub async fn chunk_group_content( ...@@ -313,15 +313,13 @@ pub async fn chunk_group_content(
} }
ChunkingType::Async => { ChunkingType::Async => {
if can_split_async { if can_split_async {
let chunkable_module = ResolvedVc::try_downcast(edge.module.unwrap()) let module = edge.module.unwrap();
.context("Module in async chunking edge is not chunkable")?;
let is_async_loader_available = let is_async_loader_available =
available_modules.as_ref().is_some_and(|available_modules| { available_modules.as_ref().is_some_and(|available_modules| {
available_modules available_modules.get(AvailableModuleItem::AsyncLoader(module))
.get(AvailableModuleItem::AsyncLoader(chunkable_module))
}); });
if !is_async_loader_available { if !is_async_loader_available {
state.async_modules.insert(chunkable_module); state.async_modules.insert(module);
} }
GraphTraversalAction::Exclude GraphTraversalAction::Exclude
} else if is_available { } else if is_available {
...@@ -388,15 +386,14 @@ pub async fn chunk_group_content( ...@@ -388,15 +386,14 @@ pub async fn chunk_group_content(
.map(async |chunkable_module| match chunkable_module { .map(async |chunkable_module| match chunkable_module {
ChunkableModuleOrBatch::Module(module) => { ChunkableModuleOrBatch::Module(module) => {
if !merged_modules_ref if !merged_modules_ref
.should_create_chunk_item_for(ResolvedVc::upcast(module)) .should_create_chunk_item_for(module)
.await? .await?
{ {
return Ok(None); return Ok(None);
} }
let module = if let Some(replacement) = merged_modules_ref let module = if let Some(replacement) =
.should_replace_module(ResolvedVc::upcast(module)) merged_modules_ref.should_replace_module(module).await?
.await?
{ {
replacement replacement
} else { } else {
...@@ -458,23 +455,18 @@ async fn map_module_batch( ...@@ -458,23 +455,18 @@ async fn map_module_batch(
.iter() .iter()
.copied() .copied()
.map(async |module| { .map(async |module| {
if !merged_modules if !merged_modules.should_create_chunk_item_for(module).await? {
.should_create_chunk_item_for(ResolvedVc::upcast(module))
.await?
{
modified.store(true, std::sync::atomic::Ordering::Relaxed); modified.store(true, std::sync::atomic::Ordering::Relaxed);
return Ok(None); return Ok(None);
} }
let module = if let Some(replacement) = merged_modules let module =
.should_replace_module(ResolvedVc::upcast(module)) if let Some(replacement) = merged_modules.should_replace_module(module).await? {
.await? modified.store(true, std::sync::atomic::Ordering::Relaxed);
{ replacement
modified.store(true, std::sync::atomic::Ordering::Relaxed); } else {
replacement module
} else { };
module
};
Ok(Some(module)) Ok(Some(module))
}) })
...@@ -518,7 +510,7 @@ async fn map_module_batch_group( ...@@ -518,7 +510,7 @@ async fn map_module_batch_group(
merged_modules_ref.should_replace_module(module).await? merged_modules_ref.should_replace_module(module).await?
{ {
modified.store(true, std::sync::atomic::Ordering::Relaxed); modified.store(true, std::sync::atomic::Ordering::Relaxed);
ResolvedVc::upcast(replacement) replacement
} else { } else {
module module
}; };
......
...@@ -11,10 +11,8 @@ use turbo_tasks::{ ...@@ -11,10 +11,8 @@ use turbo_tasks::{
}; };
use crate::{ use crate::{
chunk::{ chunk::{ChunkItem, ChunkItemWithAsyncModuleInfo, ChunkType, ChunkingContext},
ChunkItemWithAsyncModuleInfo, ChunkType, ChunkableModule, ChunkingContext, module::Module,
chunking_context::ChunkingContextExt,
},
module_graph::{ module_graph::{
ModuleGraph, ModuleGraph,
async_module_info::AsyncModulesInfo, async_module_info::AsyncModulesInfo,
...@@ -24,24 +22,22 @@ use crate::{ ...@@ -24,24 +22,22 @@ use crate::{
}; };
pub async fn attach_async_info_to_chunkable_module( pub async fn attach_async_info_to_chunkable_module(
module: ResolvedVc<Box<dyn ChunkableModule>>, module: ResolvedVc<Box<dyn Module>>,
async_module_info: &ReadRef<AsyncModulesInfo>, async_module_info: &ReadRef<AsyncModulesInfo>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<ChunkItemWithAsyncModuleInfo> { ) -> Result<ChunkItemWithAsyncModuleInfo> {
let general_module = ResolvedVc::upcast(module); let async_info = if async_module_info.contains(&module) {
let async_info = if async_module_info.contains(&general_module) {
Some( Some(
module_graph module_graph
.referenced_async_modules(*general_module) .referenced_async_modules(*module)
.to_resolved() .to_resolved()
.await?, .await?,
) )
} else { } else {
None None
}; };
let chunk_item = chunking_context let chunk_item = ChunkItem::new(*module, module_graph, chunking_context)
.chunk_item(Vc::upcast(*module), module_graph)
.to_resolved() .to_resolved()
.await?; .await?;
Ok(ChunkItemWithAsyncModuleInfo { Ok(ChunkItemWithAsyncModuleInfo {
...@@ -75,15 +71,26 @@ impl ChunkItemOrBatchWithAsyncModuleInfo { ...@@ -75,15 +71,26 @@ impl ChunkItemOrBatchWithAsyncModuleInfo {
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Option<Self>> { ) -> Result<Option<Self>> {
Ok(match chunkable_module_or_batch { Ok(match chunkable_module_or_batch {
ChunkableModuleOrBatch::Module(module) => Some(Self::ChunkItem( ChunkableModuleOrBatch::Module(module) => {
attach_async_info_to_chunkable_module( // Skip modules that are not accepted by any chunk type
module, if !chunking_context
async_module_info, .chunking_configs()
module_graph, .await?
chunking_context, .is_chunkable(module)
) .await
.await?, {
)), return Ok(None);
}
Some(Self::ChunkItem(
attach_async_info_to_chunkable_module(
module,
async_module_info,
module_graph,
chunking_context,
)
.await?,
))
}
ChunkableModuleOrBatch::Batch(batch) => Some(Self::Batch( ChunkableModuleOrBatch::Batch(batch) => Some(Self::Batch(
ChunkItemBatchWithAsyncModuleInfo::from_module_batch( ChunkItemBatchWithAsyncModuleInfo::from_module_batch(
*batch, *batch,
......
...@@ -67,15 +67,13 @@ pub async fn make_production_chunks( ...@@ -67,15 +67,13 @@ pub async fn make_production_chunks(
}, },
.. ..
} => Prepared::ChunkItem( } => Prepared::ChunkItem(
if let Some(module_chunk_groups) = if let Some(module_chunk_groups) = module_chunk_groups.get(&module).await? {
module_chunk_groups.get(&ResolvedVc::upcast(module)).await?
{
module_chunk_groups module_chunk_groups
} else { } else {
// Merged modules don't have a chunk group in chunk_group_info, so // Merged modules don't have a chunk group in chunk_group_info, so
// lookup using the original module. // lookup using the original module.
let original_module = merged_modules let original_module = merged_modules
.get_original_module(ResolvedVc::upcast(module)) .get_original_module(module)
.await? .await?
.context("every module should have a chunk group")?; .context("every module should have a chunk group")?;
module_chunk_groups module_chunk_groups
......
use std::ops::Deref;
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{ use turbo_tasks::{
NonLocalValue, ResolvedVc, TaskInput, Upcast, ValueToString, Vc, trace::TraceRawVcs, IntoTraitRef, NonLocalValue, ResolvedVc, TaskInput, TraitRef, Upcast, Vc, trace::TraceRawVcs,
}; };
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbo_tasks_hash::DeterministicHash; use turbo_tasks_hash::DeterministicHash;
...@@ -12,8 +14,8 @@ use turbo_tasks_hash::DeterministicHash; ...@@ -12,8 +14,8 @@ use turbo_tasks_hash::DeterministicHash;
use crate::{ use crate::{
asset::Asset, asset::Asset,
chunk::{ chunk::{
ChunkItem, ChunkType, ChunkableModule, EvaluatableAssets, ChunkItem, ChunkType, EvaluatableAssets, availability_info::AvailabilityInfo,
availability_info::AvailabilityInfo, chunk_id_strategy::ModuleIdStrategy, chunk_id_strategy::ModuleIdStrategy,
}, },
environment::Environment, environment::Environment,
ident::AssetIdent, ident::AssetIdent,
...@@ -278,8 +280,82 @@ pub struct ChunkingConfig { ...@@ -278,8 +280,82 @@ pub struct ChunkingConfig {
pub placeholder_for_future_extensions: (), pub placeholder_for_future_extensions: (),
} }
#[turbo_tasks::value(transparent)] #[derive(Default)]
pub struct ChunkingConfigs(FxHashMap<ResolvedVc<Box<dyn ChunkType>>, ChunkingConfig>); #[turbo_tasks::value(shared)]
pub struct ChunkingConfigs(pub FxHashMap<ResolvedVc<Box<dyn ChunkType>>, ChunkingConfig>);
#[turbo_tasks::value_impl]
impl ChunkingConfigs {
/// Create a new `ChunkingConfigs` from a list of chunk type/config pairs.
///
/// This is a memoized turbo_tasks function, so identical inputs produce the same `Vc`,
/// which is critical for downstream memoization of `module_batches()`.
#[turbo_tasks::function]
pub fn new(configs: Vec<(ResolvedVc<Box<dyn ChunkType>>, ChunkingConfig)>) -> Vc<Self> {
ChunkingConfigs(configs.into_iter().collect()).cell()
}
}
impl Deref for ChunkingConfigs {
type Target = FxHashMap<ResolvedVc<Box<dyn ChunkType>>, ChunkingConfig>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
/// Pre-resolved chunk type trait refs for efficient batch chunkability checks.
/// Created via [`ChunkingConfigs::resolved_chunk_types`].
pub type ResolvedChunkTypes = Vec<(ResolvedVc<Box<dyn ChunkType>>, TraitRef<Box<dyn ChunkType>>)>;
impl ChunkingConfigs {
pub async fn is_chunkable(&self, module: ResolvedVc<Box<dyn Module>>) -> bool {
self.chunk_type(module).await.is_some()
}
/// Returns a [`ChunkType`], if one is supported by this module.
pub async fn chunk_type(
&self,
module: ResolvedVc<Box<dyn Module>>,
) -> Option<ResolvedVc<Box<dyn ChunkType>>> {
for chunk_type in self.0.keys() {
if chunk_type
.into_trait_ref()
.await
.expect("Unexpectedly failed to cast trait")
.accepts_module(module)
{
return Some(*chunk_type);
}
}
None
}
/// Pre-resolves all chunk type trait refs. Use with [`is_chunkable_resolved`]
/// when checking many modules to avoid repeated async lookups.
pub async fn resolved_chunk_types(&self) -> Result<ResolvedChunkTypes> {
let mut result = Vec::with_capacity(self.0.len());
for chunk_type in self.0.keys() {
let trait_ref = chunk_type.into_trait_ref().await?;
result.push((*chunk_type, trait_ref));
}
Ok(result)
}
/// Check if a module is chunkable using pre-resolved trait refs.
/// More efficient than [`is_chunkable`] when checking many modules.
pub fn is_chunkable_resolved(
&self,
resolved: &ResolvedChunkTypes,
module: ResolvedVc<Box<dyn Module>>,
) -> bool {
for (_ty, trait_ref) in resolved {
if trait_ref.accepts_module(module) {
return true;
}
}
false
}
}
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Debug, Clone, Copy, Hash, TaskInput, Default, Deserialize)] #[derive(Debug, Clone, Copy, Hash, TaskInput, Default, Deserialize)]
...@@ -373,10 +449,9 @@ pub trait ChunkingContext { ...@@ -373,10 +449,9 @@ pub trait ChunkingContext {
Vc::cell(false) Vc::cell(false)
} }
/// Returns the chunking configs for this context.
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_configs(self: Vc<Self>) -> Vc<ChunkingConfigs> { fn chunking_configs(self: Vc<Self>) -> Vc<ChunkingConfigs>;
Vc::cell(Default::default())
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn batching_config(self: Vc<Self>) -> Vc<BatchingConfig> { fn batching_config(self: Vc<Self>) -> Vc<BatchingConfig> {
...@@ -427,13 +502,12 @@ pub trait ChunkingContext { ...@@ -427,13 +502,12 @@ pub trait ChunkingContext {
#[turbo_tasks::function] #[turbo_tasks::function]
fn async_loader_chunk_item( fn async_loader_chunk_item(
&self, &self,
module: Vc<Box<dyn ChunkableModule>>, module: Vc<Box<dyn Module>>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<ChunkItem>; ) -> Vc<ChunkItem>;
#[turbo_tasks::function] #[turbo_tasks::function]
fn async_loader_chunk_item_ident(&self, module: Vc<Box<dyn ChunkableModule>>) fn async_loader_chunk_item_ident(&self, module: Vc<Box<dyn Module>>) -> Vc<AssetIdent>;
-> Vc<AssetIdent>;
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunk_group( fn chunk_group(
...@@ -580,15 +654,6 @@ pub trait ChunkingContextExt { ...@@ -580,15 +654,6 @@ pub trait ChunkingContextExt {
fn relative_path_from_chunk_root_to_project_root(self: Vc<Self>) -> Vc<RcStr> fn relative_path_from_chunk_root_to_project_root(self: Vc<Self>) -> Vc<RcStr>
where where
Self: Send; Self: Send;
/// Creates a chunk item from a module. The module must implement `ChunkableModule`.
fn chunk_item(
self: Vc<Self>,
module: Vc<Box<dyn Module>>,
module_graph: Vc<ModuleGraph>,
) -> Vc<ChunkItem>
where
Self: Send;
} }
impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingContextExt for T { impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingContextExt for T {
...@@ -707,30 +772,6 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -707,30 +772,6 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte
fn relative_path_from_chunk_root_to_project_root(self: Vc<Self>) -> Vc<RcStr> { fn relative_path_from_chunk_root_to_project_root(self: Vc<Self>) -> Vc<RcStr> {
relative_path_from_chunk_root_to_project_root(Vc::upcast_non_strict(self)) relative_path_from_chunk_root_to_project_root(Vc::upcast_non_strict(self))
} }
fn chunk_item(
self: Vc<Self>,
module: Vc<Box<dyn Module>>,
module_graph: Vc<ModuleGraph>,
) -> Vc<ChunkItem> {
chunk_item(Vc::upcast_non_strict(self), module, module_graph)
}
}
#[turbo_tasks::function]
async fn chunk_item(
chunking_context: Vc<Box<dyn ChunkingContext>>,
module: Vc<Box<dyn Module>>,
module_graph: Vc<ModuleGraph>,
) -> Result<Vc<ChunkItem>> {
let module = module.to_resolved().await?;
let Some(chunkable) = ResolvedVc::try_sidecast::<Box<dyn ChunkableModule>>(module) else {
bail!(
"Module {} is not chunkable",
module.ident().to_string().await?
);
};
Ok(chunkable.as_chunk_item(module_graph, chunking_context))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use turbo_tasks::{ResolvedVc, Upcast, ValueToString, Vc}; use turbo_tasks::{ResolvedVc, Upcast, ValueToString, Vc};
use super::ChunkableModule;
use crate::{ use crate::{
context::AssetContext, context::AssetContext,
module::Module, module::Module,
...@@ -14,7 +13,7 @@ use crate::{ ...@@ -14,7 +13,7 @@ use crate::{
/// The chunking context implementation will resolve the dynamic entry to a /// The chunking context implementation will resolve the dynamic entry to a
/// well-known value or trait object. /// well-known value or trait object.
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait EvaluatableAsset: Module + ChunkableModule {} pub trait EvaluatableAsset: Module {}
pub trait EvaluatableAssetExt { pub trait EvaluatableAssetExt {
fn to_evaluatable( fn to_evaluatable(
......
...@@ -7,7 +7,7 @@ use turbo_tasks::{FxIndexMap, FxIndexSet, ResolvedVc, TryFlatJoinIterExt, TryJoi ...@@ -7,7 +7,7 @@ use turbo_tasks::{FxIndexMap, FxIndexSet, ResolvedVc, TryFlatJoinIterExt, TryJoi
use crate::{ use crate::{
chunk::{ chunk::{
ChunkableModule, ChunkingType, MergeableModule, MergeableModuleExposure, MergeableModules, ChunkingType, MergeableModule, MergeableModuleExposure, MergeableModules,
MergeableModulesExposed, MergeableModulesExposed,
}, },
module::Module, module::Module,
...@@ -20,7 +20,7 @@ use crate::{ ...@@ -20,7 +20,7 @@ use crate::{
#[turbo_tasks::value(transparent, cell = "keyed")] #[turbo_tasks::value(transparent, cell = "keyed")]
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
pub struct MergedModulesReplacements( pub struct MergedModulesReplacements(
FxHashMap<ResolvedVc<Box<dyn Module>>, ResolvedVc<Box<dyn ChunkableModule>>>, FxHashMap<ResolvedVc<Box<dyn Module>>, ResolvedVc<Box<dyn Module>>>,
); );
#[turbo_tasks::value(transparent, cell = "keyed")] #[turbo_tasks::value(transparent, cell = "keyed")]
...@@ -49,7 +49,7 @@ impl MergedModuleInfo { ...@@ -49,7 +49,7 @@ impl MergedModuleInfo {
pub async fn should_replace_module( pub async fn should_replace_module(
&self, &self,
module: ResolvedVc<Box<dyn Module>>, module: ResolvedVc<Box<dyn Module>>,
) -> Result<Option<ResolvedVc<Box<dyn ChunkableModule>>>> { ) -> Result<Option<ResolvedVc<Box<dyn Module>>>> {
Ok(self.replacements.get(&module).await?.as_deref().copied()) Ok(self.replacements.get(&module).await?.as_deref().copied())
} }
...@@ -763,7 +763,7 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc< ...@@ -763,7 +763,7 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
let mut replacements: FxHashMap< let mut replacements: FxHashMap<
ResolvedVc<Box<dyn Module>>, ResolvedVc<Box<dyn Module>>,
ResolvedVc<Box<dyn ChunkableModule>>, ResolvedVc<Box<dyn Module>>,
> = Default::default(); > = Default::default();
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
let mut replacements_to_original: FxHashMap< let mut replacements_to_original: FxHashMap<
...@@ -774,7 +774,7 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc< ...@@ -774,7 +774,7 @@ pub async fn compute_merged_modules(module_graph: Vc<ModuleGraph>) -> Result<Vc<
for (original, replacement, replacement_included) in result.into_iter().flatten() { for (original, replacement, replacement_included) in result.into_iter().flatten() {
replacements.insert(original, replacement); replacements.insert(original, replacement);
replacements_to_original.insert(ResolvedVc::upcast(replacement), original); replacements_to_original.insert(replacement, original);
included.extend(replacement_included); included.extend(replacement_included);
} }
......
...@@ -26,7 +26,7 @@ use turbo_tasks::{ ...@@ -26,7 +26,7 @@ use turbo_tasks::{
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use crate::{ use crate::{
chunk::{AsyncModuleInfo, ChunkingContext, ChunkingType}, chunk::{AsyncModuleInfo, ChunkingConfigs, ChunkingContext, ChunkingType},
issue::{ImportTracer, ImportTraces, Issue}, issue::{ImportTracer, ImportTraces, Issue},
module::Module, module::Module,
module_graph::{ module_graph::{
...@@ -782,9 +782,9 @@ impl ModuleGraph { ...@@ -782,9 +782,9 @@ impl ModuleGraph {
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn module_batches( pub async fn module_batches(
self: Vc<Self>, self: Vc<Self>,
config: Vc<BatchingConfig>, chunking_configs: ResolvedVc<ChunkingConfigs>,
) -> Result<Vc<ModuleBatchesGraph>> { ) -> Result<Vc<ModuleBatchesGraph>> {
compute_module_batches(self, &*config.await?).await compute_module_batches(self, chunking_configs).await
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -9,9 +9,7 @@ use turbo_tasks::{ ...@@ -9,9 +9,7 @@ use turbo_tasks::{
trace::TraceRawVcs, trace::TraceRawVcs,
}; };
use crate::{ use crate::{module::Module, module_graph::chunk_group_info::RoaringBitmapWrapper};
chunk::ChunkableModule, module::Module, module_graph::chunk_group_info::RoaringBitmapWrapper,
};
#[derive( #[derive(
Debug, Debug,
...@@ -50,7 +48,7 @@ impl ModuleOrBatch { ...@@ -50,7 +48,7 @@ impl ModuleOrBatch {
Debug, Copy, Clone, Hash, PartialEq, Eq, TraceRawVcs, NonLocalValue, TaskInput, Encode, Decode, Debug, Copy, Clone, Hash, PartialEq, Eq, TraceRawVcs, NonLocalValue, TaskInput, Encode, Decode,
)] )]
pub enum ChunkableModuleOrBatch { pub enum ChunkableModuleOrBatch {
Module(ResolvedVc<Box<dyn ChunkableModule>>), Module(ResolvedVc<Box<dyn Module>>),
Batch(ResolvedVc<ModuleBatch>), Batch(ResolvedVc<ModuleBatch>),
None(usize), None(usize),
} }
...@@ -58,7 +56,7 @@ pub enum ChunkableModuleOrBatch { ...@@ -58,7 +56,7 @@ pub enum ChunkableModuleOrBatch {
impl ChunkableModuleOrBatch { impl ChunkableModuleOrBatch {
pub fn from_module_or_batch(module_or_batch: ModuleOrBatch) -> Option<Self> { pub fn from_module_or_batch(module_or_batch: ModuleOrBatch) -> Option<Self> {
match module_or_batch { match module_or_batch {
ModuleOrBatch::Module(module) => ResolvedVc::try_downcast(module).map(Self::Module), ModuleOrBatch::Module(module) => Some(Self::Module(module)),
ModuleOrBatch::Batch(batch) => Some(Self::Batch(batch)), ModuleOrBatch::Batch(batch) => Some(Self::Batch(batch)),
ModuleOrBatch::None(i) => Some(Self::None(i)), ModuleOrBatch::None(i) => Some(Self::None(i)),
} }
...@@ -80,7 +78,7 @@ impl ChunkableModuleOrBatch { ...@@ -80,7 +78,7 @@ impl ChunkableModuleOrBatch {
impl From<ChunkableModuleOrBatch> for ModuleOrBatch { impl From<ChunkableModuleOrBatch> for ModuleOrBatch {
fn from(chunkable_module_or_batch: ChunkableModuleOrBatch) -> Self { fn from(chunkable_module_or_batch: ChunkableModuleOrBatch) -> Self {
match chunkable_module_or_batch { match chunkable_module_or_batch {
ChunkableModuleOrBatch::Module(module) => Self::Module(ResolvedVc::upcast(module)), ChunkableModuleOrBatch::Module(module) => Self::Module(module),
ChunkableModuleOrBatch::Batch(batch) => Self::Batch(batch), ChunkableModuleOrBatch::Batch(batch) => Self::Batch(batch),
ChunkableModuleOrBatch::None(i) => Self::None(i), ChunkableModuleOrBatch::None(i) => Self::None(i),
} }
...@@ -105,7 +103,7 @@ impl Debug for IdentStrings { ...@@ -105,7 +103,7 @@ impl Debug for IdentStrings {
#[turbo_tasks::value] #[turbo_tasks::value]
pub struct ModuleBatch { pub struct ModuleBatch {
pub modules: Vec<ResolvedVc<Box<dyn ChunkableModule>>>, pub modules: Vec<ResolvedVc<Box<dyn Module>>>,
pub chunk_groups: Option<RoaringBitmapWrapper>, pub chunk_groups: Option<RoaringBitmapWrapper>,
} }
...@@ -113,7 +111,7 @@ pub struct ModuleBatch { ...@@ -113,7 +111,7 @@ pub struct ModuleBatch {
impl ModuleBatch { impl ModuleBatch {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn new( pub fn new(
modules: Vec<ResolvedVc<Box<dyn ChunkableModule>>>, modules: Vec<ResolvedVc<Box<dyn Module>>>,
chunk_groups: Option<RoaringBitmapWrapper>, chunk_groups: Option<RoaringBitmapWrapper>,
) -> Vc<Self> { ) -> Vc<Self> {
Self { Self {
...@@ -168,9 +166,7 @@ impl ChunkableModuleBatchGroup { ...@@ -168,9 +166,7 @@ impl ChunkableModuleBatchGroup {
.items .items
.iter() .iter()
.filter_map(|batch| match *batch { .filter_map(|batch| match *batch {
ModuleOrBatch::Module(module) => { ModuleOrBatch::Module(module) => Some(ChunkableModuleOrBatch::Module(module)),
ResolvedVc::try_downcast(module).map(ChunkableModuleOrBatch::Module)
}
ModuleOrBatch::Batch(batch) => Some(ChunkableModuleOrBatch::Batch(batch)), ModuleOrBatch::Batch(batch) => Some(ChunkableModuleOrBatch::Batch(batch)),
ModuleOrBatch::None(_) => None, ModuleOrBatch::None(_) => None,
}) })
......
...@@ -18,7 +18,7 @@ use turbo_tasks::{ ...@@ -18,7 +18,7 @@ use turbo_tasks::{
}; };
use crate::{ use crate::{
chunk::{ChunkableModule, ChunkingType}, chunk::{ChunkingConfigs, ChunkingType},
module::Module, module::Module,
module_graph::{ module_graph::{
GraphTraversalAction, ModuleGraph, GraphTraversalAction, ModuleGraph,
...@@ -334,7 +334,7 @@ impl PreBatches { ...@@ -334,7 +334,7 @@ impl PreBatches {
pub async fn compute_module_batches( pub async fn compute_module_batches(
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
_config: &BatchingConfig, chunking_configs: ResolvedVc<ChunkingConfigs>,
) -> Result<Vc<ModuleBatchesGraph>> { ) -> Result<Vc<ModuleBatchesGraph>> {
let outer_span = tracing::info_span!( let outer_span = tracing::info_span!(
"compute module batches", "compute module batches",
...@@ -655,6 +655,21 @@ pub async fn compute_module_batches( ...@@ -655,6 +655,21 @@ pub async fn compute_module_batches(
// Now every module is only in one batch // Now every module is only in one batch
let mut edges_count = 0; let mut edges_count = 0;
let chunking_config = chunking_configs.await?;
// Pre-resolve chunk type trait refs to avoid repeated async lookups per module
let resolved_chunk_types = chunking_config.resolved_chunk_types().await?;
let mut chunkable_modules = FxIndexSet::default();
for prebatch in &pre_batches.batches {
for item in &prebatch.items {
if let PreBatchItem::ParallelModule(module) = item {
let is_chunkable =
chunking_config.is_chunkable_resolved(&resolved_chunk_types, *module);
if is_chunkable {
chunkable_modules.insert(*module);
}
}
}
}
// Since batches can only have references followed by a list of parallel chunkable modules, // Since batches can only have references followed by a list of parallel chunkable modules,
// we need to split batches that have modules before references. // we need to split batches that have modules before references.
...@@ -668,13 +683,13 @@ pub async fn compute_module_batches( ...@@ -668,13 +683,13 @@ pub async fn compute_module_batches(
} }
let mut mode = Mode::Other; let mut mode = Mode::Other;
for item in items { for item in items {
let chunkable_module = if let PreBatchItem::ParallelModule(module) = &item { let is_chunkable = if let PreBatchItem::ParallelModule(module) = &item {
ResolvedVc::try_downcast::<Box<dyn ChunkableModule>>(*module) chunkable_modules.contains(module)
} else { } else {
None false
}; };
let item = if let PreBatchItem::ParallelModule(module) = item { let item = if let PreBatchItem::ParallelModule(module) = item {
if chunkable_module.is_some() { if is_chunkable {
PreBatchItem::ParallelModule(module) PreBatchItem::ParallelModule(module)
} else { } else {
pre_batches.single_module_entries.insert(module); pre_batches.single_module_entries.insert(module);
...@@ -689,8 +704,8 @@ pub async fn compute_module_batches( ...@@ -689,8 +704,8 @@ pub async fn compute_module_batches(
} else { } else {
item item
}; };
match (&mode, chunkable_module) { match (&mode, is_chunkable) {
(_, Some(_)) => { (_, true) => {
mode = Mode::ParallelChunkableModule; mode = Mode::ParallelChunkableModule;
new_items.insert(item); new_items.insert(item);
} }
...@@ -707,7 +722,7 @@ pub async fn compute_module_batches( ...@@ -707,7 +722,7 @@ pub async fn compute_module_batches(
pre_batches.batches.push(new_batch); pre_batches.batches.push(new_batch);
edges_count += 1; edges_count += 1;
new_items.insert(PreBatchItem::ParallelReference(idx)); new_items.insert(PreBatchItem::ParallelReference(idx));
if chunkable_module.is_some() { if is_chunkable {
new_items.insert(item); new_items.insert(item);
} else { } else {
edges_count += 1; edges_count += 1;
...@@ -738,7 +753,11 @@ pub async fn compute_module_batches( ...@@ -738,7 +753,11 @@ pub async fn compute_module_batches(
.map(async |(i, pre_batch)| { .map(async |(i, pre_batch)| {
let mut modules = pre_batch.items.iter().filter_map(|item| { let mut modules = pre_batch.items.iter().filter_map(|item| {
if let PreBatchItem::ParallelModule(module) = item { if let PreBatchItem::ParallelModule(module) = item {
ResolvedVc::try_downcast(*module) if chunkable_modules.contains(module) {
Some(*module)
} else {
None
}
} else { } else {
None None
} }
...@@ -757,7 +776,7 @@ pub async fn compute_module_batches( ...@@ -757,7 +776,7 @@ pub async fn compute_module_batches(
); );
Ok(ModuleOrBatch::Batch(batch.to_resolved().await?)) Ok(ModuleOrBatch::Batch(batch.to_resolved().await?))
} else { } else {
Ok(ModuleOrBatch::Module(ResolvedVc::upcast(first))) Ok(ModuleOrBatch::Module(first))
} }
}) })
.try_join() .try_join()
......
...@@ -13,7 +13,7 @@ use turbo_tasks::{ ...@@ -13,7 +13,7 @@ use turbo_tasks::{
use crate::{ use crate::{
chunk::{ chunk::{
ChunkItemBatchWithAsyncModuleInfo, ChunkItemWithAsyncModuleInfo, ChunkType, ChunkItemBatchWithAsyncModuleInfo, ChunkItemWithAsyncModuleInfo, ChunkType,
ChunkableModule, ChunkingContext, chunk_item_batch::attach_async_info_to_chunkable_module, ChunkingContext, chunk_item_batch::attach_async_info_to_chunkable_module,
}, },
module::{Module, StyleModule, StyleType}, module::{Module, StyleModule, StyleType},
module_graph::{ module_graph::{
...@@ -66,7 +66,7 @@ impl ModuleInfo { ...@@ -66,7 +66,7 @@ impl ModuleInfo {
} }
struct ChunkGroupState { struct ChunkGroupState {
styles: FxIndexSet<ResolvedVc<Box<dyn ChunkableModule>>>, styles: FxIndexSet<ResolvedVc<Box<dyn Module>>>,
requests: usize, requests: usize,
} }
...@@ -77,10 +77,10 @@ pub async fn compute_style_groups( ...@@ -77,10 +77,10 @@ pub async fn compute_style_groups(
) -> Result<Vc<StyleGroups>> { ) -> Result<Vc<StyleGroups>> {
let chunk_group_info = module_graph.chunk_group_info().await?; let chunk_group_info = module_graph.chunk_group_info().await?;
let batches_graph = module_graph let batches_graph = module_graph
.module_batches(chunking_context.batching_config()) .module_batches(chunking_context.chunking_configs())
.await?; .await?;
let async_info = module_graph.async_module_info().await?; let async_info = module_graph.async_module_info().await?;
let mut module_info_map: FxIndexMap<ResolvedVc<Box<dyn ChunkableModule>>, Option<ModuleInfo>> = let mut module_info_map: FxIndexMap<ResolvedVc<Box<dyn Module>>, Option<ModuleInfo>> =
FxIndexMap::default(); FxIndexMap::default();
// Compute the style modules in each chunk group // Compute the style modules in each chunk group
...@@ -156,9 +156,7 @@ pub async fn compute_style_groups( ...@@ -156,9 +156,7 @@ pub async fn compute_style_groups(
} }
} }
ModuleOrBatch::Module(module) => { ModuleOrBatch::Module(module) => {
if let Some(chunkable_module) = ResolvedVc::try_downcast(module) { handle_module(module).await?;
handle_module(chunkable_module).await?;
}
} }
ModuleOrBatch::None(_) => {} ModuleOrBatch::None(_) => {}
} }
......
...@@ -3,16 +3,13 @@ use turbo_rcstr::rcstr; ...@@ -3,16 +3,13 @@ use turbo_rcstr::rcstr;
use turbo_tasks::{IntoTraitRef, ResolvedVc, TryJoinIterExt, ValueToString, Vc}; use turbo_tasks::{IntoTraitRef, ResolvedVc, TryJoinIterExt, ValueToString, Vc};
use turbo_tasks_fs::{FileContent, FileSystemPath}; use turbo_tasks_fs::{FileContent, FileSystemPath};
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{ChunkItem, ChunkingContext, MinifyType},
ChunkItem, ChunkType, ChunkableModule, ChunkedItem, ChunkingContext, ChunkingContextExt,
MinifyType,
},
context::AssetContext, context::AssetContext,
environment::Environment, environment::Environment,
ident::AssetIdent, ident::AssetIdent,
module::{Module, ModuleSideEffects, StyleModule, StyleType}, module::{Module, ModuleSideEffects, StyleModule, StyleType},
module_graph::ModuleGraph, module_graph::ModuleGraph,
output::{OutputAssetsReference, OutputAssetsWithReferenced}, output::OutputAssetsWithReferenced,
reference::{ModuleReference, ModuleReferences}, reference::{ModuleReference, ModuleReferences},
reference_type::ImportContext, reference_type::ImportContext,
resolve::origin::ResolveOrigin, resolve::origin::ResolveOrigin,
...@@ -22,7 +19,7 @@ use turbopack_core::{ ...@@ -22,7 +19,7 @@ use turbopack_core::{
use crate::{ use crate::{
CssModuleAssetType, CssModuleAssetType,
chunk::{CssChunkItem, CssChunkItemContent, CssChunkPlaceable, CssChunkType, CssImport}, chunk::{CssChunkItemContent, CssChunkPlaceable, CssImport},
code_gen::CodeGenerateable, code_gen::CodeGenerateable,
process::{ process::{
CssWithPlaceholderResult, FinalCssResult, ParseCss, ParseCssResult, ProcessCss, CssWithPlaceholderResult, FinalCssResult, ParseCss, ParseCssResult, ProcessCss,
...@@ -174,97 +171,18 @@ impl StyleModule for CssModuleAsset { ...@@ -174,97 +171,18 @@ impl StyleModule for CssModuleAsset {
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ChunkableModule for CssModuleAsset { impl CssChunkPlaceable for CssModuleAsset {
#[turbo_tasks::function]
fn as_chunk_item(
self: ResolvedVc<Self>,
module_graph: ResolvedVc<ModuleGraph>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Vc<ChunkItem> {
let item: Vc<Box<dyn ChunkedItem>> =
Vc::upcast(CssModuleChunkItem::cell(CssModuleChunkItem {
module: self,
module_graph,
chunking_context,
}));
ChunkItem::from_trait(item)
}
}
#[turbo_tasks::value_impl]
impl CssChunkPlaceable for CssModuleAsset {}
#[turbo_tasks::value_impl]
impl ResolveOrigin for CssModuleAsset {
#[turbo_tasks::function]
fn origin_path(&self) -> Vc<FileSystemPath> {
self.source.ident().path()
}
#[turbo_tasks::function]
fn asset_context(&self) -> Vc<Box<dyn AssetContext>> {
*self.asset_context
}
}
#[turbo_tasks::value]
struct CssModuleChunkItem {
module: ResolvedVc<CssModuleAsset>,
module_graph: ResolvedVc<ModuleGraph>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
}
#[turbo_tasks::value_impl]
impl OutputAssetsReference for CssModuleChunkItem {
#[turbo_tasks::function]
async fn references(&self) -> Result<Vc<OutputAssetsWithReferenced>> {
let mut references = Vec::new();
if let ParseCssResult::Ok { url_references, .. } = &*self.module.parse_css().await? {
for (_, reference) in url_references.await? {
if let ReferencedAsset::Some(asset) = *reference
.get_referenced_asset(*self.chunking_context)
.await?
{
references.push(asset);
}
}
}
Ok(OutputAssetsWithReferenced::from_assets(Vc::cell(
references,
)))
}
}
#[turbo_tasks::value_impl]
impl ChunkedItem for CssModuleChunkItem {
#[turbo_tasks::function]
fn asset_ident(&self) -> Vc<AssetIdent> {
self.module.ident()
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> { async fn chunk_item_content(
*self.chunking_context self: Vc<Self>,
} chunking_context: Vc<Box<dyn ChunkingContext>>,
module_graph: Vc<ModuleGraph>,
#[turbo_tasks::function] ) -> Result<Vc<CssChunkItemContent>> {
fn ty(&self) -> Vc<Box<dyn ChunkType>> { let this = self.await?;
Vc::upcast(Vc::<CssChunkType>::default()) let references = &*self.references().await?;
}
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(*self.module)
}
}
#[turbo_tasks::value_impl]
impl CssChunkItem for CssModuleChunkItem {
#[turbo_tasks::function]
async fn content(&self) -> Result<Vc<CssChunkItemContent>> {
let references = &*self.module.references().await?;
let mut imports = vec![]; let mut imports = vec![];
let chunking_context = self.chunking_context; let chunking_context = chunking_context.to_resolved().await?;
let module_graph = module_graph.to_resolved().await?;
for reference in references.iter() { for reference in references.iter() {
if let Some(import_ref) = if let Some(import_ref) =
...@@ -281,14 +199,14 @@ impl CssChunkItem for CssModuleChunkItem { ...@@ -281,14 +199,14 @@ impl CssChunkItem for CssModuleChunkItem {
if let Some(placeable) = if let Some(placeable) =
ResolvedVc::try_downcast::<Box<dyn CssChunkPlaceable>>(module) ResolvedVc::try_downcast::<Box<dyn CssChunkPlaceable>>(module)
{ {
let item = let item = ChunkItem::new(
chunking_context.chunk_item(Vc::upcast(*placeable), *self.module_graph); Vc::upcast(*placeable),
let inner: ResolvedVc<Box<dyn ChunkedItem>> = *item.await?; *module_graph,
if let Some(css_item) = *chunking_context,
ResolvedVc::try_downcast::<Box<dyn CssChunkItem>>(inner) )
{ .to_resolved()
imports.push(CssImport::Internal(import_ref, css_item)); .await?;
} imports.push(CssImport::Internal(import_ref, item));
} }
} }
} else if let Some(compose_ref) = } else if let Some(compose_ref) =
...@@ -305,14 +223,14 @@ impl CssChunkItem for CssModuleChunkItem { ...@@ -305,14 +223,14 @@ impl CssChunkItem for CssModuleChunkItem {
if let Some(placeable) = if let Some(placeable) =
ResolvedVc::try_downcast::<Box<dyn CssChunkPlaceable>>(module) ResolvedVc::try_downcast::<Box<dyn CssChunkPlaceable>>(module)
{ {
let item = let item = ChunkItem::new(
chunking_context.chunk_item(Vc::upcast(*placeable), *self.module_graph); Vc::upcast(*placeable),
let inner: ResolvedVc<Box<dyn ChunkedItem>> = *item.await?; *module_graph,
if let Some(css_item) = *chunking_context,
ResolvedVc::try_downcast::<Box<dyn CssChunkItem>>(inner) )
{ .to_resolved()
imports.push(CssImport::Composes(css_item)); .await?;
} imports.push(CssImport::Composes(item));
} }
} }
} }
...@@ -335,7 +253,6 @@ impl CssChunkItem for CssModuleChunkItem { ...@@ -335,7 +253,6 @@ impl CssChunkItem for CssModuleChunkItem {
} }
let result = self let result = self
.module
.finalize_css(*chunking_context, *chunking_context.minify_type().await?) .finalize_css(*chunking_context, *chunking_context.minify_type().await?)
.await?; .await?;
...@@ -347,17 +264,13 @@ impl CssChunkItem for CssModuleChunkItem { ...@@ -347,17 +264,13 @@ impl CssChunkItem for CssModuleChunkItem {
Ok(CssChunkItemContent { Ok(CssChunkItemContent {
inner_code: output_code.to_owned().into(), inner_code: output_code.to_owned().into(),
imports, imports,
import_context: self.module.await?.import_context, import_context: this.import_context,
source_map: *source_map, source_map: *source_map,
} }
.cell()) .cell())
} else { } else {
Ok(CssChunkItemContent { Ok(CssChunkItemContent {
inner_code: format!( inner_code: format!("/* unparsable {} */", self.ident().to_string().await?).into(),
"/* unparsable {} */",
self.module.ident().to_string().await?
)
.into(),
imports: vec![], imports: vec![],
import_context: None, import_context: None,
source_map: FileContent::NotFound.resolved_cell(), source_map: FileContent::NotFound.resolved_cell(),
...@@ -365,4 +278,38 @@ impl CssChunkItem for CssModuleChunkItem { ...@@ -365,4 +278,38 @@ impl CssChunkItem for CssModuleChunkItem {
.cell()) .cell())
} }
} }
#[turbo_tasks::function]
async fn chunk_item_output_assets(
self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
_module_graph: Vc<ModuleGraph>,
) -> Result<Vc<OutputAssetsWithReferenced>> {
let mut references = Vec::new();
if let ParseCssResult::Ok { url_references, .. } = &*self.parse_css().await? {
for (_, reference) in url_references.await? {
if let ReferencedAsset::Some(asset) =
*reference.get_referenced_asset(chunking_context).await?
{
references.push(asset);
}
}
}
Ok(OutputAssetsWithReferenced::from_assets(Vc::cell(
references,
)))
}
}
#[turbo_tasks::value_impl]
impl ResolveOrigin for CssModuleAsset {
#[turbo_tasks::function]
fn origin_path(&self) -> Vc<FileSystemPath> {
self.source.ident().path()
}
#[turbo_tasks::function]
fn asset_context(&self) -> Vc<Box<dyn AssetContext>> {
*self.asset_context
}
} }
...@@ -15,8 +15,8 @@ use turbopack_core::{ ...@@ -15,8 +15,8 @@ use turbopack_core::{
chunk::{ chunk::{
AsyncModuleInfo, Chunk, ChunkItem, ChunkItemBatchGroup, ChunkItemExt, AsyncModuleInfo, Chunk, ChunkItem, ChunkItemBatchGroup, ChunkItemExt,
ChunkItemOrBatchWithAsyncModuleInfo, ChunkItemWithAsyncModuleInfo, ChunkType, ChunkItemOrBatchWithAsyncModuleInfo, ChunkItemWithAsyncModuleInfo, ChunkType,
ChunkableModule, ChunkedItem, ChunkingContext, ChunkingContextExt, MinifyType, OutputChunk, ChunkingContext, ChunkingContextExt, MinifyType, OutputChunk, OutputChunkRuntimeInfo,
OutputChunkRuntimeInfo, SourceMapSourceType, round_chunk_item_size, SourceMapSourceType, round_chunk_item_size,
}, },
code_builder::{Code, CodeBuilder}, code_builder::{Code, CodeBuilder},
ident::AssetIdent, ident::AssetIdent,
...@@ -26,7 +26,8 @@ use turbopack_core::{ ...@@ -26,7 +26,8 @@ use turbopack_core::{
utils::{children_from_output_assets, content_to_details}, utils::{children_from_output_assets, content_to_details},
}, },
module::Module, module::Module,
output::{OutputAsset, OutputAssetsReference, OutputAssetsWithReferenced}, module_graph::ModuleGraph,
output::{OutputAsset, OutputAssets, OutputAssetsReference, OutputAssetsWithReferenced},
reference_type::ImportContext, reference_type::ImportContext,
server_fs::ServerFileSystem, server_fs::ServerFileSystem,
source_map::{ source_map::{
...@@ -79,7 +80,15 @@ impl CssChunk { ...@@ -79,7 +80,15 @@ impl CssChunk {
let mut body = CodeBuilder::new(source_maps, false); let mut body = CodeBuilder::new(source_maps, false);
let mut external_imports = FxIndexSet::default(); let mut external_imports = FxIndexSet::default();
for css_item in &this.content.await?.chunk_items { for css_item in &this.content.await?.chunk_items {
let content = &css_item.content().await?; let css_item_data = css_item.await?;
let Some(placeable) =
ResolvedVc::try_downcast::<Box<dyn CssChunkPlaceable>>(css_item_data.module)
else {
continue;
};
let content = &*placeable
.chunk_item_content(*css_item_data.chunking_context, *css_item_data.module_graph)
.await?;
for import in &content.imports { for import in &content.imports {
if let CssImport::External(external_import) = import { if let CssImport::External(external_import) = import {
external_imports.insert((*external_import.await?).to_string()); external_imports.insert((*external_import.await?).to_string());
...@@ -249,7 +258,7 @@ pub async fn write_import_context( ...@@ -249,7 +258,7 @@ pub async fn write_import_context(
#[turbo_tasks::value] #[turbo_tasks::value]
pub struct CssChunkContent { pub struct CssChunkContent {
pub chunk_items: Vec<ResolvedVc<Box<dyn CssChunkItem>>>, pub chunk_items: Vec<ResolvedVc<ChunkItem>>,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -267,7 +276,7 @@ impl OutputAssetsReference for CssChunk { ...@@ -267,7 +276,7 @@ impl OutputAssetsReference for CssChunk {
.chunk_items .chunk_items
.iter() .iter()
.map(|item| async { .map(|item| async {
let refs = item.references().await?; let refs = OutputAssetsReference::references(**item).await?;
let single_css_chunk = if should_generate_single_item_chunks { let single_css_chunk = if should_generate_single_item_chunks {
Some(ResolvedVc::upcast( Some(ResolvedVc::upcast(
SingleItemCssChunk::new(*this.chunking_context, **item) SingleItemCssChunk::new(*this.chunking_context, **item)
...@@ -357,15 +366,25 @@ impl OutputChunk for CssChunk { ...@@ -357,15 +366,25 @@ impl OutputChunk for CssChunk {
let entries_chunk_items = &content.chunk_items; let entries_chunk_items = &content.chunk_items;
let included_ids = entries_chunk_items let included_ids = entries_chunk_items
.iter() .iter()
.map(|chunk_item| chunk_item.id()) .map(|chunk_item| (**chunk_item).id())
.try_join() .try_join()
.await?; .await?;
let imports_chunk_items: Vec<_> = entries_chunk_items let imports_chunk_items: Vec<_> = entries_chunk_items
.iter() .iter()
.map(|&css_item| async move { .map(|&css_item| async move {
Ok(css_item let css_item_data = css_item.await?;
.content() let Some(placeable) =
.await? ResolvedVc::try_downcast::<Box<dyn CssChunkPlaceable>>(css_item_data.module)
else {
return Ok(Vec::new());
};
let content = placeable
.chunk_item_content(
*css_item_data.chunking_context,
*css_item_data.module_graph,
)
.await?;
Ok(content
.imports .imports
.iter() .iter()
.filter_map(|import| { .filter_map(|import| {
...@@ -439,19 +458,34 @@ impl GenerateSourceMap for CssChunk { ...@@ -439,19 +458,34 @@ impl GenerateSourceMap for CssChunk {
} }
} }
// TODO: remove
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait CssChunkPlaceable: ChunkableModule + Module {} pub trait CssChunkPlaceable: Module {
#[turbo_tasks::function]
fn chunk_item_content(
self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
module_graph: Vc<ModuleGraph>,
) -> Vc<CssChunkItemContent>;
/// Returns the output assets associated with this module's chunk item.
/// Most CSS modules have no output assets; override for modules that produce
/// additional output (e.g. url references).
#[turbo_tasks::function]
fn chunk_item_output_assets(
self: Vc<Self>,
_chunking_context: Vc<Box<dyn ChunkingContext>>,
_module_graph: Vc<ModuleGraph>,
) -> Vc<OutputAssetsWithReferenced> {
OutputAssetsWithReferenced::from_assets(*OutputAssets::empty_resolved())
}
}
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
pub enum CssImport { pub enum CssImport {
External(ResolvedVc<RcStr>), External(ResolvedVc<RcStr>),
Internal( Internal(ResolvedVc<ImportAssetReference>, ResolvedVc<ChunkItem>),
ResolvedVc<ImportAssetReference>, Composes(ResolvedVc<ChunkItem>),
ResolvedVc<Box<dyn CssChunkItem>>,
),
Composes(ResolvedVc<Box<dyn CssChunkItem>>),
} }
#[derive(Debug)] #[derive(Debug)]
...@@ -463,12 +497,6 @@ pub struct CssChunkItemContent { ...@@ -463,12 +497,6 @@ pub struct CssChunkItemContent {
pub source_map: ResolvedVc<FileContent>, pub source_map: ResolvedVc<FileContent>,
} }
#[turbo_tasks::value_trait]
pub trait CssChunkItem: ChunkedItem + OutputAssetsReference {
#[turbo_tasks::function]
fn content(self: Vc<Self>) -> Vc<CssChunkItemContent>;
}
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl Introspectable for CssChunk { impl Introspectable for CssChunk {
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -534,6 +562,10 @@ impl ChunkType for CssChunkType { ...@@ -534,6 +562,10 @@ impl ChunkType for CssChunkType {
Vc::cell(true) Vc::cell(true)
} }
fn accepts_module(&self, module: ResolvedVc<Box<dyn Module>>) -> bool {
ResolvedVc::try_sidecast::<Box<dyn CssChunkPlaceable>>(module).is_some()
}
#[turbo_tasks::function] #[turbo_tasks::function]
async fn chunk( async fn chunk(
&self, &self,
...@@ -557,17 +589,8 @@ impl ChunkType for CssChunkType { ...@@ -557,17 +589,8 @@ impl ChunkType for CssChunkType {
let content = CssChunkContent { let content = CssChunkContent {
chunk_items: chunk_items chunk_items: chunk_items
.iter() .iter()
.map(async |ChunkItemWithAsyncModuleInfo { chunk_item, .. }| { .map(|ChunkItemWithAsyncModuleInfo { chunk_item, .. }| *chunk_item)
let inner: ResolvedVc<Box<dyn ChunkedItem>> = *chunk_item.await?; .collect(),
let Some(chunk_item) = ResolvedVc::try_downcast::<Box<dyn CssChunkItem>>(inner)
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
Ok(chunk_item)
})
.try_join()
.await?,
} }
.cell(); .cell();
Ok(Vc::upcast(CssChunk::new(*chunking_context, content))) Ok(Vc::upcast(CssChunk::new(*chunking_context, content)))
...@@ -580,13 +603,32 @@ impl ChunkType for CssChunkType { ...@@ -580,13 +603,32 @@ impl ChunkType for CssChunkType {
chunk_item: Vc<ChunkItem>, chunk_item: Vc<ChunkItem>,
_async_module_info: Option<Vc<AsyncModuleInfo>>, _async_module_info: Option<Vc<AsyncModuleInfo>>,
) -> Result<Vc<usize>> { ) -> Result<Vc<usize>> {
let inner: ResolvedVc<Box<dyn ChunkedItem>> = *chunk_item.await?; let chunk_item = chunk_item.await?;
let Some(chunk_item) = ResolvedVc::try_downcast::<Box<dyn CssChunkItem>>(inner) else { let Some(module) =
bail!("Chunk item is not an css chunk item but reporting chunk type css"); ResolvedVc::try_downcast::<Box<dyn CssChunkPlaceable>>(chunk_item.module)
else {
bail!("Chunk item is not a css chunk item but reporting chunk type css");
}; };
Ok(Vc::cell(chunk_item.content().await.map_or(0, |content| { Ok(Vc::cell(
round_chunk_item_size(content.inner_code.len()) module
}))) .chunk_item_content(*chunk_item.chunking_context, *chunk_item.module_graph)
.await
.map_or(0, |content| round_chunk_item_size(content.inner_code.len())),
))
}
#[turbo_tasks::function]
fn chunk_item_output_assets(
&self,
module: ResolvedVc<Box<dyn Module>>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
module_graph: Vc<ModuleGraph>,
) -> Vc<OutputAssetsWithReferenced> {
if let Some(placeable) = ResolvedVc::try_sidecast::<Box<dyn CssChunkPlaceable>>(module) {
placeable.chunk_item_output_assets(chunking_context, module_graph)
} else {
OutputAssetsWithReferenced::from_assets(*OutputAssets::empty_resolved())
}
} }
} }
......
...@@ -6,7 +6,7 @@ use turbo_tasks::{ResolvedVc, ValueToString, Vc}; ...@@ -6,7 +6,7 @@ use turbo_tasks::{ResolvedVc, ValueToString, Vc};
use turbo_tasks_fs::{File, FileContent, FileSystemPath, rope::RopeBuilder}; use turbo_tasks_fs::{File, FileContent, FileSystemPath, rope::RopeBuilder};
use turbopack_core::{ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
chunk::{Chunk, ChunkedItem, ChunkingContext, MinifyType}, chunk::{Chunk, ChunkItem, ChunkingContext, MinifyType},
code_builder::{Code, CodeBuilder}, code_builder::{Code, CodeBuilder},
ident::AssetIdent, ident::AssetIdent,
introspect::Introspectable, introspect::Introspectable,
...@@ -15,7 +15,7 @@ use turbopack_core::{ ...@@ -15,7 +15,7 @@ use turbopack_core::{
}; };
use super::source_map::SingleItemCssChunkSourceMapAsset; use super::source_map::SingleItemCssChunkSourceMapAsset;
use crate::chunk::{CssChunkItem, write_import_context}; use crate::chunk::{CssChunkPlaceable, write_import_context};
/// A CSS chunk that only contains a single item. This is used for selectively /// A CSS chunk that only contains a single item. This is used for selectively
/// loading CSS modules that are part of a larger chunk in development mode, and /// loading CSS modules that are part of a larger chunk in development mode, and
...@@ -23,7 +23,7 @@ use crate::chunk::{CssChunkItem, write_import_context}; ...@@ -23,7 +23,7 @@ use crate::chunk::{CssChunkItem, write_import_context};
#[turbo_tasks::value] #[turbo_tasks::value]
pub struct SingleItemCssChunk { pub struct SingleItemCssChunk {
pub(super) chunking_context: ResolvedVc<Box<dyn ChunkingContext>>, pub(super) chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
item: ResolvedVc<Box<dyn CssChunkItem>>, item: ResolvedVc<ChunkItem>,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -32,7 +32,7 @@ impl SingleItemCssChunk { ...@@ -32,7 +32,7 @@ impl SingleItemCssChunk {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn new( pub fn new(
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>, chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
item: ResolvedVc<Box<dyn CssChunkItem>>, item: ResolvedVc<ChunkItem>,
) -> Vc<Self> { ) -> Vc<Self> {
SingleItemCssChunk { SingleItemCssChunk {
chunking_context, chunking_context,
...@@ -63,7 +63,15 @@ impl SingleItemCssChunk { ...@@ -63,7 +63,15 @@ impl SingleItemCssChunk {
let id = this.item.asset_ident().to_string().await?; let id = this.item.asset_ident().to_string().await?;
writeln!(code, "/* {id} */")?; writeln!(code, "/* {id} */")?;
} }
let content = this.item.content().await?; let item_data = this.item.await?;
let Some(placeable) =
ResolvedVc::try_downcast::<Box<dyn CssChunkPlaceable>>(item_data.module)
else {
return Ok(code.build().cell());
};
let content = placeable
.chunk_item_content(*item_data.chunking_context, *item_data.module_graph)
.await?;
let close = write_import_context(&mut code, content.import_context).await?; let close = write_import_context(&mut code, content.import_context).await?;
code.push_source( code.push_source(
......
...@@ -241,8 +241,6 @@ impl ModuleCssAsset { ...@@ -241,8 +241,6 @@ impl ModuleCssAsset {
} }
} }
turbopack_core::chunk_item!(ModuleCssAsset, ecmascript);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for ModuleCssAsset { impl EcmascriptChunkPlaceable for ModuleCssAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -10,11 +10,10 @@ use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_hex}; ...@@ -10,11 +10,10 @@ use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_hex};
use turbopack_core::{ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
chunk::{ chunk::{
ChunkableModule, ChunkingContext, ChunkingContextExt, EvaluatableAssets, ChunkItem, ChunkingContextExt, EvaluatableAssets, availability_info::AvailabilityInfo,
availability_info::AvailabilityInfo,
}, },
module::Module, module::Module,
module_graph::{ModuleGraph, chunk_group_info::ChunkGroup}, module_graph::chunk_group_info::ChunkGroup,
output::{OutputAsset, OutputAssetsReference, OutputAssetsWithReferenced}, output::{OutputAsset, OutputAssetsReference, OutputAssetsWithReferenced},
version::{Version, VersionedContent}, version::{Version, VersionedContent},
}; };
...@@ -23,9 +22,7 @@ use turbopack_core::{ ...@@ -23,9 +22,7 @@ use turbopack_core::{
Clone, Debug, Eq, Hash, NonLocalValue, PartialEq, TaskInput, TraceRawVcs, Encode, Decode, Clone, Debug, Eq, Hash, NonLocalValue, PartialEq, TaskInput, TraceRawVcs, Encode, Decode,
)] )]
pub struct DevHtmlEntry { pub struct DevHtmlEntry {
pub chunkable_module: ResolvedVc<Box<dyn ChunkableModule>>, pub chunk_item: ResolvedVc<ChunkItem>,
pub module_graph: ResolvedVc<ModuleGraph>,
pub chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
pub runtime_entries: Option<ResolvedVc<EvaluatableAssets>>, pub runtime_entries: Option<ResolvedVc<EvaluatableAssets>>,
} }
...@@ -136,15 +133,18 @@ impl DevHtmlAsset { ...@@ -136,15 +133,18 @@ impl DevHtmlAsset {
.iter() .iter()
.map(|entry| async move { .map(|entry| async move {
let &DevHtmlEntry { let &DevHtmlEntry {
chunkable_module, chunk_item,
chunking_context,
module_graph,
runtime_entries, runtime_entries,
} = entry; } = entry;
let chunk_item = chunk_item.await?;
let module = chunk_item.module;
let chunking_context = chunk_item.chunking_context;
let module_graph = chunk_item.module_graph;
let asset_with_referenced = if let Some(runtime_entries) = runtime_entries { let asset_with_referenced = if let Some(runtime_entries) = runtime_entries {
let runtime_entries = let runtime_entries =
if let Some(evaluatable) = ResolvedVc::try_downcast(chunkable_module) { if let Some(evaluatable) = ResolvedVc::try_downcast(module) {
runtime_entries runtime_entries
.with_entry(*evaluatable) .with_entry(*evaluatable)
.to_resolved() .to_resolved()
...@@ -154,7 +154,7 @@ impl DevHtmlAsset { ...@@ -154,7 +154,7 @@ impl DevHtmlAsset {
}; };
chunking_context chunking_context
.evaluated_chunk_group_assets( .evaluated_chunk_group_assets(
chunkable_module.ident(), module.ident(),
ChunkGroup::Entry( ChunkGroup::Entry(
runtime_entries runtime_entries
.await? .await?
...@@ -169,8 +169,8 @@ impl DevHtmlAsset { ...@@ -169,8 +169,8 @@ impl DevHtmlAsset {
} else { } else {
chunking_context chunking_context
.root_chunk_group_assets( .root_chunk_group_assets(
chunkable_module.ident(), module.ident(),
ChunkGroup::Entry(vec![ResolvedVc::upcast(chunkable_module)]), ChunkGroup::Entry(vec![module]),
*module_graph, *module_graph,
) )
.await? .await?
......
...@@ -5,8 +5,8 @@ use turbo_rcstr::rcstr; ...@@ -5,8 +5,8 @@ use turbo_rcstr::rcstr;
use turbo_tasks::{ResolvedVc, TryJoinIterExt, ValueToString, Vc}; use turbo_tasks::{ResolvedVc, TryJoinIterExt, ValueToString, Vc};
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{
AsyncModuleInfo, ChunkData, ChunkableModule, ChunkingContext, ChunkingContextExt, AsyncModuleInfo, ChunkData, ChunkingContext, ChunkingContextExt, ChunksData,
ChunksData, ModuleChunkItemIdExt, availability_info::AvailabilityInfo, ModuleChunkItemIdExt, availability_info::AvailabilityInfo,
}, },
ident::AssetIdent, ident::AssetIdent,
module::{Module, ModuleSideEffects}, module::{Module, ModuleSideEffects},
...@@ -30,7 +30,7 @@ use crate::{ ...@@ -30,7 +30,7 @@ use crate::{
/// putting it into a separate chunk group. /// putting it into a separate chunk group.
#[turbo_tasks::value] #[turbo_tasks::value]
pub struct AsyncLoaderModule { pub struct AsyncLoaderModule {
pub inner: ResolvedVc<Box<dyn ChunkableModule>>, pub inner: ResolvedVc<Box<dyn Module>>,
pub chunking_context: ResolvedVc<Box<dyn ChunkingContext>>, pub chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
pub availability_info: AvailabilityInfo, pub availability_info: AvailabilityInfo,
} }
...@@ -39,7 +39,7 @@ pub struct AsyncLoaderModule { ...@@ -39,7 +39,7 @@ pub struct AsyncLoaderModule {
impl AsyncLoaderModule { impl AsyncLoaderModule {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn new( pub fn new(
module: ResolvedVc<Box<dyn ChunkableModule>>, module: ResolvedVc<Box<dyn Module>>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>, chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<Self> { ) -> Vc<Self> {
...@@ -51,7 +51,7 @@ impl AsyncLoaderModule { ...@@ -51,7 +51,7 @@ impl AsyncLoaderModule {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn asset_ident_for(module: Vc<Box<dyn ChunkableModule>>) -> Vc<AssetIdent> { pub fn asset_ident_for(module: Vc<Box<dyn Module>>) -> Vc<AssetIdent> {
module.ident().with_modifier(rcstr!("async loader")) module.ident().with_modifier(rcstr!("async loader"))
} }
...@@ -61,9 +61,9 @@ impl AsyncLoaderModule { ...@@ -61,9 +61,9 @@ impl AsyncLoaderModule {
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
) -> Result<Vc<OutputAssetsWithReferenced>> { ) -> Result<Vc<OutputAssetsWithReferenced>> {
if let Some(chunk_items) = self.availability_info.available_modules() { if let Some(chunk_items) = self.availability_info.available_modules() {
let inner_module = ResolvedVc::upcast(self.inner); let inner_module = self.inner;
let batches = module_graph let batches = module_graph
.module_batches(self.chunking_context.batching_config()) .module_batches(self.chunking_context.chunking_configs())
.await?; .await?;
let module_or_batch = batches.get_entry(inner_module).await?; let module_or_batch = batches.get_entry(inner_module).await?;
if let Some(chunkable_module_or_batch) = if let Some(chunkable_module_or_batch) =
...@@ -80,7 +80,7 @@ impl AsyncLoaderModule { ...@@ -80,7 +80,7 @@ impl AsyncLoaderModule {
} }
Ok(self.chunking_context.chunk_group_assets( Ok(self.chunking_context.chunk_group_assets(
self.inner.ident(), self.inner.ident(),
ChunkGroup::Async(ResolvedVc::upcast(self.inner)), ChunkGroup::Async(self.inner),
module_graph, module_graph,
self.availability_info, self.availability_info,
)) ))
...@@ -119,12 +119,9 @@ impl Module for AsyncLoaderModule { ...@@ -119,12 +119,9 @@ impl Module for AsyncLoaderModule {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> { async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> {
Ok(Vc::cell(vec![ResolvedVc::upcast( Ok(Vc::cell(vec![ResolvedVc::upcast(
SingleModuleReference::new( SingleModuleReference::new(*self.await?.inner, rcstr!("async module"))
*ResolvedVc::upcast(self.await?.inner), .to_resolved()
rcstr!("async module"), .await?,
)
.to_resolved()
.await?,
)])) )]))
} }
...@@ -134,8 +131,6 @@ impl Module for AsyncLoaderModule { ...@@ -134,8 +131,6 @@ impl Module for AsyncLoaderModule {
} }
} }
turbopack_core::chunk_item!(AsyncLoaderModule, crate::chunk::ecmascript_chunk_item);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for AsyncLoaderModule { impl EcmascriptChunkPlaceable for AsyncLoaderModule {
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -38,13 +38,13 @@ impl EcmascriptChunkItemOrBatchWithAsyncInfo { ...@@ -38,13 +38,13 @@ impl EcmascriptChunkItemOrBatchWithAsyncInfo {
}) })
} }
pub fn references(&self) -> Vc<OutputAssetsWithReferenced> { pub async fn references(&self) -> Result<Vc<OutputAssetsWithReferenced>> {
match self { Ok(match self {
EcmascriptChunkItemOrBatchWithAsyncInfo::ChunkItem(item) => { EcmascriptChunkItemOrBatchWithAsyncInfo::ChunkItem(item) => {
item.chunk_item.references() item.chunk_item().await?.references()
} }
EcmascriptChunkItemOrBatchWithAsyncInfo::Batch(batch) => batch.references(), EcmascriptChunkItemOrBatchWithAsyncInfo::Batch(batch) => batch.references(),
} })
} }
} }
...@@ -76,7 +76,7 @@ impl EcmascriptChunkBatchWithAsyncInfo { ...@@ -76,7 +76,7 @@ impl EcmascriptChunkBatchWithAsyncInfo {
let mut references = Vec::new(); let mut references = Vec::new();
// We expect most references to be empty, and avoiding try_join to avoid allocating the Vec // We expect most references to be empty, and avoiding try_join to avoid allocating the Vec
for item in &self.chunk_items { for item in &self.chunk_items {
let r = item.chunk_item.references().await?; let r = item.chunk_item().await?.references().await?;
output_assets.extend(r.assets.await?); output_assets.extend(r.assets.await?);
referenced_output_assets.extend(r.referenced_assets.await?); referenced_output_assets.extend(r.referenced_assets.await?);
references.extend(r.references.await?); references.extend(r.references.await?);
......
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use turbo_tasks::{ResolvedVc, TryJoinIterExt, ValueDefault, ValueToString, Vc}; use turbo_tasks::{ResolvedVc, TryJoinIterExt, ValueDefault, ValueToString, Vc};
use turbopack_core::chunk::{ use turbopack_core::{
AsyncModuleInfo, Chunk, ChunkItem, ChunkItemBatchGroup, ChunkItemOrBatchWithAsyncModuleInfo, chunk::{
ChunkType, ChunkedItem, ChunkingContext, round_chunk_item_size, AsyncModuleInfo, Chunk, ChunkItem, ChunkItemBatchGroup,
ChunkItemOrBatchWithAsyncModuleInfo, ChunkType, ChunkingContext, round_chunk_item_size,
},
ident::AssetIdent,
module::Module,
module_graph::ModuleGraph,
output::{OutputAssets, OutputAssetsWithReferenced},
}; };
use super::{EcmascriptChunk, EcmascriptChunkContent, EcmascriptChunkItem}; use super::{EcmascriptChunk, EcmascriptChunkContent};
use crate::chunk::batch::{EcmascriptChunkItemBatchGroup, EcmascriptChunkItemOrBatchWithAsyncInfo}; use crate::chunk::{
batch::{EcmascriptChunkItemBatchGroup, EcmascriptChunkItemOrBatchWithAsyncInfo},
placeable::EcmascriptChunkPlaceable,
};
#[turbo_tasks::value] #[turbo_tasks::value]
#[derive(Default, ValueToString)] #[derive(Default, ValueToString)]
...@@ -20,6 +29,10 @@ impl ChunkType for EcmascriptChunkType { ...@@ -20,6 +29,10 @@ impl ChunkType for EcmascriptChunkType {
Vc::cell(false) Vc::cell(false)
} }
fn accepts_module(&self, module: ResolvedVc<Box<dyn Module>>) -> bool {
ResolvedVc::try_sidecast::<Box<dyn EcmascriptChunkPlaceable>>(module).is_some()
}
#[turbo_tasks::function] #[turbo_tasks::function]
async fn chunk( async fn chunk(
&self, &self,
...@@ -53,17 +66,55 @@ impl ChunkType for EcmascriptChunkType { ...@@ -53,17 +66,55 @@ impl ChunkType for EcmascriptChunkType {
chunk_item: Vc<ChunkItem>, chunk_item: Vc<ChunkItem>,
async_module_info: Option<Vc<AsyncModuleInfo>>, async_module_info: Option<Vc<AsyncModuleInfo>>,
) -> Result<Vc<usize>> { ) -> Result<Vc<usize>> {
let inner: ResolvedVc<Box<dyn ChunkedItem>> = *chunk_item.await?; let chunk_item = chunk_item.await?;
let Some(chunk_item) = ResolvedVc::try_downcast::<Box<dyn EcmascriptChunkItem>>(inner) let module = chunk_item.module;
let Some(module) = ResolvedVc::try_downcast::<Box<dyn EcmascriptChunkPlaceable>>(module)
else { else {
bail!("Chunk item is not an ecmascript chunk item but reporting chunk type ecmascript"); bail!("Chunk item is not an ecmascript chunk item but reporting chunk type ecmascript");
}; };
Ok(Vc::cell( let content = module
chunk_item .chunk_item_content(
.content_with_async_module_info(async_module_info, true) *chunk_item.chunking_context,
.await *chunk_item.module_graph,
.map_or(0, |content| round_chunk_item_size(content.inner_code.len())), async_module_info,
)) true,
)
.await;
Ok(Vc::cell(content.map_or(0, |content| {
round_chunk_item_size(content.inner_code.len())
})))
}
#[turbo_tasks::function]
fn chunk_item_content_ident(
&self,
module: ResolvedVc<Box<dyn Module>>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
module_graph: Vc<ModuleGraph>,
) -> Vc<AssetIdent> {
if let Some(placeable) =
ResolvedVc::try_sidecast::<Box<dyn EcmascriptChunkPlaceable>>(module)
{
placeable.chunk_item_content_ident(chunking_context, module_graph)
} else {
module.ident()
}
}
#[turbo_tasks::function]
fn chunk_item_output_assets(
&self,
module: ResolvedVc<Box<dyn Module>>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
module_graph: Vc<ModuleGraph>,
) -> Vc<OutputAssetsWithReferenced> {
if let Some(placeable) =
ResolvedVc::try_sidecast::<Box<dyn EcmascriptChunkPlaceable>>(module)
{
placeable.chunk_item_output_assets(chunking_context, module_graph)
} else {
OutputAssetsWithReferenced::from_assets(*OutputAssets::empty_resolved())
}
} }
} }
......
...@@ -8,8 +8,8 @@ use turbopack_core::{ ...@@ -8,8 +8,8 @@ use turbopack_core::{
}; };
use crate::chunk::{ use crate::chunk::{
EcmascriptChunkItemBatchGroup, EcmascriptChunkItemExt, EcmascriptChunkItemOrBatchWithAsyncInfo, EcmascriptChunkItemBatchGroup, EcmascriptChunkItemOrBatchWithAsyncInfo,
EcmascriptChunkItemWithAsyncInfo, ecmascript_chunk_item_code,
}; };
#[turbo_tasks::value(transparent, serialization = "none")] #[turbo_tasks::value(transparent, serialization = "none")]
...@@ -42,13 +42,14 @@ pub async fn item_code_and_ids( ...@@ -42,13 +42,14 @@ pub async fn item_code_and_ids(
item: EcmascriptChunkItemOrBatchWithAsyncInfo, item: EcmascriptChunkItemOrBatchWithAsyncInfo,
) -> Result<Vc<CodeAndIds>> { ) -> Result<Vc<CodeAndIds>> {
Ok(Vc::cell(match item { Ok(Vc::cell(match item {
EcmascriptChunkItemOrBatchWithAsyncInfo::ChunkItem(EcmascriptChunkItemWithAsyncInfo { EcmascriptChunkItemOrBatchWithAsyncInfo::ChunkItem(ref info) => {
chunk_item, let id = info.chunk_item().await?.id().await?;
async_info, let code = ecmascript_chunk_item_code(
.. info.module,
}) => { info.chunking_context,
let id = chunk_item.id().await?; info.module_graph,
let code = chunk_item.code(async_info.map(|info| *info)); info.async_info.map(|info| *info),
);
smallvec![(id, code.await?)] smallvec![(id, code.await?)]
} }
EcmascriptChunkItemOrBatchWithAsyncInfo::Batch(batch) => batch EcmascriptChunkItemOrBatchWithAsyncInfo::Batch(batch) => batch
...@@ -57,10 +58,14 @@ pub async fn item_code_and_ids( ...@@ -57,10 +58,14 @@ pub async fn item_code_and_ids(
.iter() .iter()
.map(|item| async { .map(|item| async {
Ok(( Ok((
item.chunk_item.id().await?, item.chunk_item().await?.id().await?,
item.chunk_item ecmascript_chunk_item_code(
.code(item.async_info.map(|info| *info)) item.module,
.await?, item.chunking_context,
item.module_graph,
item.async_info.map(|info| *info),
)
.await?,
)) ))
}) })
.try_join() .try_join()
......
use std::future::IntoFuture; use std::future::IntoFuture;
use anyhow::Result; use anyhow::Result;
use either::Either; use turbo_tasks::{ReadRef, ResolvedVc, Vc};
use turbo_tasks::{ReadRef, ResolvedVc, TryJoinIterExt, Vc}; use turbopack_core::chunk::{ChunkItem, ChunkItems, batch_info};
use turbopack_core::chunk::{ChunkItem, ChunkItems, ChunkedItem, batch_info};
use crate::chunk::{ use crate::chunk::{
CodeAndIds, CodeAndIds,
...@@ -21,31 +20,21 @@ pub struct EcmascriptChunkContent { ...@@ -21,31 +20,21 @@ pub struct EcmascriptChunkContent {
impl EcmascriptChunkContent { impl EcmascriptChunkContent {
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn included_chunk_items(&self) -> Result<Vc<ChunkItems>> { pub async fn included_chunk_items(&self) -> Result<Vc<ChunkItems>> {
Ok(ChunkItems( let mut result: Vec<ResolvedVc<ChunkItem>> = Vec::new();
self.chunk_items for item in &self.chunk_items {
.iter() match item {
.map(async |item| match item { EcmascriptChunkItemOrBatchWithAsyncInfo::ChunkItem(item) => {
EcmascriptChunkItemOrBatchWithAsyncInfo::ChunkItem(item) => { result.push(item.chunk_item().await?);
Ok(Either::Left(item.chunk_item)) }
EcmascriptChunkItemOrBatchWithAsyncInfo::Batch(batch) => {
let batch = batch.await?;
for item in &batch.chunk_items {
result.push(item.chunk_item().await?);
} }
EcmascriptChunkItemOrBatchWithAsyncInfo::Batch(batch) => { }
Ok(Either::Right(batch.await?)) }
} }
}) Ok(ChunkItems(result).cell())
.try_join()
.await?
.iter()
.flat_map(|item| match item {
Either::Left(item) => Either::Left(std::iter::once(*item)),
Either::Right(batch) => {
Either::Right(batch.chunk_items.iter().map(|item| item.chunk_item))
}
})
.map(ResolvedVc::upcast::<Box<dyn ChunkedItem>>)
.map(|item| ChunkItem(item).resolved_cell())
.collect(),
)
.cell())
} }
} }
......
...@@ -5,27 +5,24 @@ use bincode::{Decode, Encode}; ...@@ -5,27 +5,24 @@ use bincode::{Decode, Encode};
use smallvec::SmallVec; use smallvec::SmallVec;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ use turbo_tasks::{
NonLocalValue, PrettyPrintError, ResolvedVc, TaskInput, Upcast, ValueToString, Vc, NonLocalValue, PrettyPrintError, ResolvedVc, TaskInput, ValueToString, Vc, trace::TraceRawVcs,
trace::TraceRawVcs,
}; };
use turbo_tasks_fs::{FileSystemPath, rope::Rope}; use turbo_tasks_fs::{FileSystemPath, rope::Rope};
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{
AsyncModuleInfo, ChunkItemWithAsyncModuleInfo, ChunkType, ChunkedItem, ChunkingContext, AsyncModuleInfo, ChunkItem, ChunkItemWithAsyncModuleInfo, ChunkingContext,
ChunkingContextExt, ModuleId, SourceMapSourceType, ChunkingContextExt, ModuleId, SourceMapSourceType,
}, },
code_builder::{Code, CodeBuilder}, code_builder::{Code, CodeBuilder},
ident::AssetIdent,
issue::{IssueExt, IssueSeverity, StyledString, code_gen::CodeGenerationIssue}, issue::{IssueExt, IssueSeverity, StyledString, code_gen::CodeGenerationIssue},
module::Module, module::Module,
module_graph::ModuleGraph, module_graph::ModuleGraph,
output::OutputAssetsReference,
source_map::utils::{absolute_fileify_source_map, relative_fileify_source_map}, source_map::utils::{absolute_fileify_source_map, relative_fileify_source_map},
}; };
use crate::{ use crate::{
EcmascriptModuleContent, EcmascriptModuleContent,
chunk::{chunk_type::EcmascriptChunkType, placeable::EcmascriptChunkPlaceable}, chunk::placeable::EcmascriptChunkPlaceable,
references::async_module::{AsyncModuleOptions, OptionAsyncModuleOptions}, references::async_module::{AsyncModuleOptions, OptionAsyncModuleOptions},
runtime_functions::TURBOPACK_ASYNC_MODULE, runtime_functions::TURBOPACK_ASYNC_MODULE,
utils::StringifyJs, utils::StringifyJs,
...@@ -125,7 +122,7 @@ impl EcmascriptChunkItemContent { ...@@ -125,7 +122,7 @@ impl EcmascriptChunkItemContent {
} }
impl EcmascriptChunkItemContent { impl EcmascriptChunkItemContent {
async fn module_factory(&self) -> Result<ResolvedVc<Code>> { pub(crate) async fn module_factory(&self) -> Result<ResolvedVc<Code>> {
let mut code = CodeBuilder::default(); let mut code = CodeBuilder::default();
for additional_id in self.additional_ids.iter() { for additional_id in self.additional_ids.iter() {
writeln!(code, "{}, ", StringifyJs(&additional_id))?; writeln!(code, "{}, ", StringifyJs(&additional_id))?;
...@@ -201,7 +198,9 @@ pub struct EcmascriptChunkItemOptions { ...@@ -201,7 +198,9 @@ pub struct EcmascriptChunkItemOptions {
Debug, Clone, PartialEq, Eq, Hash, TraceRawVcs, TaskInput, NonLocalValue, Encode, Decode, Debug, Clone, PartialEq, Eq, Hash, TraceRawVcs, TaskInput, NonLocalValue, Encode, Decode,
)] )]
pub struct EcmascriptChunkItemWithAsyncInfo { pub struct EcmascriptChunkItemWithAsyncInfo {
pub chunk_item: ResolvedVc<Box<dyn EcmascriptChunkItem>>, pub module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
pub chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
pub module_graph: ResolvedVc<ModuleGraph>,
pub async_info: Option<ResolvedVc<AsyncModuleInfo>>, pub async_info: Option<ResolvedVc<AsyncModuleInfo>>,
} }
...@@ -214,59 +213,56 @@ impl EcmascriptChunkItemWithAsyncInfo { ...@@ -214,59 +213,56 @@ impl EcmascriptChunkItemWithAsyncInfo {
module: _, module: _,
async_info, async_info,
} = chunk_item; } = chunk_item;
let inner: ResolvedVc<Box<dyn ChunkedItem>> = *chunk_item.await?; let chunk_item_data = chunk_item.await?;
let Some(chunk_item) = ResolvedVc::try_downcast::<Box<dyn EcmascriptChunkItem>>(inner) let Some(module) =
ResolvedVc::try_downcast::<Box<dyn EcmascriptChunkPlaceable>>(chunk_item_data.module)
else { else {
bail!("Chunk item is not an ecmascript chunk item but reporting chunk type ecmascript"); bail!("Chunk item is not an ecmascript chunk item but reporting chunk type ecmascript");
}; };
Ok(EcmascriptChunkItemWithAsyncInfo { Ok(EcmascriptChunkItemWithAsyncInfo {
chunk_item, module,
chunking_context: chunk_item_data.chunking_context,
module_graph: chunk_item_data.module_graph,
async_info: *async_info, async_info: *async_info,
}) })
} }
}
#[turbo_tasks::value_trait]
pub trait EcmascriptChunkItem: ChunkedItem + OutputAssetsReference {
#[turbo_tasks::function]
fn content(self: Vc<Self>) -> Vc<EcmascriptChunkItemContent>;
/// Fetches the content of the chunk item with async module info. /// The [ChunkItem] for this ecmascript chunk item.
/// When `estimated` is true, it's ok to provide an estimated content, since it's only used for pub async fn chunk_item(&self) -> Result<ResolvedVc<ChunkItem>> {
/// compute the chunking. When `estimated` is true, this function should not invoke other ChunkItem::new(
/// chunking operations that would cause cycles. *ResolvedVc::upcast(self.module),
#[turbo_tasks::function] *self.module_graph,
fn content_with_async_module_info( *self.chunking_context,
self: Vc<Self>, )
_async_module_info: Option<Vc<AsyncModuleInfo>>, .to_resolved()
_estimated: bool, .await
) -> Vc<EcmascriptChunkItemContent> {
self.content()
} }
} }
pub trait EcmascriptChunkItemExt { /// Generates the module factory for the given ecmascript module.
/// Generates the module factory for this chunk item. pub fn ecmascript_chunk_item_code(
fn code(self: Vc<Self>, async_module_info: Option<Vc<AsyncModuleInfo>>) -> Vc<Code>; module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
} chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
module_graph: ResolvedVc<ModuleGraph>,
impl<T> EcmascriptChunkItemExt for T async_module_info: Option<Vc<AsyncModuleInfo>>,
where ) -> Vc<Code> {
T: Upcast<Box<dyn EcmascriptChunkItem>>, module_factory_with_code_generation_issue(
{ *module,
/// Generates the module factory for this chunk item. *chunking_context,
fn code(self: Vc<Self>, async_module_info: Option<Vc<AsyncModuleInfo>>) -> Vc<Code> { *module_graph,
module_factory_with_code_generation_issue(Vc::upcast_non_strict(self), async_module_info) async_module_info,
} )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn module_factory_with_code_generation_issue( async fn module_factory_with_code_generation_issue(
chunk_item: Vc<Box<dyn EcmascriptChunkItem>>, module: Vc<Box<dyn EcmascriptChunkPlaceable>>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
module_graph: Vc<ModuleGraph>,
async_module_info: Option<Vc<AsyncModuleInfo>>, async_module_info: Option<Vc<AsyncModuleInfo>>,
) -> Result<Vc<Code>> { ) -> Result<Vc<Code>> {
let content = match chunk_item let content = match module
.content_with_async_module_info(async_module_info, false) .chunk_item_content(chunking_context, module_graph, async_module_info, false)
.await .await
{ {
Ok(item) => item.module_factory().await, Ok(item) => item.module_factory().await,
...@@ -275,7 +271,7 @@ async fn module_factory_with_code_generation_issue( ...@@ -275,7 +271,7 @@ async fn module_factory_with_code_generation_issue(
Ok(match content { Ok(match content {
Ok(factory) => *factory, Ok(factory) => *factory,
Err(error) => { Err(error) => {
let id = chunk_item.asset_ident().to_string().await; let id = module.ident().to_string().await;
let id = id.as_ref().map_or_else(|_| "unknown", |id| &**id); let id = id.as_ref().map_or_else(|_| "unknown", |id| &**id);
let error = error.context(format!( let error = error.context(format!(
"An error occurred while generating the chunk item {id}" "An error occurred while generating the chunk item {id}"
...@@ -284,7 +280,7 @@ async fn module_factory_with_code_generation_issue( ...@@ -284,7 +280,7 @@ async fn module_factory_with_code_generation_issue(
let js_error_message = serde_json::to_string(&error_message)?; let js_error_message = serde_json::to_string(&error_message)?;
CodeGenerationIssue { CodeGenerationIssue {
severity: IssueSeverity::Error, severity: IssueSeverity::Error,
path: chunk_item.asset_ident().path().owned().await?, path: module.ident().path().owned().await?,
title: StyledString::Text(rcstr!("Code generation for chunk item errored")) title: StyledString::Text(rcstr!("Code generation for chunk item errored"))
.resolved_cell(), .resolved_cell(),
message: StyledString::Text(error_message).resolved_cell(), message: StyledString::Text(error_message).resolved_cell(),
...@@ -300,88 +296,3 @@ async fn module_factory_with_code_generation_issue( ...@@ -300,88 +296,3 @@ async fn module_factory_with_code_generation_issue(
} }
}) })
} }
/// Generic chunk item that wraps any EcmascriptChunkPlaceable module.
/// This replaces the need for individual per-module ChunkItem wrapper structs.
#[turbo_tasks::value]
pub struct EcmascriptModuleChunkItem {
module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
module_graph: ResolvedVc<ModuleGraph>,
}
/// Factory function to create an EcmascriptModuleChunkItem.
/// Use this instead of implementing ChunkableModule::as_chunk_item() on each module.
pub fn ecmascript_chunk_item(
module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
module_graph: ResolvedVc<ModuleGraph>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Vc<EcmascriptModuleChunkItem> {
EcmascriptModuleChunkItem {
module,
chunking_context,
module_graph,
}
.cell()
}
#[turbo_tasks::value_impl]
impl ChunkedItem for EcmascriptModuleChunkItem {
#[turbo_tasks::function]
fn asset_ident(&self) -> Vc<AssetIdent> {
self.module.ident()
}
#[turbo_tasks::function]
fn content_ident(&self) -> Vc<AssetIdent> {
self.module
.chunk_item_content_ident(*self.chunking_context, *self.module_graph)
}
#[turbo_tasks::function]
fn ty(&self) -> Vc<Box<dyn ChunkType>> {
Vc::upcast(Vc::<EcmascriptChunkType>::default())
}
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(*self.module)
}
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
*self.chunking_context
}
}
#[turbo_tasks::value_impl]
impl OutputAssetsReference for EcmascriptModuleChunkItem {
#[turbo_tasks::function]
fn references(&self) -> Vc<turbopack_core::output::OutputAssetsWithReferenced> {
self.module
.chunk_item_output_assets(*self.chunking_context, *self.module_graph)
}
}
#[turbo_tasks::value_impl]
impl EcmascriptChunkItem for EcmascriptModuleChunkItem {
#[turbo_tasks::function]
fn content(&self) -> Vc<EcmascriptChunkItemContent> {
self.module
.chunk_item_content(*self.chunking_context, *self.module_graph, None, false)
}
#[turbo_tasks::function]
fn content_with_async_module_info(
&self,
async_module_info: Option<Vc<AsyncModuleInfo>>,
estimated: bool,
) -> Vc<EcmascriptChunkItemContent> {
self.module.chunk_item_content(
*self.chunking_context,
*self.module_graph,
async_module_info,
estimated,
)
}
}
...@@ -33,8 +33,8 @@ pub use self::{ ...@@ -33,8 +33,8 @@ pub use self::{
content::EcmascriptChunkContent, content::EcmascriptChunkContent,
data::EcmascriptChunkData, data::EcmascriptChunkData,
item::{ item::{
EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkItemExt, EcmascriptChunkItemContent, EcmascriptChunkItemOptions, EcmascriptChunkItemWithAsyncInfo,
EcmascriptChunkItemOptions, EcmascriptChunkItemWithAsyncInfo, ecmascript_chunk_item, ecmascript_chunk_item_code,
}, },
placeable::{EcmascriptChunkPlaceable, EcmascriptExports}, placeable::{EcmascriptChunkPlaceable, EcmascriptExports},
}; };
...@@ -75,7 +75,7 @@ impl OutputAssetsReference for EcmascriptChunk { ...@@ -75,7 +75,7 @@ impl OutputAssetsReference for EcmascriptChunk {
.chunk_items .chunk_items
.iter() .iter()
.map(async |with_info| { .map(async |with_info| {
let r = with_info.references().await?; let r = with_info.references().await?.await?;
Ok(( Ok((
r.assets.await?, r.assets.await?,
r.referenced_assets.await?, r.referenced_assets.await?,
......
...@@ -9,7 +9,7 @@ use turbo_tasks_fs::{ ...@@ -9,7 +9,7 @@ use turbo_tasks_fs::{
}; };
use turbopack_core::{ use turbopack_core::{
asset::Asset, asset::Asset,
chunk::{AsyncModuleInfo, ChunkableModule, ChunkingContext}, chunk::{AsyncModuleInfo, ChunkingContext},
file_source::FileSource, file_source::FileSource,
ident::AssetIdent, ident::AssetIdent,
issue::{ issue::{
...@@ -31,7 +31,7 @@ use crate::{ ...@@ -31,7 +31,7 @@ use crate::{
}; };
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait EcmascriptChunkPlaceable: ChunkableModule + Module { pub trait EcmascriptChunkPlaceable: Module {
#[turbo_tasks::function] #[turbo_tasks::function]
fn get_exports(self: Vc<Self>) -> Vc<EcmascriptExports>; fn get_exports(self: Vc<Self>) -> Vc<EcmascriptExports>;
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -52,9 +52,9 @@ pub trait EcmascriptChunkPlaceable: ChunkableModule + Module { ...@@ -52,9 +52,9 @@ pub trait EcmascriptChunkPlaceable: ChunkableModule + Module {
_estimated: bool, _estimated: bool,
) -> Vc<EcmascriptChunkItemContent>; ) -> Vc<EcmascriptChunkItemContent>;
/// Returns the content identity for cache invalidation. /// A [AssetIdent] that uniquely identifies the content of this module's chunk item.
/// Override this for modules whose content depends on more than just the module source /// It is usually identical to the module's ident but can be different when the chunk item
/// (e.g., async loaders that depend on available modules). /// content depends on available modules e.g. for chunk loaders.
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunk_item_content_ident( fn chunk_item_content_ident(
self: Vc<Self>, self: Vc<Self>,
...@@ -64,15 +64,16 @@ pub trait EcmascriptChunkPlaceable: ChunkableModule + Module { ...@@ -64,15 +64,16 @@ pub trait EcmascriptChunkPlaceable: ChunkableModule + Module {
self.ident() self.ident()
} }
/// Returns output assets that this chunk item depends on. /// Returns the output assets associated with this module's chunk item.
/// Override this for modules that reference static assets, manifests, etc. /// Most modules have no output assets; override for modules that produce
/// additional output (e.g. chunk loaders, external modules, static assets).
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunk_item_output_assets( 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> { ) -> Vc<OutputAssetsWithReferenced> {
OutputAssetsWithReferenced::from_assets(OutputAssets::empty()) OutputAssetsWithReferenced::from_assets(*OutputAssets::empty_resolved())
} }
} }
......
...@@ -83,7 +83,7 @@ use turbo_tasks::{ ...@@ -83,7 +83,7 @@ use turbo_tasks::{
use turbo_tasks_fs::{FileJsonContent, FileSystemPath, glob::Glob, rope::Rope}; use turbo_tasks_fs::{FileJsonContent, FileSystemPath, glob::Glob, rope::Rope};
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{
AsyncModuleInfo, ChunkableModule, ChunkingContext, EvaluatableAsset, MergeableModule, AsyncModuleInfo, ChunkingContext, EvaluatableAsset, MergeableModule,
MergeableModuleExposure, MergeableModules, MergeableModulesExposed, MinifyType, MergeableModuleExposure, MergeableModules, MergeableModulesExposed, MinifyType,
ModuleChunkItemIdExt, ModuleId, ModuleChunkItemIdExt, ModuleId,
}, },
...@@ -95,7 +95,7 @@ use turbopack_core::{ ...@@ -95,7 +95,7 @@ use turbopack_core::{
reference::ModuleReferences, reference::ModuleReferences,
reference_type::InnerAssets, reference_type::InnerAssets,
resolve::{ resolve::{
FindContextFileResult, ModulePart, find_context_file, origin::ResolveOrigin, package_json, FindContextFileResult, find_context_file, origin::ResolveOrigin, package_json,
parse::Request, parse::Request,
}, },
source::Source, source::Source,
...@@ -118,7 +118,8 @@ use crate::{ ...@@ -118,7 +118,8 @@ use crate::{
esm::{UrlRewriteBehavior, base::EsmAssetReferences, export}, esm::{UrlRewriteBehavior, base::EsmAssetReferences, export},
}, },
side_effect_optimization::{ side_effect_optimization::{
facade::module::EcmascriptModuleFacadeModule, locals::module::EcmascriptModuleLocalsModule, facade::module::EcmascriptModuleFacadeModule,
locals::module::EcmascriptModuleLocalsModule,
reference::EcmascriptModulePartReference, reference::EcmascriptModulePartReference,
}, },
swc_comments::{CowComments, ImmutableComments}, swc_comments::{CowComments, ImmutableComments},
...@@ -698,6 +699,42 @@ impl EcmascriptModuleAsset { ...@@ -698,6 +699,42 @@ impl EcmascriptModuleAsset {
pub fn options(&self) -> Vc<EcmascriptOptions> { pub fn options(&self) -> Vc<EcmascriptOptions> {
*self.options *self.options
} }
/// Returns the locals module if the module should be split (has re-exports), otherwise self.
///
/// The locals module only contains the local bindings of the original module,
/// excluding any re-exports.
#[turbo_tasks::function]
pub async fn get_locals_if_split(
self: Vc<Self>,
) -> Result<Vc<Box<dyn EcmascriptChunkPlaceable>>> {
let should_split = *self.get_exports().split_locals_and_reexports().await?;
Ok(if should_split {
Vc::upcast(EcmascriptModuleLocalsModule::new(self))
} else {
Vc::upcast(self)
})
}
/// Returns the facade module if the module should be split (has re-exports), otherwise self.
///
/// The facade module re-exports all exports from the original module, including
/// both local bindings (via the locals module) and re-exports from other modules.
#[turbo_tasks::function]
pub async fn get_facade_if_split(
self: Vc<Self>,
) -> Result<Vc<Box<dyn EcmascriptChunkPlaceable>>> {
use turbopack_core::resolve::ModulePart;
let should_split = *self.get_exports().split_locals_and_reexports().await?;
Ok(if should_split {
Vc::upcast(EcmascriptModuleFacadeModule::new(
Vc::upcast(self),
ModulePart::Facade,
))
} else {
Vc::upcast(self)
})
}
} }
impl EcmascriptModuleAsset { impl EcmascriptModuleAsset {
...@@ -783,8 +820,6 @@ impl Module for EcmascriptModuleAsset { ...@@ -783,8 +820,6 @@ impl Module for EcmascriptModuleAsset {
} }
} }
turbopack_core::chunk_item!(EcmascriptModuleAsset, crate::chunk::ecmascript_chunk_item);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for EcmascriptModuleAsset { impl EcmascriptChunkPlaceable for EcmascriptModuleAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -821,44 +856,6 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleAsset { ...@@ -821,44 +856,6 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleAsset {
} }
} }
#[turbo_tasks::value_impl]
impl EcmascriptModuleAsset {
/// Returns the locals module if the module should be split (has re-exports), otherwise self.
///
/// The locals module contains only the local bindings and evaluation side effects,
/// while re-exports are handled separately by the facade module.
#[turbo_tasks::function]
pub async fn get_locals_if_split(
self: Vc<Self>,
) -> Result<Vc<Box<dyn EcmascriptChunkPlaceable>>> {
let should_split = *self.get_exports().split_locals_and_reexports().await?;
Ok(if should_split {
Vc::upcast(EcmascriptModuleLocalsModule::new(self))
} else {
Vc::upcast(self)
})
}
/// Returns the facade module if the module should be split (has re-exports), otherwise self.
///
/// The facade module re-exports all exports from the original module, including
/// both local bindings (via the locals module) and re-exports from other modules.
#[turbo_tasks::function]
pub async fn get_facade_if_split(
self: Vc<Self>,
) -> Result<Vc<Box<dyn EcmascriptChunkPlaceable>>> {
let should_split = *self.get_exports().split_locals_and_reexports().await?;
Ok(if should_split {
Vc::upcast(EcmascriptModuleFacadeModule::new(
Vc::upcast(self),
ModulePart::Facade,
))
} else {
Vc::upcast(self)
})
}
}
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl MergeableModule for EcmascriptModuleAsset { impl MergeableModule for EcmascriptModuleAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -878,7 +875,7 @@ impl MergeableModule for EcmascriptModuleAsset { ...@@ -878,7 +875,7 @@ impl MergeableModule for EcmascriptModuleAsset {
self: Vc<Self>, self: Vc<Self>,
modules: Vc<MergeableModulesExposed>, modules: Vc<MergeableModulesExposed>,
entry_points: Vc<MergeableModules>, entry_points: Vc<MergeableModules>,
) -> Result<Vc<Box<dyn ChunkableModule>>> { ) -> Result<Vc<Box<dyn Module>>> {
Ok(Vc::upcast( Ok(Vc::upcast(
*MergedEcmascriptModule::new( *MergedEcmascriptModule::new(
modules, modules,
......
...@@ -4,8 +4,8 @@ use turbo_rcstr::{RcStr, rcstr}; ...@@ -4,8 +4,8 @@ use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc}; use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc};
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{
AsyncModuleInfo, ChunkData, ChunkableModule, ChunkingContext, ChunkingContextExt, AsyncModuleInfo, ChunkData, ChunkingContext, ChunkingContextExt, ChunksData,
ChunksData, availability_info::AvailabilityInfo, availability_info::AvailabilityInfo,
}, },
ident::AssetIdent, ident::AssetIdent,
module::{Module, ModuleSideEffects}, module::{Module, ModuleSideEffects},
...@@ -38,7 +38,7 @@ use crate::{ ...@@ -38,7 +38,7 @@ use crate::{
/// import appears in. /// import appears in.
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
pub struct ManifestAsyncModule { pub struct ManifestAsyncModule {
pub inner: ResolvedVc<Box<dyn ChunkableModule>>, pub inner: ResolvedVc<Box<dyn Module>>,
pub module_graph: ResolvedVc<ModuleGraph>, pub module_graph: ResolvedVc<ModuleGraph>,
pub chunking_context: ResolvedVc<Box<dyn ChunkingContext>>, pub chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
pub availability_info: AvailabilityInfo, pub availability_info: AvailabilityInfo,
...@@ -48,7 +48,7 @@ pub struct ManifestAsyncModule { ...@@ -48,7 +48,7 @@ pub struct ManifestAsyncModule {
impl ManifestAsyncModule { impl ManifestAsyncModule {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn new( pub fn new(
module: ResolvedVc<Box<dyn ChunkableModule>>, module: ResolvedVc<Box<dyn Module>>,
module_graph: ResolvedVc<ModuleGraph>, module_graph: ResolvedVc<ModuleGraph>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>, chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
...@@ -65,7 +65,7 @@ impl ManifestAsyncModule { ...@@ -65,7 +65,7 @@ impl ManifestAsyncModule {
pub(super) fn chunk_group(&self) -> Vc<OutputAssetsWithReferenced> { pub(super) fn chunk_group(&self) -> Vc<OutputAssetsWithReferenced> {
self.chunking_context.chunk_group_assets( self.chunking_context.chunk_group_assets(
self.inner.ident(), self.inner.ident(),
ChunkGroup::Async(ResolvedVc::upcast(self.inner)), ChunkGroup::Async(self.inner),
*self.module_graph, *self.module_graph,
self.availability_info, self.availability_info,
) )
...@@ -77,10 +77,10 @@ impl ManifestAsyncModule { ...@@ -77,10 +77,10 @@ impl ManifestAsyncModule {
) -> Result<Vc<OutputAssetsWithReferenced>> { ) -> Result<Vc<OutputAssetsWithReferenced>> {
let this = self.await?; let this = self.await?;
if let Some(chunk_items) = this.availability_info.available_modules() { if let Some(chunk_items) = this.availability_info.available_modules() {
let inner_module = ResolvedVc::upcast(this.inner); let inner_module = this.inner;
let batches = this let batches = this
.module_graph .module_graph
.module_batches(this.chunking_context.batching_config()) .module_batches(this.chunking_context.chunking_configs())
.await?; .await?;
let module_or_batch = batches.get_entry(inner_module).await?; let module_or_batch = batches.get_entry(inner_module).await?;
if let Some(chunkable_module_or_batch) = if let Some(chunkable_module_or_batch) =
...@@ -174,8 +174,6 @@ impl Module for ManifestAsyncModule { ...@@ -174,8 +174,6 @@ impl Module for ManifestAsyncModule {
} }
} }
turbopack_core::chunk_item!(ManifestAsyncModule, crate::chunk::ecmascript_chunk_item);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for ManifestAsyncModule { impl EcmascriptChunkPlaceable for ManifestAsyncModule {
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -5,10 +5,7 @@ use indoc::writedoc; ...@@ -5,10 +5,7 @@ use indoc::writedoc;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc}; use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc};
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{AsyncModuleInfo, ChunkData, ChunkingContext, ChunksData, ModuleChunkItemIdExt},
AsyncModuleInfo, ChunkData, ChunkableModule, ChunkingContext, ChunksData,
ModuleChunkItemIdExt,
},
ident::AssetIdent, ident::AssetIdent,
module::{Module, ModuleSideEffects}, module::{Module, ModuleSideEffects},
module_graph::ModuleGraph, module_graph::ModuleGraph,
...@@ -68,7 +65,7 @@ impl ManifestLoaderModule { ...@@ -68,7 +65,7 @@ impl ManifestLoaderModule {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn asset_ident_for(module: Vc<Box<dyn ChunkableModule>>) -> Vc<AssetIdent> { pub fn asset_ident_for(module: Vc<Box<dyn Module>>) -> Vc<AssetIdent> {
module.ident().with_modifier(modifier()) module.ident().with_modifier(modifier())
} }
} }
...@@ -96,8 +93,6 @@ impl Module for ManifestLoaderModule { ...@@ -96,8 +93,6 @@ impl Module for ManifestLoaderModule {
} }
} }
turbopack_core::chunk_item!(ManifestLoaderModule, crate::chunk::ecmascript_chunk_item);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for ManifestLoaderModule { impl EcmascriptChunkPlaceable for ManifestLoaderModule {
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -184,7 +179,7 @@ impl EcmascriptChunkPlaceable for ManifestLoaderModule { ...@@ -184,7 +179,7 @@ impl EcmascriptChunkPlaceable for ManifestLoaderModule {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunk_item_output_assets( async fn chunk_item_output_assets(
&self, &self,
_chunking_context: Vc<Box<dyn ChunkingContext>>, _chunking_context: Vc<Box<dyn ChunkingContext>>,
_module_graph: Vc<ModuleGraph>, _module_graph: Vc<ModuleGraph>,
......
...@@ -88,8 +88,6 @@ impl Module for MergedEcmascriptModule { ...@@ -88,8 +88,6 @@ impl Module for MergedEcmascriptModule {
} }
} }
turbopack_core::chunk_item!(MergedEcmascriptModule, crate::chunk::ecmascript_chunk_item);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for MergedEcmascriptModule { impl EcmascriptChunkPlaceable for MergedEcmascriptModule {
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -367,8 +367,6 @@ impl Module for CachedExternalModule { ...@@ -367,8 +367,6 @@ impl Module for CachedExternalModule {
} }
} }
turbopack_core::chunk_item!(CachedExternalModule, crate::chunk::ecmascript_chunk_item);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for CachedExternalModule { impl EcmascriptChunkPlaceable for CachedExternalModule {
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -12,11 +12,11 @@ use swc_core::{ ...@@ -12,11 +12,11 @@ use swc_core::{
}; };
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ use turbo_tasks::{
FxIndexMap, NonLocalValue, ResolvedVc, TaskInput, TryJoinIterExt, Vc, debug::ValueDebugFormat, FxIndexMap, NonLocalValue, TaskInput, TryJoinIterExt, Vc, debug::ValueDebugFormat,
trace::TraceRawVcs, trace::TraceRawVcs,
}; };
use turbopack_core::{ use turbopack_core::{
chunk::{ChunkableModule, ChunkingContext, ModuleChunkItemIdExt, ModuleId}, chunk::{ChunkingContext, ModuleChunkItemIdExt, ModuleId},
issue::{ issue::{
Issue, IssueExt, IssueSeverity, StyledString, code_gen::CodeGenerationIssue, Issue, IssueExt, IssueSeverity, StyledString, code_gen::CodeGenerationIssue,
module::emit_unknown_module_type_error, module::emit_unknown_module_type_error,
...@@ -355,10 +355,16 @@ async fn to_single_pattern_mapping( ...@@ -355,10 +355,16 @@ async fn to_single_pattern_mapping(
return Ok(SinglePatternMapping::Invalid); return Ok(SinglePatternMapping::Invalid);
} }
}; };
if let Some(chunkable) = ResolvedVc::try_downcast::<Box<dyn ChunkableModule>>(module) { if chunking_context
.chunking_configs()
.await?
.chunk_type(module)
.await
.is_some()
{
match resolve_type { match resolve_type {
ResolveType::AsyncChunkLoader => { ResolveType::AsyncChunkLoader => {
let ident = chunking_context.async_loader_chunk_item_ident(*chunkable); let ident = chunking_context.async_loader_chunk_item_ident(*module);
let loader_id = chunking_context let loader_id = chunking_context
.chunk_item_id_strategy() .chunk_item_id_strategy()
.await? .await?
...@@ -367,16 +373,16 @@ async fn to_single_pattern_mapping( ...@@ -367,16 +373,16 @@ async fn to_single_pattern_mapping(
return Ok(SinglePatternMapping::ModuleLoader(loader_id)); return Ok(SinglePatternMapping::ModuleLoader(loader_id));
} }
ResolveType::ChunkItem => { ResolveType::ChunkItem => {
let item_id = chunkable.chunk_item_id(chunking_context).await?; let item_id = module.chunk_item_id(chunking_context).await?;
return Ok(SinglePatternMapping::Module(item_id)); return Ok(SinglePatternMapping::Module(item_id));
} }
} }
} }
CodeGenerationIssue { CodeGenerationIssue {
severity: IssueSeverity::Bug, severity: IssueSeverity::Bug,
title: StyledString::Text(rcstr!("non-ecmascript placeable asset")).resolved_cell(), title: StyledString::Text(rcstr!("non-chunkable asset")).resolved_cell(),
message: StyledString::Text(rcstr!( message: StyledString::Text(rcstr!(
"asset is not placeable in ESM chunks, so it doesn't have a module id" "asset is not chunkable, so it doesn't have a module id"
)) ))
.resolved_cell(), .resolved_cell(),
path: origin.origin_path().owned().await?, path: origin.origin_path().owned().await?,
......
...@@ -435,8 +435,6 @@ impl Module for RequireContextAsset { ...@@ -435,8 +435,6 @@ impl Module for RequireContextAsset {
} }
} }
turbopack_core::chunk_item!(RequireContextAsset, crate::chunk::ecmascript_chunk_item);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for RequireContextAsset { impl EcmascriptChunkPlaceable for RequireContextAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -11,7 +11,7 @@ use turbo_tasks::{ ...@@ -11,7 +11,7 @@ use turbo_tasks::{
}; };
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbopack_core::{ use turbopack_core::{
chunk::{ChunkableModule, ChunkingContext, ChunkingType, ChunkingTypeOption, EvaluatableAsset}, chunk::{ChunkingContext, ChunkingType, ChunkingTypeOption, EvaluatableAsset},
context::AssetContext, context::AssetContext,
issue::{IssueExt, IssueSeverity, IssueSource, StyledString, code_gen::CodeGenerationIssue}, issue::{IssueExt, IssueSeverity, IssueSource, StyledString, code_gen::CodeGenerationIssue},
module::Module, module::Module,
...@@ -25,6 +25,7 @@ use turbopack_core::{ ...@@ -25,6 +25,7 @@ use turbopack_core::{
}; };
use crate::{ use crate::{
chunk::EcmascriptChunkPlaceable,
code_gen::{CodeGen, CodeGeneration, IntoCodeGenReference}, code_gen::{CodeGen, CodeGeneration, IntoCodeGenReference},
create_visitor, create_visitor,
references::{ references::{
...@@ -179,9 +180,9 @@ impl ModuleReference for WorkerAssetReference { ...@@ -179,9 +180,9 @@ impl ModuleReference for WorkerAssetReference {
ModuleResolveResultItem::Module(module) => { ModuleResolveResultItem::Module(module) => {
let module_ident = module.ident().to_string().await?; let module_ident = module.ident().to_string().await?;
let Some(chunkable) = if ResolvedVc::try_sidecast::<Box<dyn EcmascriptChunkPlaceable>>(*module)
ResolvedVc::try_downcast::<Box<dyn ChunkableModule>>(*module) .is_none()
else { {
CodeGenerationIssue { CodeGenerationIssue {
severity: self.get_module_type_issue_severity().await?, severity: self.get_module_type_issue_severity().await?,
title: StyledString::Text(rcstr!("non-chunkable module")) title: StyledString::Text(rcstr!("non-chunkable module"))
...@@ -202,13 +203,12 @@ impl ModuleReference for WorkerAssetReference { ...@@ -202,13 +203,12 @@ impl ModuleReference for WorkerAssetReference {
.resolved_cell() .resolved_cell()
.emit(); .emit();
continue; continue;
}; }
// For Node.js worker threads, the module must also be evaluatable since // For Node.js worker threads, the module must also be evaluatable since
// it becomes an entry point // it becomes an entry point
if matches!(self.worker_type, WorkerType::NodeWorkerThread) if matches!(self.worker_type, WorkerType::NodeWorkerThread)
&& ResolvedVc::try_sidecast::<Box<dyn EvaluatableAsset>>(chunkable) && ResolvedVc::try_sidecast::<Box<dyn EvaluatableAsset>>(*module).is_none()
.is_none()
{ {
CodeGenerationIssue { CodeGenerationIssue {
severity: self.get_module_type_issue_severity().await?, severity: self.get_module_type_issue_severity().await?,
...@@ -234,7 +234,7 @@ impl ModuleReference for WorkerAssetReference { ...@@ -234,7 +234,7 @@ impl ModuleReference for WorkerAssetReference {
} }
let loader = let loader =
WorkerLoaderModule::new(*chunkable, self.worker_type, *asset_context) WorkerLoaderModule::new(**module, self.worker_type, *asset_context)
.to_resolved() .to_resolved()
.await?; .await?;
......
...@@ -4,8 +4,8 @@ use anyhow::{Result, bail}; ...@@ -4,8 +4,8 @@ use anyhow::{Result, bail};
use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{
AsyncModuleInfo, ChunkableModule, ChunkingContext, EvaluatableAsset, MergeableModule, AsyncModuleInfo, ChunkingContext, EvaluatableAsset, MergeableModule, MergeableModules,
MergeableModules, MergeableModulesExposed, MergeableModulesExposed,
}, },
ident::AssetIdent, ident::AssetIdent,
module::{Module, ModuleSideEffects}, module::{Module, ModuleSideEffects},
...@@ -364,11 +364,6 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule { ...@@ -364,11 +364,6 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
} }
} }
turbopack_core::chunk_item!(
EcmascriptModuleFacadeModule,
crate::chunk::ecmascript_chunk_item
);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EvaluatableAsset for EcmascriptModuleFacadeModule {} impl EvaluatableAsset for EcmascriptModuleFacadeModule {}
...@@ -379,7 +374,7 @@ impl MergeableModule for EcmascriptModuleFacadeModule { ...@@ -379,7 +374,7 @@ impl MergeableModule for EcmascriptModuleFacadeModule {
self: Vc<Self>, self: Vc<Self>,
modules: Vc<MergeableModulesExposed>, modules: Vc<MergeableModulesExposed>,
entry_points: Vc<MergeableModules>, entry_points: Vc<MergeableModules>,
) -> Result<Vc<Box<dyn ChunkableModule>>> { ) -> Result<Vc<Box<dyn Module>>> {
Ok(Vc::upcast( Ok(Vc::upcast(
*MergedEcmascriptModule::new( *MergedEcmascriptModule::new(
modules, modules,
......
...@@ -4,7 +4,7 @@ use anyhow::{Result, bail}; ...@@ -4,7 +4,7 @@ use anyhow::{Result, bail};
use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{
AsyncModuleInfo, ChunkableModule, ChunkingContext, MergeableModule, MergeableModules, AsyncModuleInfo, ChunkingContext, MergeableModule, MergeableModules,
MergeableModulesExposed, MergeableModulesExposed,
}, },
ident::AssetIdent, ident::AssetIdent,
...@@ -190,11 +190,6 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleLocalsModule { ...@@ -190,11 +190,6 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleLocalsModule {
} }
} }
turbopack_core::chunk_item!(
EcmascriptModuleLocalsModule,
crate::chunk::ecmascript_chunk_item
);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl MergeableModule for EcmascriptModuleLocalsModule { impl MergeableModule for EcmascriptModuleLocalsModule {
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -202,7 +197,7 @@ impl MergeableModule for EcmascriptModuleLocalsModule { ...@@ -202,7 +197,7 @@ impl MergeableModule for EcmascriptModuleLocalsModule {
&self, &self,
modules: Vc<MergeableModulesExposed>, modules: Vc<MergeableModulesExposed>,
entry_points: Vc<MergeableModules>, entry_points: Vc<MergeableModules>,
) -> Result<Vc<Box<dyn ChunkableModule>>> { ) -> Result<Vc<Box<dyn Module>>> {
Ok(Vc::upcast( Ok(Vc::upcast(
*MergedEcmascriptModule::new(modules, entry_points, self.module.await?.options).await?, *MergedEcmascriptModule::new(modules, entry_points, self.module.await?.options).await?,
)) ))
......
...@@ -369,11 +369,6 @@ impl EcmascriptChunkPlaceable for EcmascriptModulePartAsset { ...@@ -369,11 +369,6 @@ impl EcmascriptChunkPlaceable for EcmascriptModulePartAsset {
} }
} }
turbopack_core::chunk_item!(
EcmascriptModulePartAsset,
crate::chunk::ecmascript_chunk_item
);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptModulePartAsset { impl EcmascriptModulePartAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -202,7 +202,5 @@ impl EcmascriptChunkPlaceable for SideEffectsModule { ...@@ -202,7 +202,5 @@ impl EcmascriptChunkPlaceable for SideEffectsModule {
} }
} }
turbopack_core::chunk_item!(SideEffectsModule, crate::chunk::ecmascript_chunk_item);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EvaluatableAsset for SideEffectsModule {} impl EvaluatableAsset for SideEffectsModule {}
...@@ -4,9 +4,9 @@ use turbo_rcstr::rcstr; ...@@ -4,9 +4,9 @@ use turbo_rcstr::rcstr;
use turbo_tasks::{ResolvedVc, TryJoinIterExt, ValueToString, Vc}; use turbo_tasks::{ResolvedVc, TryJoinIterExt, ValueToString, Vc};
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{
AsyncModuleInfo, ChunkData, ChunkGroupType, ChunkableModule, ChunkingContext, AsyncModuleInfo, ChunkData, ChunkGroupType, ChunkingContext, ChunkingContextExt,
ChunkingContextExt, ChunkingType, ChunkingTypeOption, ChunksData, EvaluatableAsset, ChunkingType, ChunkingTypeOption, ChunksData, EvaluatableAsset, EvaluatableAssets,
EvaluatableAssets, availability_info::AvailabilityInfo, availability_info::AvailabilityInfo,
}, },
context::AssetContext, context::AssetContext,
ident::AssetIdent, ident::AssetIdent,
...@@ -32,7 +32,7 @@ use crate::{ ...@@ -32,7 +32,7 @@ use crate::{
/// constructor. /// constructor.
#[turbo_tasks::value] #[turbo_tasks::value]
pub struct WorkerLoaderModule { pub struct WorkerLoaderModule {
pub inner: ResolvedVc<Box<dyn ChunkableModule>>, pub inner: ResolvedVc<Box<dyn Module>>,
pub worker_type: WorkerType, pub worker_type: WorkerType,
pub asset_context: ResolvedVc<Box<dyn AssetContext>>, pub asset_context: ResolvedVc<Box<dyn AssetContext>>,
} }
...@@ -41,7 +41,7 @@ pub struct WorkerLoaderModule { ...@@ -41,7 +41,7 @@ pub struct WorkerLoaderModule {
impl WorkerLoaderModule { impl WorkerLoaderModule {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn new( pub fn new(
module: ResolvedVc<Box<dyn ChunkableModule>>, module: ResolvedVc<Box<dyn Module>>,
worker_type: WorkerType, worker_type: WorkerType,
asset_context: ResolvedVc<Box<dyn AssetContext>>, asset_context: ResolvedVc<Box<dyn AssetContext>>,
) -> Vc<Self> { ) -> Vc<Self> {
...@@ -65,7 +65,7 @@ impl WorkerLoaderModule { ...@@ -65,7 +65,7 @@ impl WorkerLoaderModule {
this.inner this.inner
.ident() .ident()
.with_modifier(this.worker_type.chunk_modifier_str()), .with_modifier(this.worker_type.chunk_modifier_str()),
ChunkGroup::Isolated(ResolvedVc::upcast(this.inner)), ChunkGroup::Isolated(this.inner),
module_graph, module_graph,
AvailabilityInfo::root(), AvailabilityInfo::root(),
), ),
...@@ -161,7 +161,7 @@ impl Module for WorkerLoaderModule { ...@@ -161,7 +161,7 @@ impl Module for WorkerLoaderModule {
async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> { async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> {
let this = self.await?; let this = self.await?;
Ok(Vc::cell(vec![ResolvedVc::upcast( Ok(Vc::cell(vec![ResolvedVc::upcast(
WorkerModuleReference::new(*ResolvedVc::upcast(this.inner), this.worker_type) WorkerModuleReference::new(*this.inner, this.worker_type)
.to_resolved() .to_resolved()
.await?, .await?,
)])) )]))
...@@ -173,8 +173,6 @@ impl Module for WorkerLoaderModule { ...@@ -173,8 +173,6 @@ impl Module for WorkerLoaderModule {
} }
} }
turbopack_core::chunk_item!(WorkerLoaderModule, crate::chunk::ecmascript_chunk_item);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for WorkerLoaderModule { impl EcmascriptChunkPlaceable for WorkerLoaderModule {
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -34,6 +34,7 @@ turbo-tasks = { workspace = true } ...@@ -34,6 +34,7 @@ turbo-tasks = { workspace = true }
turbo-tasks-fs = { workspace = true } turbo-tasks-fs = { workspace = true }
turbo-tasks-hash = { workspace = true } turbo-tasks-hash = { workspace = true }
turbopack-core = { workspace = true } turbopack-core = { workspace = true }
turbopack-css = { workspace = true }
turbopack-ecmascript = { workspace = true } turbopack-ecmascript = { workspace = true }
turbopack-ecmascript-runtime = { workspace = true } turbopack-ecmascript-runtime = { workspace = true }
...@@ -6,10 +6,9 @@ use turbo_tasks_fs::FileSystemPath; ...@@ -6,10 +6,9 @@ use turbo_tasks_fs::FileSystemPath;
use turbopack_core::{ use turbopack_core::{
asset::Asset, asset::Asset,
chunk::{ chunk::{
AssetSuffix, Chunk, ChunkGroupResult, ChunkItem, ChunkType, ChunkableModule, AssetSuffix, Chunk, ChunkGroupResult, ChunkItem, ChunkType, ChunkingConfig,
ChunkingConfig, ChunkingConfigs, ChunkingContext, ChunkingContextExt, ChunkingConfigs, ChunkingContext, EntryChunkGroupResult, EvaluatableAssets, MinifyType,
EntryChunkGroupResult, EvaluatableAssets, MinifyType, SourceMapSourceType, SourceMapsType, SourceMapSourceType, SourceMapsType, UnusedReferences, UrlBehavior,
UnusedReferences, UrlBehavior,
availability_info::AvailabilityInfo, availability_info::AvailabilityInfo,
chunk_group::{MakeChunkGroupResult, make_chunk_group}, chunk_group::{MakeChunkGroupResult, make_chunk_group},
chunk_id_strategy::ModuleIdStrategy, chunk_id_strategy::ModuleIdStrategy,
...@@ -24,9 +23,10 @@ use turbopack_core::{ ...@@ -24,9 +23,10 @@ use turbopack_core::{
}, },
output::{OutputAsset, OutputAssets}, output::{OutputAsset, OutputAssets},
}; };
use turbopack_css::chunk::CssChunkType;
use turbopack_ecmascript::{ use turbopack_ecmascript::{
async_chunk::module::AsyncLoaderModule, async_chunk::module::AsyncLoaderModule,
chunk::EcmascriptChunk, chunk::{EcmascriptChunk, EcmascriptChunkType},
manifest::{chunk_asset::ManifestAsyncModule, loader_module::ManifestLoaderModule}, manifest::{chunk_asset::ManifestAsyncModule, loader_module::ManifestLoaderModule},
}; };
use turbopack_ecmascript_runtime::RuntimeType; use turbopack_ecmascript_runtime::RuntimeType;
...@@ -448,8 +448,19 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -448,8 +448,19 @@ impl ChunkingContext for NodeJsChunkingContext {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_configs(&self) -> Result<Vc<ChunkingConfigs>> { async fn chunking_configs(&self) -> Result<Vc<ChunkingConfigs>> {
Ok(Vc::cell(self.chunking_configs.iter().cloned().collect())) let mut configs = self.chunking_configs.clone();
let ecma_type: ResolvedVc<Box<dyn ChunkType>> =
ResolvedVc::upcast(Vc::<EcmascriptChunkType>::default().to_resolved().await?);
if !configs.iter().any(|(ty, _)| *ty == ecma_type) {
configs.push((ecma_type, ChunkingConfig::default()));
}
let css_type: ResolvedVc<Box<dyn ChunkType>> =
ResolvedVc::upcast(Vc::<CssChunkType>::default().to_resolved().await?);
if !configs.iter().any(|(ty, _)| *ty == css_type) {
configs.push((css_type, ChunkingConfig::default()));
}
Ok(ChunkingConfigs::new(configs))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -636,7 +647,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -636,7 +647,7 @@ impl ChunkingContext for NodeJsChunkingContext {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn async_loader_chunk_item( async fn async_loader_chunk_item(
self: Vc<Self>, self: Vc<Self>,
module: Vc<Box<dyn ChunkableModule>>, module: Vc<Box<dyn Module>>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Result<Vc<ChunkItem>> { ) -> Result<Vc<ChunkItem>> {
...@@ -654,17 +665,17 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -654,17 +665,17 @@ impl ChunkingContext for NodeJsChunkingContext {
.to_resolved() .to_resolved()
.await?; .await?;
let loader_module = ManifestLoaderModule::new(*manifest_asset); let loader_module = ManifestLoaderModule::new(*manifest_asset);
chunking_context.chunk_item(Vc::upcast(loader_module), module_graph) ChunkItem::new(Vc::upcast(loader_module), module_graph, *chunking_context)
} else { } else {
let module = AsyncLoaderModule::new(module, *chunking_context, availability_info); let module = AsyncLoaderModule::new(module, *chunking_context, availability_info);
chunking_context.chunk_item(Vc::upcast(module), module_graph) ChunkItem::new(Vc::upcast(module), module_graph, *chunking_context)
}) })
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn async_loader_chunk_item_ident( async fn async_loader_chunk_item_ident(
self: Vc<Self>, self: Vc<Self>,
module: Vc<Box<dyn ChunkableModule>>, module: Vc<Box<dyn Module>>,
) -> Result<Vc<AssetIdent>> { ) -> Result<Vc<AssetIdent>> {
Ok(if self.await?.manifest_chunks { Ok(if self.await?.manifest_chunks {
ManifestLoaderModule::asset_ident_for(module) ManifestLoaderModule::asset_ident_for(module)
......
...@@ -65,8 +65,6 @@ impl Module for StaticUrlJsModule { ...@@ -65,8 +65,6 @@ impl Module for StaticUrlJsModule {
} }
} }
turbopack_core::chunk_item!(StaticUrlJsModule, ecmascript);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for StaticUrlJsModule { impl EcmascriptChunkPlaceable for StaticUrlJsModule {
#[turbo_tasks::function] #[turbo_tasks::function]
......
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([ (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ad3e4_tests_snapshot_basic-tree-shake_dynamic-import_input_index_7dac1ace.js", "output/ad3e4_tests_snapshot_basic-tree-shake_dynamic-import_input_index_d8d543b1.js",
{"otherChunks":["output/bf321_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_ee638b2a.js","output/bf321_tests_snapshot_basic-tree-shake_dynamic-import_input_index_9775ceed.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/index.js [test] (ecmascript)"]} {"otherChunks":["output/bf321_tests_snapshot_basic-tree-shake_dynamic-import_input_index_9775ceed.js","output/bf321_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_ee638b2a.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/index.js [test] (ecmascript)"]}
]); ]);
// Dummy runtime // Dummy runtime
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
__turbopack_context__.v((parentImport) => { __turbopack_context__.v((parentImport) => {
return Promise.all([ return Promise.all([
"output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_c52390c2._.js" "output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_0b8573ac._.js"
].map((chunk) => __turbopack_context__.l(chunk))).then(() => { ].map((chunk) => __turbopack_context__.l(chunk))).then(() => {
return parentImport("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/import.js [test] (ecmascript)"); return parentImport("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/import.js [test] (ecmascript)");
}); });
......
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_df8dd76f._.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/aaf3a_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_index_ea8e1245.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/shared.js [test] (ecmascript)", ((__turbopack_context__, module, exports) => {
// shared package
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/index.js [test] (ecmascript)", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -16,17 +12,6 @@ __turbopack_context__.A("[project]/turbopack/crates/turbopack-tests/tests/snapsh ...@@ -16,17 +12,6 @@ __turbopack_context__.A("[project]/turbopack/crates/turbopack-tests/tests/snapsh
foo(true); foo(true);
}); });
}), }),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/node_modules/bar/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"bar",
()=>bar
]);
function bar(value) {
console.assert(value);
}
}),
]); ]);
//# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_df8dd76f._.js.map //# sourceMappingURL=aaf3a_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_index_ea8e1245.js.map
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,5 @@ ...@@ -2,7 +2,5 @@
"version": 3, "version": 3,
"sources": [], "sources": [],
"sections": [ "sections": [
{"offset": {"line": 3, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/shared.js"],"sourcesContent":["// shared package\n"],"names":[],"mappings":"AAAA,iBAAiB"}}, {"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/index.js"],"sourcesContent":["import { bar } from 'bar'\nimport './shared'\n\nbar(true)\n\nimport('./import').then(({ foo }) => {\n foo(true)\n})\n"],"names":["then","foo"],"mappings":";AAAA;AACA;;;AAEA,IAAA,gOAAG,EAAC;AAEJ,yJAAmBA,IAAI,CAAC,CAAC,EAAEC,GAAG,EAAE;IAC9BA,IAAI;AACN"}}]
{"offset": {"line": 8, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/index.js"],"sourcesContent":["import { bar } from 'bar'\nimport './shared'\n\nbar(true)\n\nimport('./import').then(({ foo }) => {\n foo(true)\n})\n"],"names":["then","foo"],"mappings":";AAAA;AACA;;;AAEA,IAAA,gOAAG,EAAC;AAEJ,yJAAmBA,IAAI,CAAC,CAAC,EAAEC,GAAG,EAAE;IAC9BA,IAAI;AACN"}},
{"offset": {"line": 21, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/node_modules/bar/index.js"],"sourcesContent":["export function bar(value) {\n console.assert(value);\n}\n"],"names":["bar","value","console","assert"],"mappings":";;;;AAAO,SAASA,IAAIC,KAAK;IACvBC,QAAQC,MAAM,CAACF;AACjB","ignoreList":[0]}}]
} }
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ba425_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_index_7b89cd79.js",
{"otherChunks":["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_dab22947._.js","output/aaf3a_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_index_ea8e1245.js","output/aaf3a_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_import_c0ebb290.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ba425_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_index_da1eef81.js",
{"otherChunks":["output/aaf3a_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_import_c0ebb290.js","output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_df8dd76f._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_c52390c2._.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_0b8573ac._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/node_modules/foo/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"foo",
()=>foo
]);
function foo(value) {
console.assert(value);
}
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/import.js [test] (ecmascript)", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/import.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -12,17 +23,6 @@ var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbo ...@@ -12,17 +23,6 @@ var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbo
(0, __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$async_chunk$2f$input$2f$node_modules$2f$foo$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__["foo"])(true); (0, __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$async_chunk$2f$input$2f$node_modules$2f$foo$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__["foo"])(true);
(0, __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$async_chunk$2f$input$2f$node_modules$2f$bar$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__["bar"])(true); (0, __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$async_chunk$2f$input$2f$node_modules$2f$bar$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__["bar"])(true);
}), }),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/node_modules/foo/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"foo",
()=>foo
]);
function foo(value) {
console.assert(value);
}
}),
]); ]);
//# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_c52390c2._.js.map //# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_0b8573ac._.js.map
\ No newline at end of file \ No newline at end of file
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
"version": 3, "version": 3,
"sources": [], "sources": [],
"sections": [ "sections": [
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/node/spawn_node_eval/input/index.js"],"sourcesContent":["import { spawn } from 'child_process'\n\nlet x = spawn(process.argv[0], ['-e', \"console.log('foo');\"])\n"],"names":["x","process","argv"],"mappings":";AAAA;;AAEA,IAAIA,IAAI,IAAA,+OAAK,EAACC,QAAQC,IAAI,CAAC,EAAE,EAAE;IAAC;IAAM;CAAsB"}}, {"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/node_modules/foo/index.js"],"sourcesContent":["export function foo(value) {\n console.assert(value);\n}\n"],"names":["foo","value","console","assert"],"mappings":";;;;AAAO,SAASA,IAAIC,KAAK;IACvBC,QAAQC,MAAM,CAACF;AACjB","ignoreList":[0]}},
{"offset": {"line": 15, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/node/spawn_node_eval/input/node_modules/child_process/index.js"],"sourcesContent":["export function spawn(cmd, args) {\n //\n}\n"],"names":["spawn","cmd","args"],"mappings":";;;;AAAO,SAASA,MAAMC,GAAG,EAAEC,IAAI;AAC7B,EAAE;AACJ","ignoreList":[0]}}] {"offset": {"line": 15, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/import.js"],"sourcesContent":["import { foo } from 'foo'\nimport { bar } from 'bar'\nimport './shared'\n\nfoo(true)\nbar(true)\n"],"names":[],"mappings":";AAAA;AACA;AACA;;;;AAEA,IAAA,gOAAG,EAAC;AACJ,IAAA,gOAAG,EAAC"}}]
} }
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/import.js"],"sourcesContent":["import { foo } from 'foo'\nimport { bar } from 'bar'\nimport './shared'\n\nfoo(true)\nbar(true)\n"],"names":[],"mappings":";AAAA;AACA;AACA;;;;AAEA,IAAA,gOAAG,EAAC;AACJ,IAAA,gOAAG,EAAC"}},
{"offset": {"line": 17, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/node_modules/foo/index.js"],"sourcesContent":["export function foo(value) {\n console.assert(value);\n}\n"],"names":["foo","value","console","assert"],"mappings":";;;;AAAO,SAASA,IAAIC,KAAK;IACvBC,QAAQC,MAAM,CAACF;AACjB","ignoreList":[0]}}]
}
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_dab22947._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/node_modules/bar/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"bar",
()=>bar
]);
function bar(value) {
console.assert(value);
}
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/shared.js [test] (ecmascript)", ((__turbopack_context__, module, exports) => {
// shared package
}),
]);
//# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_dab22947._.js.map
\ No newline at end of file
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
"version": 3, "version": 3,
"sources": [], "sources": [],
"sections": [ "sections": [
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunked/input/index.js"],"sourcesContent":["import { foo } from 'foo'\n\nfoo(true)\n"],"names":[],"mappings":";AAAA;;AAEA,IAAA,4NAAG,EAAC"}}, {"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/node_modules/bar/index.js"],"sourcesContent":["export function bar(value) {\n console.assert(value);\n}\n"],"names":["bar","value","console","assert"],"mappings":";;;;AAAO,SAASA,IAAIC,KAAK;IACvBC,QAAQC,MAAM,CAACF;AACjB","ignoreList":[0]}},
{"offset": {"line": 12, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunked/input/node_modules/foo/index.js"],"sourcesContent":["export function foo(value) {\n console.assert(value);\n}\n"],"names":["foo","value","console","assert"],"mappings":";;;;AAAO,SAASA,IAAIC,KAAK;IACvBC,QAAQC,MAAM,CAACF;AACjB","ignoreList":[0]}}] {"offset": {"line": 14, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/shared.js"],"sourcesContent":["// shared package\n"],"names":[],"mappings":"AAAA,iBAAiB"}}]
} }
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([ (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ba425_crates_turbopack-tests_tests_snapshot_basic_chunked_input_index_3d2893fd.js", "output/ba425_crates_turbopack-tests_tests_snapshot_basic_chunked_input_index_a86bc380.js",
{"otherChunks":["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_chunked_input_f80bf1f2._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunked/input/index.js [test] (ecmascript)"]} {"otherChunks":["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_chunked_input_cb37d43c._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunked/input/index.js [test] (ecmascript)"]}
]); ]);
// Dummy runtime // Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_chunked_input_f80bf1f2._.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_chunked_input_cb37d43c._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunked/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([]);
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$chunked$2f$input$2f$node_modules$2f$foo$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunked/input/node_modules/foo/index.js [test] (ecmascript)");
;
(0, __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$chunked$2f$input$2f$node_modules$2f$foo$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__["foo"])(true);
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunked/input/node_modules/foo/index.js [test] (ecmascript)", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunked/input/node_modules/foo/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -18,6 +10,14 @@ function foo(value) { ...@@ -18,6 +10,14 @@ function foo(value) {
console.assert(value); console.assert(value);
} }
}), }),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunked/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([]);
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$chunked$2f$input$2f$node_modules$2f$foo$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunked/input/node_modules/foo/index.js [test] (ecmascript)");
;
(0, __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$chunked$2f$input$2f$node_modules$2f$foo$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__["foo"])(true);
}),
]); ]);
//# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_basic_chunked_input_f80bf1f2._.js.map //# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_basic_chunked_input_cb37d43c._.js.map
\ No newline at end of file \ No newline at end of file
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
"version": 3, "version": 3,
"sources": [], "sources": [],
"sections": [ "sections": [
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/shebang/input/index.js"],"sourcesContent":["#!/usr/bin/env node\n\nimport { foo } from 'foo'\n\nfoo(true)\n"],"names":[],"mappings":";AAEA;;AAEA,IAAA,4NAAG,EAAC"}}, {"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunked/input/node_modules/foo/index.js"],"sourcesContent":["export function foo(value) {\n console.assert(value);\n}\n"],"names":["foo","value","console","assert"],"mappings":";;;;AAAO,SAASA,IAAIC,KAAK;IACvBC,QAAQC,MAAM,CAACF;AACjB","ignoreList":[0]}},
{"offset": {"line": 12, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/shebang/input/node_modules/foo/index.js"],"sourcesContent":["#!/usr/bin/env node\n\nexport function foo(value) {\n console.assert(value);\n}\n"],"names":["foo","value","console","assert"],"mappings":";;;;AAEO,SAASA,IAAIC,KAAK;IACvBC,QAAQC,MAAM,CAACF;AACjB","ignoreList":[0]}}] {"offset": {"line": 15, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunked/input/index.js"],"sourcesContent":["import { foo } from 'foo'\n\nfoo(true)\n"],"names":[],"mappings":";AAAA;;AAEA,IAAA,4NAAG,EAAC"}}]
} }
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([ (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ba425_crates_turbopack-tests_tests_snapshot_basic_shebang_input_index_1ec6f047.js", "output/ba425_crates_turbopack-tests_tests_snapshot_basic_shebang_input_index_c7271b63.js",
{"otherChunks":["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_shebang_input_07d95226._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/shebang/input/index.js [test] (ecmascript)"]} {"otherChunks":["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_shebang_input_75c3b344._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/shebang/input/index.js [test] (ecmascript)"]}
]); ]);
// Dummy runtime // Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_shebang_input_07d95226._.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_shebang_input_75c3b344._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/shebang/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([]);
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$shebang$2f$input$2f$node_modules$2f$foo$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/shebang/input/node_modules/foo/index.js [test] (ecmascript)");
;
(0, __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$shebang$2f$input$2f$node_modules$2f$foo$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__["foo"])(true);
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/shebang/input/node_modules/foo/index.js [test] (ecmascript)", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/shebang/input/node_modules/foo/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -18,6 +10,14 @@ function foo(value) { ...@@ -18,6 +10,14 @@ function foo(value) {
console.assert(value); console.assert(value);
} }
}), }),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/shebang/input/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([]);
var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$shebang$2f$input$2f$node_modules$2f$foo$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/shebang/input/node_modules/foo/index.js [test] (ecmascript)");
;
(0, __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$shebang$2f$input$2f$node_modules$2f$foo$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__["foo"])(true);
}),
]); ]);
//# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_basic_shebang_input_07d95226._.js.map //# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_basic_shebang_input_75c3b344._.js.map
\ No newline at end of file \ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/shebang/input/node_modules/foo/index.js"],"sourcesContent":["#!/usr/bin/env node\n\nexport function foo(value) {\n console.assert(value);\n}\n"],"names":["foo","value","console","assert"],"mappings":";;;;AAEO,SAASA,IAAIC,KAAK;IACvBC,QAAQC,MAAM,CAACF;AACjB","ignoreList":[0]}},
{"offset": {"line": 15, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/shebang/input/index.js"],"sourcesContent":["#!/usr/bin/env node\n\nimport { foo } from 'foo'\n\nfoo(true)\n"],"names":[],"mappings":";AAEA;;AAEA,IAAA,4NAAG,EAAC"}}]
}
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([ (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/5c1d0_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_fa502a1e.js", "output/5c1d0_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_ff8b2f88.js",
{"otherChunks":["output/780ce_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_284cef63.js","output/aaf3a_crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_bae4bbe2._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js [test] (ecmascript)"]} {"otherChunks":["output/aaf3a_crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_bae4bbe2._.js","output/780ce_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_284cef63.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js [test] (ecmascript)"]}
]); ]);
// Dummy runtime // Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/5c1d0_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_index_7cb9f920.js",
{"otherChunks":["output/aaf3a_crates_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_127ba44c._.css","output/780ce_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_index_f81e3d8a.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/5c1d0_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_index_f17db994.js",
{"otherChunks":["output/780ce_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_other_5b4712f9.css","output/bf321_tests_snapshot_css_absolute-uri-import_input_withduplicateurl_a75e84b4.css","output/780ce_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_index_c5822330.css","output/780ce_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_index_f81e3d8a.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
@import "https://example.com/stylesheet1.css"; @import "https://example.com/stylesheet1.css";
@import "https://example.com/withquote\".css"; @import "https://example.com/withquote\".css";
@import "https://example.com/stylesheet2.css"; @import "https://example.com/stylesheet2.css";
/* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/other.css [test] (css) */
.foo {
background-color: red;
}
/* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/withduplicateurl.css [test] (css) */
.bar {
background-color: green;
}
/* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/index.css [test] (css) */ /* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/index.css [test] (css) */
body { body {
background-color: #00f; background-color: #00f;
} }
/*# sourceMappingURL=aaf3a_crates_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_127ba44c._.css.map*/ /*# sourceMappingURL=780ce_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_index_c5822330.css.map*/
\ No newline at end of file \ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/index.css"],"sourcesContent":["@import 'https://example.com/stylesheet1.css';\n@import 'https://example.com/withquote\".css';\n@import './other.css';\n@import './withduplicateurl.css';\n@import url('https://example.com/stylesheet2.css');\n\nbody {\n background-color: blue;\n}\n"],"names":[],"mappings":"AAMA"}}]
}
\ No newline at end of file
/* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/other.css [test] (css) */
.foo {
background-color: red;
}
/*# sourceMappingURL=780ce_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_other_5b4712f9.css.map*/
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 1, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/other.css"],"sourcesContent":[".foo {\n background-color: red;\n}\n"],"names":[],"mappings":"AAAA"}}]
}
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/other.css"],"sourcesContent":[".foo {\n background-color: red;\n}\n"],"names":[],"mappings":"AAAA"}},
{"offset": {"line": 9, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/withduplicateurl.css"],"sourcesContent":["/* This should not be duplicated */\n@import 'https://example.com/stylesheet1.css';\n\n.bar {\n background-color: green;\n}\n"],"names":[],"mappings":"AAGA"}},
{"offset": {"line": 14, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/index.css"],"sourcesContent":["@import 'https://example.com/stylesheet1.css';\n@import 'https://example.com/withquote\".css';\n@import './other.css';\n@import './withduplicateurl.css';\n@import url('https://example.com/stylesheet2.css');\n\nbody {\n background-color: blue;\n}\n"],"names":[],"mappings":"AAMA"}}]
}
\ No newline at end of file
@import "https://example.com/stylesheet1.css";
/* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/withduplicateurl.css [test] (css) */
.bar {
background-color: green;
}
/*# sourceMappingURL=bf321_tests_snapshot_css_absolute-uri-import_input_withduplicateurl_a75e84b4.css.map*/
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 2, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/input/withduplicateurl.css"],"sourcesContent":["/* This should not be duplicated */\n@import 'https://example.com/stylesheet1.css';\n\n.bar {\n background-color: green;\n}\n"],"names":[],"mappings":"AAGA"}}]
}
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/5c1d0_turbopack-tests_tests_snapshot_css_chained-attributes_input_index_53d36408.js",
{"otherChunks":["output/aaf3a_crates_turbopack-tests_tests_snapshot_css_chained-attributes_input_1fa64d9f._.css","output/780ce_turbopack-tests_tests_snapshot_css_chained-attributes_input_index_d8843af2.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/5c1d0_turbopack-tests_tests_snapshot_css_chained-attributes_input_index_cab04d6d.js",
{"otherChunks":["output/aaf3a_crates_turbopack-tests_tests_snapshot_css_chained-attributes_input_c_86191b3e.css","output/aaf3a_crates_turbopack-tests_tests_snapshot_css_chained-attributes_input_c_ef6cffd3.css","output/aaf3a_crates_turbopack-tests_tests_snapshot_css_chained-attributes_input_b_0dd56a4c.css","output/aaf3a_crates_turbopack-tests_tests_snapshot_css_chained-attributes_input_a_531b8d37.css","output/780ce_turbopack-tests_tests_snapshot_css_chained-attributes_input_style_8666effe.css","output/780ce_turbopack-tests_tests_snapshot_css_chained-attributes_input_index_d8843af2.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
/* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/style.css [test] (css) */
.style {
color: #ff0;
}
/*# sourceMappingURL=780ce_turbopack-tests_tests_snapshot_css_chained-attributes_input_style_8666effe.css.map*/
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 1, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/style.css"],"sourcesContent":["@import url('./a.css') layer(layer) supports(not(display: inline-grid)) print;\n\n.style {\n color: yellow;\n}\n"],"names":[],"mappings":"AAEA"}}]
}
\ No newline at end of file
/* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/c.css [test] (css, layer(layer) layer(foo) print and (orientation: landscape) supports(not(display: inline-grid)) supports(font-format(woff2))) */
@layer layer.foo {
@media print and (orientation: landscape) {
@supports not(display: inline-grid) and font-format(woff2) {
.imported {
color: red;
}
}
}
}
/* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/c.css [test] (css, layer(layer) layer(bar) print and (orientation: portrait) supports(not(display: inline-grid)) supports(font-format(woff2))) */
@layer layer.bar {
@media print and (orientation: portrait) {
@supports not(display: inline-grid) and font-format(woff2) {
.imported {
color: red;
}
}
}
}
/* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/b.css [test] (css, layer(layer) print supports(not(display: inline-grid)) supports(font-format(woff2))) */
@layer layer {
@media print {
@supports not(display: inline-grid) and font-format(woff2) {
.imported {
color: orange;
}
}
}
}
/* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/a.css [test] (css, layer(layer) print supports(not(display: inline-grid))) */
@layer layer {
@media print {
@supports not(display: inline-grid) {
.imported {
color: #0ff;
}
}
}
}
/* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/style.css [test] (css) */
.style {
color: #ff0;
}
/*# sourceMappingURL=aaf3a_crates_turbopack-tests_tests_snapshot_css_chained-attributes_input_1fa64d9f._.css.map*/
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/c.css"],"sourcesContent":[".imported {\n color: red;\n}\n"],"names":[],"mappings":"AAAA"}},
{"offset": {"line": 16, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/c.css"],"sourcesContent":[".imported {\n color: red;\n}\n"],"names":[],"mappings":"AAAA"}},
{"offset": {"line": 28, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/b.css"],"sourcesContent":["@import url('./c.css') layer(foo) (orientation: landscape);\n@import url('./c.css') layer(bar) (orientation: portrait);\n\n.imported {\n color: orange;\n}\n"],"names":[],"mappings":"AAGA"}},
{"offset": {"line": 40, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/a.css"],"sourcesContent":["@import url('./b.css') supports(font-format(woff2));\n\n.imported {\n color: cyan;\n}\n"],"names":[],"mappings":"AAEA"}},
{"offset": {"line": 49, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/style.css"],"sourcesContent":["@import url('./a.css') layer(layer) supports(not(display: inline-grid)) print;\n\n.style {\n color: yellow;\n}\n"],"names":[],"mappings":"AAEA"}}]
}
\ No newline at end of file
/* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/a.css [test] (css, layer(layer) print supports(not(display: inline-grid))) */
@layer layer {
@media print {
@supports not(display: inline-grid) {
.imported {
color: #0ff;
}
}
}
}
/*# sourceMappingURL=aaf3a_crates_turbopack-tests_tests_snapshot_css_chained-attributes_input_a_531b8d37.css.map*/
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/a.css"],"sourcesContent":["@import url('./b.css') supports(font-format(woff2));\n\n.imported {\n color: cyan;\n}\n"],"names":[],"mappings":"AAEA"}}]
}
\ No newline at end of file
/* [project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/b.css [test] (css, layer(layer) print supports(not(display: inline-grid)) supports(font-format(woff2))) */
@layer layer {
@media print {
@supports not(display: inline-grid) and font-format(woff2) {
.imported {
color: orange;
}
}
}
}
/*# sourceMappingURL=aaf3a_crates_turbopack-tests_tests_snapshot_css_chained-attributes_input_b_0dd56a4c.css.map*/
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/b.css"],"sourcesContent":["@import url('./c.css') layer(foo) (orientation: landscape);\n@import url('./c.css') layer(bar) (orientation: portrait);\n\n.imported {\n color: orange;\n}\n"],"names":[],"mappings":"AAGA"}}]
}
\ No newline at end of file
This diff is collapsed.
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