Unverified Commit ab8e8329 authored by Sam Poder's avatar Sam Poder Committed by GitHub

[turbopack] Thread `chunkingHeuristics` through to chunk groups (#95020)

This takes `chunkingHeuristics` from `next.config.js` and puts it on
`ChunkGroupEntry` so it can be on `ChunkGroupInfo` which will then make
it available in `make_production_chunks`
parent 99aba86a
......@@ -60,7 +60,7 @@ use turbopack_core::{
module_graph::{
GraphEntries, ModuleGraph, SingleModuleGraph, VisitedModules,
binding_usage_info::compute_binding_usage_info,
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
chunk_group_info::{ChunkGroup, ChunkGroupEntry, EntryHeuristics},
},
output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
reference::all_assets_from_entries,
......@@ -896,7 +896,10 @@ impl AppProject {
let span = tracing::info_span!("module graph for endpoint", modules = Empty);
let span_clone = span.clone();
async move {
let rsc_entry_chunk_group = ChunkGroupEntry::Entry(vec![rsc_entry]);
let rsc_entry_chunk_group = ChunkGroupEntry::Entry {
modules: vec![rsc_entry],
heuristics: EntryHeuristics::default(),
};
let mut graphs = vec![];
let mut visited_modules = VisitedModules::empty();
......@@ -919,7 +922,10 @@ impl AppProject {
// and the page
let graph = SingleModuleGraph::new_with_entries_visited_intern(
GraphEntries::from_chunk_groups(vec![
ChunkGroupEntry::Entry(client_shared_entries),
ChunkGroupEntry::Entry {
modules: client_shared_entries,
heuristics: EntryHeuristics::default(),
},
ChunkGroupEntry::SharedMultiple(
server_utils
.iter()
......@@ -2144,17 +2150,32 @@ impl Endpoint for AppEndpoint {
#[turbo_tasks::function]
async fn entries(self: Vc<Self>) -> Result<Vc<GraphEntries>> {
let this = self.await?;
let app_entry = self.app_endpoint_entry().await?;
// The route's chunking heuristics from `experimental.turbopackChunkingHeuristics`. They are
// attached to the route's entry chunk group.
let heuristics = this
.app_project
.project()
.next_config()
.chunking_heuristics()
.await?
.entry_heuristics_for(&app_entry.pathname);
Ok(GraphEntries::from_chunk_groups(vec![
ChunkGroupEntry::Entry(vec![self.app_endpoint_entry().await?.rsc_entry]),
ChunkGroupEntry::Entry(
this.app_project
ChunkGroupEntry::Entry {
modules: vec![app_entry.rsc_entry],
heuristics,
},
ChunkGroupEntry::Entry {
modules: this
.app_project
.client_runtime_entries()
.await?
.iter()
.copied()
.map(ResolvedVc::upcast)
.collect(),
),
heuristics: EntryHeuristics::high_priority(),
},
])
.cell())
}
......
......@@ -18,7 +18,7 @@ use turbopack_core::{
module::Module,
module_graph::{
GraphEntries,
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
chunk_group_info::{ChunkGroup, ChunkGroupEntry, EntryHeuristics},
},
output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
reference_type::{EntryReferenceSubType, ReferenceType},
......@@ -257,8 +257,11 @@ impl Endpoint for InstrumentationEndpoint {
async fn entries(self: Vc<Self>) -> Result<Vc<GraphEntries>> {
let entry_module = self.entry_module().to_resolved().await?;
Ok(
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry(vec![entry_module])])
.cell(),
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry {
modules: vec![entry_module],
heuristics: EntryHeuristics::high_priority(),
}])
.cell(),
)
}
......
......@@ -20,7 +20,7 @@ use turbopack_core::{
module::Module,
module_graph::{
GraphEntries,
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
chunk_group_info::{ChunkGroup, ChunkGroupEntry, EntryHeuristics},
},
output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
reference_type::{EntryReferenceSubType, ReferenceType},
......@@ -407,9 +407,11 @@ impl Endpoint for MiddlewareEndpoint {
#[turbo_tasks::function]
async fn entries(self: Vc<Self>) -> Result<Vc<GraphEntries>> {
Ok(
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry(vec![
self.entry_module().to_resolved().await?,
])])
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry {
modules: vec![self.entry_module().to_resolved().await?],
// Middleware runs on (potentially) all routes, so treat it as high priority.
heuristics: EntryHeuristics::high_priority(),
}])
.cell(),
)
}
......
......@@ -56,7 +56,7 @@ use turbopack_core::{
module_graph::{
GraphEntries, ModuleGraph, SingleModuleGraph, VisitedModules,
binding_usage_info::compute_binding_usage_info,
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
chunk_group_info::{ChunkGroup, ChunkGroupEntry, EntryHeuristics},
},
output::{OptionOutputAsset, OutputAsset, OutputAssets},
reference::all_assets_from_entries,
......@@ -751,9 +751,10 @@ impl PageEndpoint {
}
let graph = SingleModuleGraph::new_with_entries_visited_intern(
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry(vec![
ssr_chunk_module.ssr_module,
])]),
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry {
modules: vec![ssr_chunk_module.ssr_module],
heuristics: EntryHeuristics::default(),
}]),
visited_modules,
should_trace,
should_read_binding_usage,
......@@ -1713,6 +1714,14 @@ impl Endpoint for PageEndpoint {
let ssr_chunk_module = self.internal_ssr_chunk_module().await?;
let heuristics = this
.pages_project
.project()
.next_config()
.chunking_heuristics()
.await?
.entry_heuristics_for(&this.pathname);
let shared_entries = [
ssr_chunk_module.document_module,
ssr_chunk_module.app_module,
......@@ -1722,17 +1731,20 @@ impl Endpoint for PageEndpoint {
.into_iter()
.flatten()
.map(ChunkGroupEntry::Shared)
.chain(std::iter::once(ChunkGroupEntry::Entry(vec![
ssr_chunk_module.ssr_module,
])))
.chain(std::iter::once(ChunkGroupEntry::Entry {
modules: vec![ssr_chunk_module.ssr_module],
heuristics: heuristics.clone(),
}))
.chain(if this.ty == PageEndpointType::Html {
Some(ChunkGroupEntry::Entry(
self.client_evaluatable_assets()
Some(ChunkGroupEntry::Entry {
modules: self
.client_evaluatable_assets()
.await?
.iter()
.map(|m| ResolvedVc::upcast(*m))
.collect(),
))
heuristics,
})
.into_iter()
} else {
None.into_iter()
......
......@@ -73,7 +73,7 @@ use turbopack_core::{
binding_usage_info::{
BindingUsageInfo, OptionBindingUsageInfo, compute_binding_usage_info,
},
chunk_group_info::ChunkGroupEntry,
chunk_group_info::{ChunkGroupEntry, EntryHeuristics},
},
output::{
ExpandOutputAssetsInput, ExpandedOutputAssets, OutputAsset, OutputAssets,
......@@ -1484,7 +1484,10 @@ impl Project {
Ok(if *self.per_page_module_graph().await? {
ModuleGraph::from_graphs(
vec![SingleModuleGraph::new_with_entry(
ChunkGroupEntry::Entry(vec![entry]),
ChunkGroupEntry::Entry {
modules: vec![entry],
heuristics: EntryHeuristics::default(),
},
/* include_traced */ *self.should_write_nft_manifests().await?,
/* include_binding_usage */ self.next_mode().await?.is_production(),
)],
......@@ -1510,8 +1513,11 @@ impl Project {
.collect();
ModuleGraph::from_graphs(
vec![SingleModuleGraph::new_with_entries(
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry(entries)])
.resolved_cell(),
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry {
modules: entries,
heuristics: EntryHeuristics::default(),
}])
.resolved_cell(),
/* include_traced */ *self.should_write_nft_manifests().await?,
/* include_binding_usage */ self.next_mode().await?.is_production(),
)],
......@@ -2579,14 +2585,16 @@ impl Project {
#[turbo_tasks::function]
pub async fn client_main_modules(self: Vc<Self>) -> Result<Vc<GraphEntries>> {
let pages_project = self.pages_project();
let mut chunk_groups = vec![ChunkGroupEntry::Entry(vec![
pages_project.client_main_module().to_resolved().await?,
])];
let mut chunk_groups = vec![ChunkGroupEntry::Entry {
modules: vec![pages_project.client_main_module().to_resolved().await?],
heuristics: EntryHeuristics::high_priority(),
}];
if let Some(app_project) = *self.app_project().await? {
chunk_groups.push(ChunkGroupEntry::Entry(vec![
app_project.client_main_module().to_resolved().await?,
]));
chunk_groups.push(ChunkGroupEntry::Entry {
modules: vec![app_project.client_main_module().to_resolved().await?],
heuristics: EntryHeuristics::high_priority(),
});
}
Ok(GraphEntries::from_chunk_groups(chunk_groups).cell())
......
......@@ -11,7 +11,7 @@ use turbopack_core::{
module::Module,
module_graph::{
ModuleGraph, SingleModuleGraph,
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
chunk_group_info::{ChunkGroup, ChunkGroupEntry, EntryHeuristics},
},
output::{OutputAsset, OutputAssets},
reference_type::{EntryReferenceSubType, ReferenceType},
......@@ -109,7 +109,10 @@ async fn service_worker_chunk(
let own_graph = ModuleGraph::from_graphs(
vec![SingleModuleGraph::new_with_entry(
ChunkGroupEntry::Entry(vec![module]),
ChunkGroupEntry::Entry {
modules: vec![module],
heuristics: EntryHeuristics::default(),
},
/* include_traced */ *project.should_write_nft_manifests().await?,
/* include_binding_usage */ is_production,
)],
......
......@@ -26,7 +26,7 @@ use turbopack_core::{
issue::{
IgnoreIssue, IgnoreIssuePattern, Issue, IssueExt, IssueSeverity, IssueStage, StyledString,
},
module_graph::style_groups::StyleGroupsAlgorithm,
module_graph::{chunk_group_info::EntryHeuristics, style_groups::StyleGroupsAlgorithm},
resolve::ResolveAliasMap,
};
use turbopack_ecmascript::{
......@@ -1131,6 +1131,82 @@ const DEFAULT_REQUEST_COST: f32 = 100_000.0;
/// Default `weightDistribution` for the graph algorithm.
const DEFAULT_WEIGHT_DISTRIBUTION: f32 = 0.1;
/// `experimental.chunkingHeuristics`: hints for Turbopack's production chunker.
#[derive(
Clone,
Debug,
Default,
PartialEq,
Deserialize,
TraceRawVcs,
NonLocalValue,
OperationValue,
Encode,
Decode,
)]
#[serde(rename_all = "camelCase")]
pub struct ChunkingHeuristicsConfig {
/// A number between `0.0..=1.0`. Higher values weight the benefit of merging
/// chunks for a single page load more heavily. A site's bounce rate is a good
/// approximation if you don't have a better value.
first_page_load_priority: Option<f64>,
/// Regular expressions matching routes that are priority routes and should be grouped more
/// eagerly to reduce the single-route request cost (e.g. the homepage) at the cost of
/// requiring more requests on navigation.
priority_routes: Option<Vec<RegexComponents>>,
/// Multiplier applied to the single-request probability of `priority_routes` routes
/// (default `1.5`). Higher values merge their client-side bundles more eagerly.
priority_boost: Option<f64>,
/// Estimated cost of an additional request, in bytes (uncompressed and unminified
/// bytes of code, default is 200 KB), used by the chunker to trade off request
/// count against preventing double-fetching.
request_cost: Option<u64>,
}
#[turbo_tasks::value]
pub struct ChunkingHeuristics {
/// First-page-load priority as an integer percentage (`0..=100`), or `None` if unset.
pub first_page_load_priority: Option<u32>,
/// Route-matching regexes for priority routes.
priority_routes: Vec<EsRegex>,
/// Priority-route boost as an integer percentage (e.g. `150` for a 1.5x boost), or
/// `None` to use the default.
pub priority_boost_percent: Option<u32>,
/// Global estimated cost of an additional request, in bytes, or `None` if unset.
pub request_cost: Option<u64>,
}
impl ChunkingHeuristics {
/// Compute the [`EntryHeuristics`] for a route `pathname` by matching it against the configured
/// priority-route regexes.
pub fn entry_heuristics_for(&self, pathname: &str) -> EntryHeuristics {
let high_priority = self
.priority_routes
.iter()
.filter(|regex| regex.as_regex_str().is_none())
.any(|regex| regex.is_match(pathname))
|| regex::RegexSet::new(
self.priority_routes
.iter()
.filter_map(|regex| regex.as_regex_str()),
)
.is_ok_and(|set| set.is_match(pathname));
EntryHeuristics { high_priority }
}
}
/// Compile a list of route-matching [`RegexComponents`] into [`EsRegex`]es.
fn parse_route_regexes(patterns: &[RegexComponents]) -> Result<Vec<EsRegex>> {
patterns
.iter()
.cloned()
.map(|pattern| {
EsRegex::try_from(pattern)
.context("Invalid route pattern in `experimental.turbopackChunkingHeuristics`")
})
.collect()
}
/// Resolve `experimental.cssChunking` to the [`StyleGroupsAlgorithm`] Turbopack should use.
///
/// `strict` and `false` (`CssChunkingObject::None`) are bundler-incompatible with Turbopack and
......@@ -1223,6 +1299,9 @@ pub struct ExperimentalConfig {
/// CSS chunking strategy. See [`CssChunkingConfig`] for the accepted shapes.
css_chunking: Option<CssChunkingConfig>,
/// Traffic-shape hints for the production chunker. See [`ChunkingHeuristicsConfig`].
turbopack_chunking_heuristics: Option<ChunkingHeuristicsConfig>,
// ---
// UNSUPPORTED
// ---
......@@ -2012,6 +2091,27 @@ impl NextConfig {
Ok(resolve_css_chunking_algorithm(self.experimental.css_chunking.as_ref())?.cell())
}
#[turbo_tasks::function]
pub fn chunking_heuristics(&self) -> Result<Vc<ChunkingHeuristics>> {
let config = self.experimental.turbopack_chunking_heuristics.as_ref();
let priority_routes = parse_route_regexes(
config
.and_then(|c| c.priority_routes.as_deref())
.unwrap_or_default(),
)?;
Ok(ChunkingHeuristics {
first_page_load_priority: config
.and_then(|c| c.first_page_load_priority)
.map(|priority| (priority.clamp(0.0, 1.0) * 100.0).round() as u32),
priority_routes,
priority_boost_percent: config
.and_then(|c| c.priority_boost)
.map(|boost| (boost.max(0.0) * 100.0).round() as u32),
request_cost: config.and_then(|c| c.request_cost),
}
.cell())
}
#[turbo_tasks::function]
pub fn mdx_rs(&self) -> Vc<OptionalMdxTransformOptions> {
let options = &self.experimental.mdx_rs;
......
......@@ -122,6 +122,16 @@ impl EsRegex {
}
}
/// Returns the normalized `regex`-crate source (with inline flags already applied) if this
/// regex is backed by the `regex` crate, or `None` if it falls back to `regress` (e.g. it uses
/// lookahead/backreferences). Useful for combining several patterns into a [`regex::RegexSet`].
pub fn as_regex_str(&self) -> Option<&str> {
match &self.delegate {
EsRegexImpl::Regex(r) => Some(r.as_str()),
EsRegexImpl::Regress(_) => None,
}
}
/// Searches for the first match of the regex in the `haystack`, and iterates over the capture
/// groups within that first match.
///
......
......@@ -36,7 +36,7 @@ use turbopack_core::{
module_graph::{
GraphEntries, ModuleGraph, SingleModuleGraph,
binding_usage_info::compute_binding_usage_info,
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
chunk_group_info::{ChunkGroup, ChunkGroupEntry, EntryHeuristics},
},
output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
reference_type::{EntryReferenceSubType, ReferenceType},
......@@ -316,8 +316,11 @@ async fn build_internal(
.await?;
let single_graph = SingleModuleGraph::new_with_entries(
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry(entries.clone())])
.resolved_cell(),
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry {
modules: entries.clone(),
heuristics: EntryHeuristics::default(),
}])
.resolved_cell(),
false,
true,
);
......
......@@ -14,7 +14,8 @@ use turbopack_core::{
file_source::FileSource,
module::Module,
module_graph::{
GraphEntries, ModuleGraph, SingleModuleGraph, chunk_group_info::ChunkGroupEntry,
GraphEntries, ModuleGraph, SingleModuleGraph,
chunk_group_info::{ChunkGroupEntry, EntryHeuristics},
},
reference_type::{EntryReferenceSubType, ReferenceType},
resolve::{
......@@ -168,8 +169,11 @@ pub async fn create_web_entry_source(
.collect::<Vec<ResolvedVc<Box<dyn Module>>>>();
let module_graph = ModuleGraph::from_graphs(
vec![SingleModuleGraph::new_with_entries(
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry(all_modules)])
.resolved_cell(),
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry {
modules: all_modules,
heuristics: EntryHeuristics::default(),
}])
.resolved_cell(),
false,
false,
)],
......
......@@ -94,6 +94,31 @@ pub struct ChunkGroupInfo {
#[turbo_tasks(trace_ignore)]
#[bincode(with = "turbo_bincode::indexset")]
pub chunk_group_keys: FxIndexSet<ChunkGroupKey>,
pub chunking_heuristics: ChunkingHeuristicsInfo,
}
/// Chunking heuristics computed by [`compute_chunk_group_info`]. `priority_routes` is a set of
/// chunk-group indices (same indexing as [`ChunkGroupInfo::chunk_groups`]).
#[derive(
Debug,
Default,
Clone,
PartialEq,
Eq,
TraceRawVcs,
ValueDebugFormat,
NonLocalValue,
Encode,
Decode,
)]
pub struct ChunkingHeuristicsInfo {
/// The set of chunk-group indices that belong to a priority route: the priority
/// routes themselves, plus every chunk group they pull in.
///
/// Example: `priority_routes = {3, 7}` — chunk groups 3 and 7 are served by a priority
/// route; any group not in the set (e.g. 4) is not.
#[turbo_tasks(trace_ignore)]
pub priority_routes: RoaringBitmapWrapper,
}
#[turbo_tasks::value_impl]
......@@ -126,11 +151,30 @@ impl ChunkGroupInfo {
}
}
/// Per-entry chunking heuristics.
#[turbo_tasks::task_input]
#[derive(Debug, Default, Clone, Hash, PartialEq, Eq, TraceRawVcs, Encode, Decode)]
pub struct EntryHeuristics {
pub high_priority: bool,
}
impl EntryHeuristics {
/// Heuristics for an entry that is a high-priority route.
pub fn high_priority() -> Self {
Self {
high_priority: true,
}
}
}
/// See [ChunkGroup] for documentation
#[turbo_tasks::task_input]
#[derive(Debug, Clone, Hash, PartialEq, Eq, TraceRawVcs, Encode, Decode)]
pub enum ChunkGroupEntry {
Entry(Vec<ResolvedVc<Box<dyn Module>>>),
Entry {
modules: Vec<ResolvedVc<Box<dyn Module>>>,
heuristics: EntryHeuristics,
},
Async(ResolvedVc<Box<dyn Module>>),
Isolated(ResolvedVc<Box<dyn Module>>),
IsolatedMerged {
......@@ -152,7 +196,9 @@ impl ChunkGroupEntry {
Self::Async(e) | Self::Isolated(e) | Self::Shared(e) => {
Either::Left(std::iter::once(*e))
}
Self::Entry(entries)
Self::Entry {
modules: entries, ..
}
| Self::IsolatedMerged { entries, .. }
| Self::SharedMultiple(entries)
| Self::SharedMerged { entries, .. } => Either::Right(entries.iter().copied()),
......@@ -465,7 +511,7 @@ pub async fn compute_chunk_group_info(graph: &ModuleGraph) -> Result<Vc<ChunkGro
>,
) -> ChunkGroupKey {
match entry {
ChunkGroupEntry::Entry(entries) => ChunkGroupKey::Entry(entries),
ChunkGroupEntry::Entry { modules, .. } => ChunkGroupKey::Entry(modules),
ChunkGroupEntry::Async(entry) => ChunkGroupKey::Async(entry),
ChunkGroupEntry::Isolated(entry) => ChunkGroupKey::Isolated(entry),
ChunkGroupEntry::Shared(entry) => ChunkGroupKey::Shared(entry),
......@@ -760,6 +806,7 @@ pub async fn compute_chunk_group_info(graph: &ModuleGraph) -> Result<Vc<ChunkGro
Ok(ChunkGroupInfo {
module_chunk_groups: ResolvedVc::cell(module_chunk_groups),
chunk_group_keys: chunk_groups_map.keys().cloned().collect(),
chunking_heuristics: ChunkingHeuristicsInfo::default(),
chunk_groups: chunk_groups_map
.into_iter()
.map(|(k, (_, merged_entries))| match k {
......
......@@ -1967,6 +1967,7 @@ pub mod tests {
asset::{Asset, AssetContent},
ident::AssetIdent,
module::{Module, ModuleSideEffects},
module_graph::chunk_group_info::EntryHeuristics,
reference::{ModuleReference, ModuleReferences},
resolve::ModuleResolveResult,
};
......@@ -2288,8 +2289,11 @@ pub mod tests {
let b_module = make_module("b.js").await?;
let parent_graph = SingleModuleGraph::new_with_entries(
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry(vec![b_module])])
.resolved_cell(),
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry {
modules: vec![b_module],
heuristics: EntryHeuristics::default(),
}])
.resolved_cell(),
false,
false,
);
......@@ -2298,9 +2302,10 @@ pub mod tests {
vec![
parent_graph,
SingleModuleGraph::new_with_entries_visited(
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry(vec![
a_module,
])])
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry {
modules: vec![a_module],
heuristics: EntryHeuristics::default(),
}])
.resolved_cell(),
VisitedModules::from_graph(parent_graph),
false,
......@@ -2465,8 +2470,11 @@ pub mod tests {
let a_module = make_module("a.js").await?;
let parent_graph = SingleModuleGraph::new_with_entries(
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry(vec![x_module])])
.resolved_cell(),
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry {
modules: vec![x_module],
heuristics: EntryHeuristics::default(),
}])
.resolved_cell(),
true,
false,
);
......@@ -2475,9 +2483,10 @@ pub mod tests {
vec![
parent_graph,
SingleModuleGraph::new_with_entries_visited(
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry(vec![
a_module,
])])
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry {
modules: vec![a_module],
heuristics: EntryHeuristics::default(),
}])
.resolved_cell(),
VisitedModules::from_graph(parent_graph),
true,
......@@ -2827,7 +2836,10 @@ pub mod tests {
.await?;
let graph = SingleModuleGraph::new_with_entries(
GraphEntries::resolved_cell(GraphEntries::new(
vec![ChunkGroupEntry::Entry(entry_modules.clone())],
vec![ChunkGroupEntry::Entry {
modules: entry_modules.clone(),
heuristics: EntryHeuristics::default(),
}],
vec![],
)),
false,
......
......@@ -26,7 +26,7 @@ use turbopack_core::{
module::Module,
module_graph::{
GraphEntries, ModuleGraph,
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
chunk_group_info::{ChunkGroup, ChunkGroupEntry, EntryHeuristics},
},
output::{OutputAsset, OutputAssets},
reference_type::{InnerAssets, ReferenceType},
......@@ -422,15 +422,19 @@ pub struct EvaluateEntries {
impl EvaluateEntries {
#[turbo_tasks::function]
pub async fn graph_entries(self: Vc<Self>) -> Result<Vc<GraphEntries>> {
Ok(GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry(
self.await?
.entries
.iter()
.cloned()
.map(ResolvedVc::upcast)
.collect(),
)])
.cell())
Ok(
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry {
modules: self
.await?
.entries
.iter()
.cloned()
.map(ResolvedVc::upcast)
.collect(),
heuristics: EntryHeuristics::default(),
}])
.cell(),
)
}
}
......
......@@ -32,7 +32,7 @@ use turbopack_core::{
module::Module,
module_graph::{
ModuleGraph, SingleModuleGraph,
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
chunk_group_info::{ChunkGroup, ChunkGroupEntry, EntryHeuristics},
},
output::{ExpandOutputAssetsInput, OutputAsset, OutputAssets, expand_output_assets},
reference_type::{EcmaScriptModulesReferenceSubType, InnerAssets, ReferenceType},
......@@ -753,7 +753,10 @@ impl EvaluateContext for WebpackLoaderContext {
// Build a module graph from the resolved module and its
// transitive dependencies
let single_graph = SingleModuleGraph::new_with_entry(
ChunkGroupEntry::Entry(vec![module]),
ChunkGroupEntry::Entry {
modules: vec![module],
heuristics: EntryHeuristics::default(),
},
false,
false,
);
......
......@@ -50,7 +50,7 @@ use turbopack_core::{
module_graph::{
GraphEntries, ModuleGraph, SingleModuleGraph,
binding_usage_info::compute_binding_usage_info,
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
chunk_group_info::{ChunkGroup, ChunkGroupEntry, EntryHeuristics},
},
output::{OutputAsset, OutputAssets, OutputAssetsReference, OutputAssetsWithReferenced},
reference_type::{EntryReferenceSubType, ReferenceType, ReferenceTypeCondition},
......@@ -468,8 +468,11 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
.collect();
let single_graph = SingleModuleGraph::new_with_entries(
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry(entry_modules.clone())])
.resolved_cell(),
GraphEntries::from_chunk_groups(vec![ChunkGroupEntry::Entry {
modules: entry_modules.clone(),
heuristics: EntryHeuristics::default(),
}])
.resolved_cell(),
false,
true,
);
......
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