Unverified Commit 8216e23a authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Turbopack: reduce hmr chunk list subscriptions (#94062)

Previously, we created chunk list register chunks for every reachable
chunk in the chunk graph on a page. Now, we only create one that
subscribes to all recursively reachable assets.

This has to pass around an explicit list of client references chunks as
those cannot be discovered via the chunk graph alone.

This results in a significant performance improvement when loading pages
with the dev server, improving performance of a 60s cold build in a
large app by about 10s.
parent 88027c21
...@@ -9,7 +9,8 @@ use next_core::{ ...@@ -9,7 +9,8 @@ use next_core::{
get_edge_resolve_options_context, get_next_package, get_edge_resolve_options_context, get_next_package,
next_app::{ next_app::{
AppEntry, AppPage, get_app_client_references_chunks, get_app_client_shared_chunk_group, AppEntry, AppPage, get_app_client_references_chunks, get_app_client_shared_chunk_group,
get_app_page_entry, get_app_route_entry, metadata::route::get_app_metadata_route_entry, get_app_page_entry, get_app_route_entry, get_client_references_chunks_for_hmr,
metadata::route::get_app_metadata_route_entry,
}, },
next_client::{ next_client::{
ClientContextType, get_client_module_options_context, get_client_resolve_options_context, ClientContextType, get_client_module_options_context, get_client_resolve_options_context,
...@@ -38,8 +39,8 @@ use next_core::{ ...@@ -38,8 +39,8 @@ use next_core::{
use tracing::{Instrument, field::Empty}; use tracing::{Instrument, field::Empty};
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ use turbo_tasks::{
Completion, NonLocalValue, ResolvedVc, TryJoinIterExt, ValueToString, Vc, fxindexset, Completion, FxIndexMap, NonLocalValue, ResolvedVc, TryJoinIterExt, ValueToString, Vc,
trace::TraceRawVcs, fxindexset, trace::TraceRawVcs,
}; };
use turbo_tasks_fs::{File, FileContent, FileSystemPath}; use turbo_tasks_fs::{File, FileContent, FileSystemPath};
use turbopack::{ use turbopack::{
...@@ -1278,6 +1279,26 @@ impl AppEndpoint { ...@@ -1278,6 +1279,26 @@ impl AppEndpoint {
None None
}; };
let per_page_module_graph = *project.per_page_module_graph().await?;
let next_dynamic_imports =
NextDynamicGraphs::new(*module_graphs.base, per_page_module_graph)
.get_next_dynamic_imports_for_endpoint(*rsc_entry)
.await?;
let is_production = project.next_mode().await?.is_production();
let client_references =
ClientReferencesGraphs::new(*module_graphs.base, per_page_module_graph)
.get_client_references_for_endpoint(
*rsc_entry,
matches!(this.ty, AppEndpointType::Page { .. }),
is_production,
is_production,
)
.to_resolved()
.await?;
// We only need the client runtime entries for pages not for Route Handlers // We only need the client runtime entries for pages not for Route Handlers
let (availability_info, client_shared_chunks) = if is_app_page { let (availability_info, client_shared_chunks) = if is_app_page {
let client_shared_chunk_group = get_app_client_shared_chunk_group( let client_shared_chunk_group = get_app_client_shared_chunk_group(
...@@ -1300,26 +1321,6 @@ impl AppEndpoint { ...@@ -1300,26 +1321,6 @@ impl AppEndpoint {
(AvailabilityInfo::root(), vec![]) (AvailabilityInfo::root(), vec![])
}; };
let per_page_module_graph = *project.per_page_module_graph().await?;
let next_dynamic_imports =
NextDynamicGraphs::new(*module_graphs.base, per_page_module_graph)
.get_next_dynamic_imports_for_endpoint(*rsc_entry)
.await?;
let is_production = project.next_mode().await?.is_production();
let client_references =
ClientReferencesGraphs::new(*module_graphs.base, per_page_module_graph)
.get_client_references_for_endpoint(
*rsc_entry,
matches!(this.ty, AppEndpointType::Page { .. }),
is_production,
is_production,
)
.to_resolved()
.await?;
let client_references_chunks = get_app_client_references_chunks( let client_references_chunks = get_app_client_references_chunks(
*client_references, *client_references,
*module_graphs.full, *module_graphs.full,
...@@ -1351,6 +1352,39 @@ impl AppEndpoint { ...@@ -1351,6 +1352,39 @@ impl AppEndpoint {
server_assets.extend(assets.all_assets().await?.iter().copied()); server_assets.extend(assets.all_assets().await?.iter().copied());
} }
// In development, register a page-specific HMR chunk list that owns all client
// reference chunks for this page. These chunks are computed via separate
// chunk_group(IsolatedMerged) calls and aren't reachable from the shared client
// chunk group's module graph, so they need their own HMR subscription.
//
// The register chunk is page-specific and must NOT go into client_shared_chunks
// (root_main_files), which is shared across all pages. Instead it goes into
// root_main_files_per_page so it is serialized under rootMainFilesTree[page] in
// the build manifest. The server renderer reads rootMainFilesTree[pagePath] first
// (required-scripts.tsx), so only the correct page's register chunk is loaded.
let is_hot_module_replacement_enabled = project
.client_compile_time_info()
.await?
.hot_module_replacement_enabled;
let page_hmr_chunks = if is_app_page && is_hot_module_replacement_enabled {
let client_components_chunks_ident =
AssetIdent::from_path(project.project_path().owned().await?)
.with_modifier(rcstr!("client-components"))
.with_modifier(app_entry.original_name.clone())
.into_vc();
let client_reference_chunks =
get_client_references_chunks_for_hmr(*client_references_chunks);
client_chunking_context
.hmr_chunk_list(client_components_chunks_ident, client_reference_chunks)
.await?
.iter()
.copied()
.collect::<Vec<_>>()
} else {
vec![]
};
client_assets.extend(page_hmr_chunks.iter().copied());
let manifest_path_prefix = &app_entry.original_name; let manifest_path_prefix = &app_entry.original_name;
// Only Pages need a polyfill chunk, Routes handlers don't have any inherent code that runs // Only Pages need a polyfill chunk, Routes handlers don't have any inherent code that runs
...@@ -1404,6 +1438,13 @@ impl AppEndpoint { ...@@ -1404,6 +1438,13 @@ impl AppEndpoint {
ResolvedVc::cell(client_assets.into_iter().collect::<Vec<_>>()); ResolvedVc::cell(client_assets.into_iter().collect::<Vec<_>>());
if emit_manifests != EmitManifests::None { if emit_manifests != EmitManifests::None {
let root_main_files_per_page = if page_hmr_chunks.is_empty() {
FxIndexMap::default()
} else {
let mut m = FxIndexMap::default();
m.insert(app_entry.original_name.clone(), page_hmr_chunks);
m
};
let build_manifest = BuildManifest { let build_manifest = BuildManifest {
output_path: node_root.join(&format!( output_path: node_root.join(&format!(
"server/app{manifest_path_prefix}/build-manifest.json", "server/app{manifest_path_prefix}/build-manifest.json",
...@@ -1412,6 +1453,7 @@ impl AppEndpoint { ...@@ -1412,6 +1453,7 @@ impl AppEndpoint {
pages: Default::default(), pages: Default::default(),
root_main_files: client_shared_chunks, root_main_files: client_shared_chunks,
polyfill_files: polyfill_output_asset.into_iter().collect(), polyfill_files: polyfill_output_asset.into_iter().collect(),
root_main_files_per_page,
}; };
server_assets.insert(ResolvedVc::upcast(build_manifest.resolved_cell())); server_assets.insert(ResolvedVc::upcast(build_manifest.resolved_cell()));
} }
...@@ -1798,6 +1840,7 @@ impl AppEndpoint { ...@@ -1798,6 +1840,7 @@ impl AppEndpoint {
app_entry.rsc_entry.ident(), app_entry.rsc_entry.ident(),
ChunkGroup::Entry(vec![app_entry.rsc_entry]), ChunkGroup::Entry(vec![app_entry.rsc_entry]),
module_graph, module_graph,
OutputAssets::empty(),
chunk_group1.await?.availability_info, chunk_group1.await?.availability_info,
); );
......
...@@ -107,6 +107,7 @@ impl InstrumentationEndpoint { ...@@ -107,6 +107,7 @@ impl InstrumentationEndpoint {
module.ident(), module.ident(),
ChunkGroup::Entry(vec![module]), ChunkGroup::Entry(vec![module]),
module_graph, module_graph,
OutputAssets::empty(),
AvailabilityInfo::root(), AvailabilityInfo::root(),
)) ))
} }
......
...@@ -116,6 +116,7 @@ impl MiddlewareEndpoint { ...@@ -116,6 +116,7 @@ impl MiddlewareEndpoint {
module.ident(), module.ident(),
ChunkGroup::Entry(vec![module]), ChunkGroup::Entry(vec![module]),
module_graph, module_graph,
OutputAssets::empty(),
AvailabilityInfo::root(), AvailabilityInfo::root(),
); );
Ok(edge_chunk_grou) Ok(edge_chunk_grou)
......
...@@ -787,6 +787,7 @@ impl PageEndpoint { ...@@ -787,6 +787,7 @@ impl PageEndpoint {
AssetIdent::from_path(this.page.await?.base_path.clone()).into_vc(), AssetIdent::from_path(this.page.await?.base_path.clone()).into_vc(),
ChunkGroup::Entry(evaluatable_assets), ChunkGroup::Entry(evaluatable_assets),
module_graph, module_graph,
OutputAssets::empty(),
AvailabilityInfo::root(), AvailabilityInfo::root(),
); );
...@@ -1025,6 +1026,7 @@ impl PageEndpoint { ...@@ -1025,6 +1026,7 @@ impl PageEndpoint {
ssr_module.ident(), ssr_module.ident(),
ChunkGroup::Entry(vec![ssr_module]), ChunkGroup::Entry(vec![ssr_module]),
ssr_module_graph, ssr_module_graph,
OutputAssets::empty(),
current_chunk_group.await?.availability_info, current_chunk_group.await?.availability_info,
); );
...@@ -1254,6 +1256,7 @@ impl PageEndpoint { ...@@ -1254,6 +1256,7 @@ impl PageEndpoint {
pages, pages,
polyfill_files: Default::default(), polyfill_files: Default::default(),
root_main_files: Default::default(), root_main_files: Default::default(),
root_main_files_per_page: Default::default(),
}; };
Ok(Vc::upcast(build_manifest.cell())) Ok(Vc::upcast(build_manifest.cell()))
} }
......
...@@ -2424,6 +2424,7 @@ impl Project { ...@@ -2424,6 +2424,7 @@ impl Project {
chunk_name: RcStr, chunk_name: RcStr,
target: HmrTarget, target: HmrTarget,
) -> Result<Vc<Box<dyn Version>>> { ) -> Result<Vc<Box<dyn Version>>> {
tracing::info!(chunk_name = %chunk_name, target = %target, "hmr subscription");
let content = this.hmr_content(chunk_name, target).await?; let content = this.hmr_content(chunk_name, target).await?;
if let Some(content) = &*content { if let Some(content) = &*content {
Ok(content.version()) Ok(content.version())
......
...@@ -2,13 +2,13 @@ use anyhow::Result; ...@@ -2,13 +2,13 @@ use anyhow::Result;
use tracing::Instrument; use tracing::Instrument;
use turbo_rcstr::rcstr; use turbo_rcstr::rcstr;
use turbo_tasks::{ use turbo_tasks::{
FxIndexMap, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, ValueToStringRef, Vc, FxIndexMap, FxIndexSet, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, ValueToStringRef, Vc,
}; };
use turbopack_core::{ use turbopack_core::{
chunk::{ChunkGroupResult, ChunkingContext, availability_info::AvailabilityInfo}, chunk::{ChunkGroupResult, ChunkingContext, availability_info::AvailabilityInfo},
module::Module, module::Module,
module_graph::{ModuleGraph, chunk_group_info::ChunkGroup}, module_graph::{ModuleGraph, chunk_group_info::ChunkGroup},
output::OutputAssetsWithReferenced, output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
}; };
use crate::{ use crate::{
...@@ -337,3 +337,37 @@ pub async fn get_app_client_references_chunks( ...@@ -337,3 +337,37 @@ pub async fn get_app_client_references_chunks(
.instrument(tracing::info_span!("process client references")) .instrument(tracing::info_span!("process client references"))
.await .await
} }
/// Flattens all client-side output assets from `client_references_chunks` so the
/// page's HMR chunk list can subscribe to updates for chunks built outside the
/// entry's own module graph (each `chunk_group(IsolatedMerged)` call for a
/// client component group generates chunks separately).
#[turbo_tasks::function]
pub async fn get_client_references_chunks_for_hmr(
client_references_chunks: Vc<ClientReferencesChunks>,
) -> Result<Vc<OutputAssets>> {
let client_references_chunks_ref = client_references_chunks.await?;
let mut extras: FxIndexSet<ResolvedVc<Box<dyn OutputAsset>>> = client_references_chunks_ref
.layout_segment_client_chunks
.values()
.map(|&assets| async move {
let primary = assets.primary_assets().await?;
Ok(primary.iter().copied().collect::<Vec<_>>())
})
.try_flat_join()
.await?
.into_iter()
.collect();
for &chunk_group in client_references_chunks_ref
.client_component_client_chunks
.values()
{
// Use all_assets() (not primary_assets()) to also follow async loader references
// transitively. This ensures that dynamic imports within 'use client' pages are
// covered by the page's HMR subscription, not just the page module itself.
extras.extend(chunk_group.all_assets().await?.iter().copied());
}
// client_component_ssr_chunks are intentionally excluded: they run on the server
// (Node.js/Edge), not in the browser, so they don't belong in the client HMR chunk list.
Ok(Vc::cell(extras.into_iter().collect()))
}
...@@ -7,6 +7,7 @@ use turbopack_core::{ ...@@ -7,6 +7,7 @@ use turbopack_core::{
}, },
ident::AssetIdent, ident::AssetIdent,
module_graph::{ModuleGraph, chunk_group_info::ChunkGroup}, module_graph::{ModuleGraph, chunk_group_info::ChunkGroup},
output::OutputAssets,
}; };
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -21,7 +22,7 @@ pub async fn get_app_client_shared_chunk_group( ...@@ -21,7 +22,7 @@ pub async fn get_app_client_shared_chunk_group(
} }
let span = tracing::trace_span!("app client shared"); let span = tracing::trace_span!("app client shared");
let app_client_shared_chunk_grou = async { let app_client_shared_chunk_group = async {
client_chunking_context client_chunking_context
.evaluated_chunk_group( .evaluated_chunk_group(
ident, ident,
...@@ -33,6 +34,10 @@ pub async fn get_app_client_shared_chunk_group( ...@@ -33,6 +34,10 @@ pub async fn get_app_client_shared_chunk_group(
.collect(), .collect(),
), ),
module_graph, module_graph,
// The shared chunk group must stay shared across pages; page-specific HMR
// chunks (e.g. client references) are routed through a separate page-specific
// evaluated chunk group instead.
OutputAssets::empty(),
AvailabilityInfo::root(), AvailabilityInfo::root(),
) )
.to_resolved() .to_resolved()
...@@ -42,5 +47,5 @@ pub async fn get_app_client_shared_chunk_group( ...@@ -42,5 +47,5 @@ pub async fn get_app_client_shared_chunk_group(
.instrument(span) .instrument(span)
.await?; .await?;
Ok(app_client_shared_chunk_grou) Ok(app_client_shared_chunk_group)
} }
...@@ -17,7 +17,10 @@ use turbo_rcstr::RcStr; ...@@ -17,7 +17,10 @@ use turbo_rcstr::RcStr;
use turbo_tasks::{NonLocalValue, TaskInput, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, TaskInput, trace::TraceRawVcs};
pub use crate::next_app::{ pub use crate::next_app::{
app_client_references_chunks::{ClientReferencesChunks, get_app_client_references_chunks}, app_client_references_chunks::{
ClientReferencesChunks, get_app_client_references_chunks,
get_client_references_chunks_for_hmr,
},
app_client_shared_chunks::get_app_client_shared_chunk_group, app_client_shared_chunks::get_app_client_shared_chunk_group,
app_entry::AppEntry, app_entry::AppEntry,
app_page_entry::get_app_page_entry, app_page_entry::get_app_page_entry,
......
...@@ -35,6 +35,12 @@ pub struct BuildManifest { ...@@ -35,6 +35,12 @@ pub struct BuildManifest {
pub root_main_files: Vec<ResolvedVc<Box<dyn OutputAsset>>>, pub root_main_files: Vec<ResolvedVc<Box<dyn OutputAsset>>>,
#[bincode(with = "turbo_bincode::indexmap")] #[bincode(with = "turbo_bincode::indexmap")]
pub pages: FxIndexMap<RcStr, ResolvedVc<OutputAssets>>, pub pages: FxIndexMap<RcStr, ResolvedVc<OutputAssets>>,
/// Per-page extra files that supplement `root_main_files` for App Router
/// pages. Serialized as `rootMainFilesTree[page] = [...root_main_files,
/// ...per_page_files]` so that `required-scripts.tsx` can load the correct
/// page-specific scripts without polluting the shared `rootMainFiles`.
#[bincode(with = "turbo_bincode::indexmap")]
pub root_main_files_per_page: FxIndexMap<RcStr, Vec<ResolvedVc<Box<dyn OutputAsset>>>>,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -50,11 +56,19 @@ impl OutputAssetsReference for BuildManifest { ...@@ -50,11 +56,19 @@ impl OutputAssetsReference for BuildManifest {
.try_flat_join() .try_flat_join()
.await?; .await?;
let per_page_files = self
.root_main_files_per_page
.values()
.flatten()
.copied()
.collect::<Vec<_>>();
let references = chunks let references = chunks
.into_iter() .into_iter()
.flatten() .flatten()
.chain(root_main_files) .chain(root_main_files)
.chain(self.polyfill_files.iter().copied()) .chain(self.polyfill_files.iter().copied())
.chain(per_page_files)
.collect(); .collect();
Ok(OutputAssetsWithReferenced::from_assets(Vc::cell( Ok(OutputAssetsWithReferenced::from_assets(Vc::cell(
...@@ -87,6 +101,7 @@ impl Asset for BuildManifest { ...@@ -87,6 +101,7 @@ impl Asset for BuildManifest {
pub root_main_files: Vec<RcStr>, pub root_main_files: Vec<RcStr>,
pub pages: FxIndexMap<RcStr, Vec<RcStr>>, pub pages: FxIndexMap<RcStr, Vec<RcStr>>,
pub amp_first_pages: Vec<RcStr>, pub amp_first_pages: Vec<RcStr>,
pub root_main_files_tree: FxIndexMap<RcStr, Vec<RcStr>>,
} }
let pages: Vec<(RcStr, Vec<RcStr>)> = self let pages: Vec<(RcStr, Vec<RcStr>)> = self
...@@ -146,10 +161,41 @@ impl Asset for BuildManifest { ...@@ -146,10 +161,41 @@ impl Asset for BuildManifest {
.try_flat_join() .try_flat_join()
.await?; .await?;
let root_main_files_tree: Vec<(RcStr, Vec<RcStr>)> = self
.root_main_files_per_page
.iter()
.map(async |(page, per_page_chunks)| {
let per_page_paths: Vec<RcStr> = per_page_chunks
.iter()
.copied()
.map(async |chunk| {
let chunk_path = chunk.path().await?;
Ok(client_relative_path
.get_path_to(&chunk_path)
.context(
"failed to resolve client-relative path to per-page root file",
)?
.into())
})
.try_join()
.await?;
// Combine the shared root_main_files with this page's extra
// files so that required-scripts.tsx gets the full list.
let combined = root_main_files
.iter()
.cloned()
.chain(per_page_paths)
.collect();
Ok((page.clone(), combined))
})
.try_join()
.await?;
let manifest = SerializedBuildManifest { let manifest = SerializedBuildManifest {
pages: FxIndexMap::from_iter(pages), pages: FxIndexMap::from_iter(pages),
polyfill_files, polyfill_files,
root_main_files, root_main_files,
root_main_files_tree: FxIndexMap::from_iter(root_main_files_tree),
..Default::default() ..Default::default()
}; };
......
...@@ -1827,6 +1827,7 @@ async fn hmr_update_with_issues_operation( ...@@ -1827,6 +1827,7 @@ async fn hmr_update_with_issues_operation(
state: ResolvedVc<VersionState>, state: ResolvedVc<VersionState>,
target: HmrTarget, target: HmrTarget,
) -> Result<Vc<HmrUpdateWithIssues>> { ) -> Result<Vc<HmrUpdateWithIssues>> {
tracing::info!(chunk_name = %chunk_name, target = %target, "hmr subscription");
let update_op = project_hmr_update_operation(project, chunk_name, target, state); let update_op = project_hmr_update_operation(project, chunk_name, target, state);
// NOTE: we do not use `strongly_consistent_catch_collectables` here. The JS HMR // NOTE: we do not use `strongly_consistent_catch_collectables` here. The JS HMR
// consumers in `hot-reloader-turbopack.ts` (`subscribeToServerHmr` and // consumers in `hot-reloader-turbopack.ts` (`subscribeToServerHmr` and
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"esModuleInterop": true, "esModuleInterop": true,
"skipLibCheck": false, "skipLibCheck": false,
"lib": ["es2022", "dom"], "lib": ["es2022", "dom", "dom.iterable"],
"rootDir": "src", "rootDir": "src",
"types": ["jest"] "types": ["jest"]
}, },
......
...@@ -141,6 +141,7 @@ function extractModulesFromTurbopackMessage( ...@@ -141,6 +141,7 @@ function extractModulesFromTurbopackMessage(
} }
for (const mergedUpdate of update.instruction.merged) { for (const mergedUpdate of update.instruction.merged) {
if (!mergedUpdate.entries) continue
for (const name of Object.keys(mergedUpdate.entries)) { for (const name of Object.keys(mergedUpdate.entries)) {
const res = /(.*)\s+[([].*/.exec(name) const res = /(.*)\s+[([].*/.exec(name)
if (res === null) { if (res === null) {
......
...@@ -416,12 +416,16 @@ export class TurbopackManifestLoader { ...@@ -416,12 +416,16 @@ export class TurbopackManifestLoader {
polyfillFiles: [], polyfillFiles: [],
lowPriorityFiles, lowPriorityFiles,
rootMainFiles: [], rootMainFiles: [],
rootMainFilesTree: {},
} }
for (const m of manifests) { for (const m of manifests) {
Object.assign(manifest.pages, m.pages) Object.assign(manifest.pages, m.pages)
if (m.rootMainFiles.length) manifest.rootMainFiles = m.rootMainFiles if (m.rootMainFiles.length) manifest.rootMainFiles = m.rootMainFiles
// polyfillFiles should always be the same, so we can overwrite instead of actually merging // polyfillFiles should always be the same, so we can overwrite instead of actually merging
if (m.polyfillFiles.length) manifest.polyfillFiles = m.polyfillFiles if (m.polyfillFiles.length) manifest.polyfillFiles = m.polyfillFiles
if (m.rootMainFilesTree) {
Object.assign(manifest.rootMainFilesTree!, m.rootMainFilesTree)
}
} }
manifest.pages = sortObjectByKey(manifest.pages) as BuildManifest['pages'] manifest.pages = sortObjectByKey(manifest.pages) as BuildManifest['pages']
return manifest return manifest
......
...@@ -153,7 +153,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -153,7 +153,6 @@ describe('Error overlay for hydration errors in App router', () => {
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
<script> <script>
<script>
<Next.js Internal Component> <Next.js Internal Component>
<RootLayout params={Promise}> <RootLayout params={Promise}>
<html <html
...@@ -789,7 +788,6 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -789,7 +788,6 @@ describe('Error overlay for hydration errors in App router', () => {
<Next.js Internal Component> <Next.js Internal Component>
<Next.js Internal Component> <Next.js Internal Component>
<script> <script>
<script>
<RootLayout> <RootLayout>
> <html> > <html>
<body> <body>
......
'use client'
import styles from './dynamic.module.css'
export default function Dynamic() {
return (
<div id="dynamic-component" className={styles.container}>
Dynamic Component
</div>
)
}
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
'use client'
import dynamic from 'next/dynamic'
import { useState } from 'react'
const Dynamic = dynamic(() => import('../components/dynamic'))
export default function LazyPage() {
const [show, setShow] = useState(false)
return (
<div>
<button id="load-button" onClick={() => setShow(true)}>
Load Component
</button>
{show && <Dynamic />}
</div>
)
}
import dynamic from 'next/dynamic'
const Dynamic = dynamic(() => import('./components/dynamic'))
export default function Page() {
return <Dynamic />
}
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
import type * as Playwright from 'playwright'
// Verifies the behavior introduced in https://github.com/vercel/next.js/pull/94062:
// the App Router should register a single HMR chunk list per page entrypoint,
// even when the page contains RSC client references (e.g. lazily-imported
// client components). Previously each chunk_group call produced its own
// Dynamic EcmascriptDevChunkList, resulting in one subscription per client
// component group.
describe('hmr-dynamic-component chunk list subscriptions', () => {
const { next, isTurbopack, isNextDev } = nextTestSetup({
files: __dirname,
})
if (!isTurbopack || !isNextDev) {
it('skipped on non-Turbopack or non-dev environments', () => {})
return
}
it('registers exactly one HMR chunk list subscription for the page entrypoint', async () => {
const sentSubscribes: Array<{ type: string; path: string }> = []
const browser = await next.browser('/', {
beforePageLoad(page: Playwright.Page) {
page.on('websocket', (ws) => {
// Only inspect the Next.js / Turbopack HMR websocket. Other
// websockets (e.g. devtools) should be ignored.
if (!ws.url().includes('/_next/hmr')) {
return
}
ws.on('framesent', (frame) => {
const payload =
typeof frame.payload === 'string'
? frame.payload
: frame.payload.toString('utf8')
try {
const parsed = JSON.parse(payload)
if (
parsed?.type === 'turbopack-subscribe' &&
typeof parsed?.path === 'string'
) {
sentSubscribes.push({ type: parsed.type, path: parsed.path })
}
} catch {
// Non-JSON frames are unrelated; ignore.
}
})
})
},
})
// Wait for the page to fully boot and for HMR subscriptions to settle.
await retry(async () => {
const div = await browser.elementByCss('#dynamic-component')
expect(await div.text()).toContain('Dynamic Component')
})
// Each `turbopack-subscribe` frame corresponds to one `registerChunkList`
// call in the browser runtime:
// 1. The shared client runtime chunk list (covers react/polyfills/etc.)
// 2. A page-specific chunk list that owns the RSC client reference chunks
// (built outside the shared module graph via chunk_group(IsolatedMerged)).
await retry(async () => {
const chunkListPaths = new Set(
sentSubscribes.filter((m) => m.path.endsWith('.js')).map((m) => m.path)
)
expect(chunkListPaths.size).toBe(2)
})
})
})
import { join } from 'path'
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
describe('hmr-dynamic-component', () => {
const { next } = nextTestSetup({
files: __dirname,
patchFileDelay: 500,
})
it('should update text in a dynamically-imported client component without a full reload', async () => {
const browser = await next.browser('/')
const componentPath = join('app', 'components', 'dynamic.tsx')
const originalContent = await next.readFile(componentPath)
try {
await retry(async () => {
const div = await browser.elementByCss('#dynamic-component')
expect(await div.text()).toContain('Dynamic Component')
})
const timeOrigin = await browser.eval('performance.timeOrigin')
const editedContent = originalContent.replace(
'Dynamic Component',
'Dynamic Component UPDATED'
)
await next.patchFile(componentPath, editedContent)
await retry(async () => {
const div = await browser.elementByCss('#dynamic-component')
expect(await div.text()).toContain('Dynamic Component UPDATED')
}, 10000)
// Ensure the page was updated via HMR and not a full reload
expect(await browser.eval('performance.timeOrigin')).toEqual(timeOrigin)
} finally {
await next.patchFile(componentPath, originalContent)
}
})
it('should update text via HMR after loading a button-triggered dynamic component', async () => {
const browser = await next.browser('/lazy')
const componentPath = join('app', 'components', 'dynamic.tsx')
const originalContent = await next.readFile(componentPath)
try {
// Click button to trigger the dynamic import
await browser.elementByCss('#load-button').click()
await retry(async () => {
const div = await browser.elementByCss('#dynamic-component')
expect(await div.text()).toContain('Dynamic Component')
})
const timeOrigin = await browser.eval('performance.timeOrigin')
await next.patchFile(
componentPath,
originalContent.replace(
'Dynamic Component',
'Dynamic Component UPDATED'
)
)
await retry(async () => {
const div = await browser.elementByCss('#dynamic-component')
expect(await div.text()).toContain('Dynamic Component UPDATED')
}, 10000)
// Ensure the page was updated via HMR and not a full reload
expect(await browser.eval('performance.timeOrigin')).toEqual(timeOrigin)
} finally {
await next.patchFile(componentPath, originalContent)
}
})
it('should load updated code when button is clicked after a code change', async () => {
const browser = await next.browser('/lazy')
const componentPath = join('app', 'components', 'dynamic.tsx')
const originalContent = await next.readFile(componentPath)
try {
// Patch the file before the dynamic component has been loaded
await next.patchFile(
componentPath,
originalContent.replace(
'Dynamic Component',
'Dynamic Component PRE-LOADED'
)
)
// Now click the button — the component should load with the updated code
await browser.elementByCss('#load-button').click()
await retry(async () => {
const div = await browser.elementByCss('#dynamic-component')
expect(await div.text()).toContain('Dynamic Component PRE-LOADED')
}, 10000)
} finally {
await next.patchFile(componentPath, originalContent)
}
})
it('should update styles in a dynamically-imported client component via HMR', async () => {
const browser = await next.browser('/')
const cssPath = join('app', 'components', 'dynamic.module.css')
const originalCss = await next.readFile(cssPath)
try {
await retry(async () => {
const div = await browser.elementByCss('#dynamic-component')
expect(await div.text()).toContain('Dynamic Component')
})
// Verify initial style
await retry(async () => {
const color = await browser.eval(
`window.getComputedStyle(document.getElementById('dynamic-component')).color`
)
expect(color).toBe('rgb(255, 0, 0)')
})
const timeOrigin = await browser.eval('performance.timeOrigin')
await next.patchFile(
cssPath,
originalCss.replace('color: red', 'color: blue')
)
await retry(async () => {
const color = await browser.eval(
`window.getComputedStyle(document.getElementById('dynamic-component')).color`
)
expect(color).toBe('rgb(0, 0, 255)')
}, 10000)
// Ensure the update was via HMR and not a full reload
expect(await browser.eval('performance.timeOrigin')).toEqual(timeOrigin)
} finally {
await next.patchFile(cssPath, originalCss)
}
})
})
...@@ -184,11 +184,9 @@ export function runHotModuleReloadHmrTest(nextConfig: { ...@@ -184,11 +184,9 @@ export function runHotModuleReloadHmrTest(nextConfig: {
// Added because of a regression in react-hot-loader, see issues: #4246 #4273 // Added because of a regression in react-hot-loader, see issues: #4246 #4273
// Also: https://github.com/vercel/styled-jsx/issues/425 // Also: https://github.com/vercel/styled-jsx/issues/425
it('should update styles in a dynamic component correctly', async () => { it('should update styles in a dynamic component correctly', async () => {
const browser = await next.browser( const browser = await next.browser(basePath + '/hmr/dynamic-component')
basePath + '/hmr/style-dynamic-component'
)
const secondBrowser = await next.browser( const secondBrowser = await next.browser(
basePath + '/hmr/style-dynamic-component' basePath + '/hmr/dynamic-component'
) )
const pagePath = join('components', 'hmr', 'dynamic.js') const pagePath = join('components', 'hmr', 'dynamic.js')
const originalContent = await next.readFile(pagePath) const originalContent = await next.readFile(pagePath)
...@@ -200,12 +198,12 @@ export function runHotModuleReloadHmrTest(nextConfig: { ...@@ -200,12 +198,12 @@ export function runHotModuleReloadHmrTest(nextConfig: {
expect(initialFontSize).toBe('100px') expect(initialFontSize).toBe('100px')
const initialHtml = await next.render( const initialHtml = await next.render(
basePath + '/hmr/style-dynamic-component' basePath + '/hmr/dynamic-component'
) )
expect(initialHtml.includes('100px')).toBeTruthy() expect(initialHtml.includes('100px')).toBeTruthy()
const $initialHtml = await next.render$( const $initialHtml = await next.render$(
basePath + '/hmr/style-dynamic-component' basePath + '/hmr/dynamic-component'
) )
const initialServerClassName = const initialServerClassName =
$initialHtml('#dynamic-component').attr('class') $initialHtml('#dynamic-component').attr('class')
...@@ -233,11 +231,11 @@ export function runHotModuleReloadHmrTest(nextConfig: { ...@@ -233,11 +231,11 @@ export function runHotModuleReloadHmrTest(nextConfig: {
expect(browserHtml.includes('font-size:100px')).toBe(false) expect(browserHtml.includes('font-size:100px')).toBe(false)
const editedHtml = await next.render( const editedHtml = await next.render(
basePath + '/hmr/style-dynamic-component' basePath + '/hmr/dynamic-component'
) )
expect(editedHtml.includes('200px')).toBeTruthy() expect(editedHtml.includes('200px')).toBeTruthy()
const $editedHtml = await next.render$( const $editedHtml = await next.render$(
basePath + '/hmr/style-dynamic-component' basePath + '/hmr/dynamic-component'
) )
const editedServerClassName = const editedServerClassName =
$editedHtml('#dynamic-component').attr('class') $editedHtml('#dynamic-component').attr('class')
...@@ -250,6 +248,40 @@ export function runHotModuleReloadHmrTest(nextConfig: { ...@@ -250,6 +248,40 @@ export function runHotModuleReloadHmrTest(nextConfig: {
} }
}) })
it('should update text in a dynamic component correctly', async () => {
const browser = await next.browser(basePath + '/hmr/dynamic-component')
const pagePath = join('components', 'hmr', 'dynamic.js')
const originalContent = await next.readFile(pagePath)
try {
const div = await browser.elementByCss('#dynamic-component')
const initialText = await div.text()
expect(initialText).toContain('Dynamic Component')
const timeOrigin = await browser.eval('performance.timeOrigin')
const editedContent = originalContent.replace(
'Dynamic Component',
'Dynamic Component UPDATED'
)
// Change the component text
await next.patchFile(pagePath, editedContent)
// Wait for HMR to propagate the text update
await retry(async () => {
const editedDiv = await browser.elementByCss('#dynamic-component')
const editedText = await editedDiv.text()
expect(editedText).toContain('Dynamic Component UPDATED')
})
// Ensure the page was updated via HMR and not a full reload
expect(await browser.eval('performance.timeOrigin')).toEqual(timeOrigin)
} finally {
// Restore the original content
await next.patchFile(pagePath, originalContent)
}
})
it('should not full reload when nonlatin characters are used', async () => { it('should not full reload when nonlatin characters are used', async () => {
const browser = await next.browser(basePath + '/hmr/nonlatin') const browser = await next.browser(basePath + '/hmr/nonlatin')
const pagePath = join('pages', 'hmr', 'nonlatin.js') const pagePath = join('pages', 'hmr', 'nonlatin.js')
......
use anyhow::{Context, Result, bail}; use anyhow::{Context, Result, bail};
use tracing::Instrument; use tracing::Instrument;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{FxIndexMap, ResolvedVc, TaskInput, TryJoinIterExt, Upcast, ValueToString, Vc}; use turbo_tasks::{
FxIndexMap, FxIndexSet, ResolvedVc, TaskInput, TryJoinIterExt, Upcast, ValueToString, Vc,
};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbo_tasks_hash::HashAlgorithm; use turbo_tasks_hash::HashAlgorithm;
use turbopack_core::{ use turbopack_core::{
...@@ -23,7 +25,7 @@ use turbopack_core::{ ...@@ -23,7 +25,7 @@ use turbopack_core::{
binding_usage_info::{BindingUsageInfo, ModuleExportUsage}, binding_usage_info::{BindingUsageInfo, ModuleExportUsage},
chunk_group_info::ChunkGroup, chunk_group_info::ChunkGroup,
}, },
output::{OutputAsset, OutputAssets}, output::{ExpandOutputAssetsInput, OutputAsset, OutputAssets, expand_output_assets},
}; };
use turbopack_ecmascript::{ use turbopack_ecmascript::{
async_chunk::module::AsyncLoaderModule, async_chunk::module::AsyncLoaderModule,
...@@ -755,7 +757,6 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -755,7 +757,6 @@ impl ChunkingContext for BrowserChunkingContext {
) -> Result<Vc<ChunkGroupResult>> { ) -> Result<Vc<ChunkGroupResult>> {
let span = tracing::info_span!("chunking", name = display(ident.to_string().await?)); let span = tracing::info_span!("chunking", name = display(ident.to_string().await?));
async move { async move {
let this = self.await?;
let input_availability_info = availability_info; let input_availability_info = availability_info;
let MakeChunkGroupResult { let MakeChunkGroupResult {
chunks, chunks,
...@@ -771,37 +772,12 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -771,37 +772,12 @@ impl ChunkingContext for BrowserChunkingContext {
let chunks = chunks.await?; let chunks = chunks.await?;
let mut assets = chunks let assets = chunks
.iter() .iter()
.map(|chunk| self.generate_chunk(*chunk)) .map(|chunk| self.generate_chunk(*chunk))
.try_join() .try_join()
.await?; .await?;
if this.enable_hot_module_replacement {
let ident = if let Some(input_availability_info_ident) =
input_availability_info.ident().await?
{
ident
.owned()
.await?
.with_modifier(input_availability_info_ident)
.into_vc()
} else {
ident
};
let other_assets = Vc::cell(assets.clone());
assets.push(
self.generate_chunk_list_register_chunk(
ident,
EvaluatableAssets::empty(),
other_assets,
EcmascriptDevChunkListSource::Dynamic,
)
.to_resolved()
.await?,
);
}
Ok(ChunkGroupResult { Ok(ChunkGroupResult {
assets: ResolvedVc::cell(assets), assets: ResolvedVc::cell(assets),
referenced_assets: OutputAssets::empty_resolved(), referenced_assets: OutputAssets::empty_resolved(),
...@@ -820,6 +796,9 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -820,6 +796,9 @@ impl ChunkingContext for BrowserChunkingContext {
ident: Vc<AssetIdent>, ident: Vc<AssetIdent>,
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: ResolvedVc<ModuleGraph>, module_graph: ResolvedVc<ModuleGraph>,
// Extra chunks to include in the HMR chunk list beyond what is reachable from this chunk
// group. Used to cover RSC client reference chunks that are built separately.
extra_chunks: Vc<OutputAssets>,
input_availability_info: AvailabilityInfo, input_availability_info: AvailabilityInfo,
) -> Result<Vc<ChunkGroupResult>> { ) -> Result<Vc<ChunkGroupResult>> {
let span = tracing::info_span!( let span = tracing::info_span!(
...@@ -849,6 +828,10 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -849,6 +828,10 @@ impl ChunkingContext for BrowserChunkingContext {
.try_join() .try_join()
.await?; .await?;
// The evaluate chunk loads `other_assets` as `SourceType.Runtime` (without script
// tags), so it must contain only the directly-generated chunks for this chunk group.
// `extra_chunks` are loaded separately (already in the HTML), so excluding them here
// prevents the runtime from blocking on a load that will never happen.
let other_assets = Vc::cell(assets.clone()); let other_assets = Vc::cell(assets.clone());
let entries = Vc::cell( let entries = Vc::cell(
...@@ -862,6 +845,29 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -862,6 +845,29 @@ impl ChunkingContext for BrowserChunkingContext {
); );
if this.enable_hot_module_replacement { if this.enable_hot_module_replacement {
// Follow references (async loaders) to get actual dynamic component chunks, so
// the single HMR chunk list covers all lazily-loaded modules.
// inner=false: we only follow Reference inputs transitively, not Asset inputs,
// to avoid pulling in source maps and other asset-adjacent files that can't be
// reloaded by the DOM backend (which only handles CSS chunks via reloadChunk).
let all_dynamic_chunks = expand_output_assets(
references
.iter()
.copied()
.map(ExpandOutputAssetsInput::Reference)
.chain(assets.iter().copied().map(ExpandOutputAssetsInput::Asset)),
false,
)
.await?;
// Combine direct chunks, transitively-reachable dynamic chunks, and any caller-
// provided extras (e.g. RSC client reference chunks built outside this graph).
let extra_chunks_ref = extra_chunks.await?;
let mut hmr_chunks: FxIndexSet<ResolvedVc<Box<dyn OutputAsset>>> =
all_dynamic_chunks.into_iter().collect();
hmr_chunks.extend(extra_chunks_ref.iter().copied());
let hmr_other_assets = Vc::cell(hmr_chunks.into_iter().collect());
let ident = if let Some(input_availability_info_ident) = let ident = if let Some(input_availability_info_ident) =
input_availability_info.ident().await? input_availability_info.ident().await?
{ {
...@@ -877,7 +883,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -877,7 +883,7 @@ impl ChunkingContext for BrowserChunkingContext {
self.generate_chunk_list_register_chunk( self.generate_chunk_list_register_chunk(
ident, ident,
entries, entries,
other_assets, hmr_other_assets,
EcmascriptDevChunkListSource::Entry, EcmascriptDevChunkListSource::Entry,
) )
.to_resolved() .to_resolved()
...@@ -903,6 +909,31 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -903,6 +909,31 @@ impl ChunkingContext for BrowserChunkingContext {
.await .await
} }
#[turbo_tasks::function]
async fn hmr_chunk_list(
self: Vc<Self>,
ident: Vc<AssetIdent>,
chunks: Vc<OutputAssets>,
) -> Result<Vc<OutputAssets>> {
let this = self.await?;
if !this.enable_hot_module_replacement {
unreachable!("hmr_chunk_list called with enable_hot_module_replacement disabled");
}
if chunks.await?.is_empty() {
return Ok(OutputAssets::empty());
}
Ok(Vc::cell(vec![
self.generate_chunk_list_register_chunk(
ident,
EvaluatableAssets::empty(),
chunks,
EcmascriptDevChunkListSource::Entry,
)
.to_resolved()
.await?,
]))
}
#[turbo_tasks::function] #[turbo_tasks::function]
fn entry_chunk_group( fn entry_chunk_group(
self: Vc<Self>, self: Vc<Self>,
......
...@@ -459,6 +459,7 @@ async fn build_internal( ...@@ -459,6 +459,7 @@ async fn build_internal(
[ResolvedVc::upcast(ecmascript)].into_iter().collect(), [ResolvedVc::upcast(ecmascript)].into_iter().collect(),
), ),
module_graph, module_graph,
OutputAssets::empty(),
AvailabilityInfo::root(), AvailabilityInfo::root(),
), ),
Target::Node => OutputAssetsWithReferenced { Target::Node => OutputAssetsWithReferenced {
......
...@@ -433,15 +433,38 @@ pub trait ChunkingContext { ...@@ -433,15 +433,38 @@ pub trait ChunkingContext {
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<ChunkGroupResult>; ) -> Vc<ChunkGroupResult>;
/// Like [`Self::chunk_group`], but additionally produces an evaluate chunk
/// (and, in dev, a chunk-list register chunk) that bootstraps and runs
/// `chunk_group`'s entries.
///
/// `extra_chunks` are not part of this chunk group's module graph, but they
/// are loaded alongside the entries (and tracked in the chunk-list register
/// chunk for HMR) — used to extend the entry's HMR-tracked chunks with
/// chunks computed elsewhere (e.g. app-router client references).
#[turbo_tasks::function] #[turbo_tasks::function]
fn evaluated_chunk_group( fn evaluated_chunk_group(
self: Vc<Self>, self: Vc<Self>,
ident: Vc<AssetIdent>, ident: Vc<AssetIdent>,
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
extra_chunks: Vc<OutputAssets>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<ChunkGroupResult>; ) -> Vc<ChunkGroupResult>;
/// In development, produces a standalone HMR chunk-list register chunk
/// that tracks `chunks` for hot-module-replacement without producing an
/// evaluate chunk. Returns `None` (empty vec) outside dev or when HMR is
/// disabled. Used to register a page-specific chunk list that covers
/// client-reference chunks built outside the shared module graph.
#[turbo_tasks::function]
fn hmr_chunk_list(
self: Vc<Self>,
_ident: Vc<AssetIdent>,
_chunks: Vc<OutputAssets>,
) -> Vc<OutputAssets> {
OutputAssets::empty()
}
/// Generates an output chunk that: /// Generates an output chunk that:
/// * loads the given extra_chunks in addition to the generated chunks; and /// * loads the given extra_chunks in addition to the generated chunks; and
/// * evaluates the given assets; and /// * evaluates the given assets; and
...@@ -511,6 +534,7 @@ pub trait ChunkingContextExt { ...@@ -511,6 +534,7 @@ pub trait ChunkingContextExt {
ident: Vc<AssetIdent>, ident: Vc<AssetIdent>,
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
extra_chunks: Vc<OutputAssets>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<OutputAssetsWithReferenced> ) -> Vc<OutputAssetsWithReferenced>
where where
...@@ -597,6 +621,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -597,6 +621,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte
ident: Vc<AssetIdent>, ident: Vc<AssetIdent>,
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
extra_chunks: Vc<OutputAssets>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<OutputAssetsWithReferenced> { ) -> Vc<OutputAssetsWithReferenced> {
evaluated_chunk_group_assets( evaluated_chunk_group_assets(
...@@ -604,6 +629,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -604,6 +629,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte
ident, ident,
chunk_group, chunk_group,
module_graph, module_graph,
extra_chunks,
availability_info, availability_info,
) )
} }
...@@ -745,10 +771,17 @@ fn evaluated_chunk_group_assets( ...@@ -745,10 +771,17 @@ fn evaluated_chunk_group_assets(
ident: Vc<AssetIdent>, ident: Vc<AssetIdent>,
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
extra_chunks: Vc<OutputAssets>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<OutputAssetsWithReferenced> { ) -> Vc<OutputAssetsWithReferenced> {
chunking_context chunking_context
.evaluated_chunk_group(ident, chunk_group, module_graph, availability_info) .evaluated_chunk_group(
ident,
chunk_group,
module_graph,
extra_chunks,
availability_info,
)
.output_assets_with_referenced() .output_assets_with_referenced()
} }
......
...@@ -15,7 +15,7 @@ use turbopack_core::{ ...@@ -15,7 +15,7 @@ use turbopack_core::{
}, },
module::Module, module::Module,
module_graph::{ModuleGraph, chunk_group_info::ChunkGroup}, module_graph::{ModuleGraph, chunk_group_info::ChunkGroup},
output::{OutputAsset, OutputAssetsReference, OutputAssetsWithReferenced}, output::{OutputAsset, OutputAssets, OutputAssetsReference, OutputAssetsWithReferenced},
version::{Version, VersionedContent}, version::{Version, VersionedContent},
}; };
...@@ -163,6 +163,7 @@ impl DevHtmlAsset { ...@@ -163,6 +163,7 @@ impl DevHtmlAsset {
.collect(), .collect(),
), ),
*module_graph, *module_graph,
OutputAssets::empty(),
AvailabilityInfo::root(), AvailabilityInfo::root(),
) )
.await? .await?
......
...@@ -72,6 +72,7 @@ impl WorkerLoaderModule { ...@@ -72,6 +72,7 @@ impl WorkerLoaderModule {
ident, ident,
ChunkGroup::Isolated(ResolvedVc::upcast(this.inner)), ChunkGroup::Isolated(ResolvedVc::upcast(this.inner)),
module_graph, module_graph,
OutputAssets::empty(),
AvailabilityInfo::root(), AvailabilityInfo::root(),
) )
} }
......
...@@ -634,6 +634,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -634,6 +634,7 @@ impl ChunkingContext for NodeJsChunkingContext {
_ident: Vc<AssetIdent>, _ident: Vc<AssetIdent>,
_chunk_group: ChunkGroup, _chunk_group: ChunkGroup,
_module_graph: Vc<ModuleGraph>, _module_graph: Vc<ModuleGraph>,
_extra_chunks: Vc<OutputAssets>,
_availability_info: AvailabilityInfo, _availability_info: AvailabilityInfo,
) -> Result<Vc<ChunkGroupResult>> { ) -> Result<Vc<ChunkGroupResult>> {
bail!("the Node.js chunking context does not support evaluated chunk groups") bail!("the Node.js chunking context does not support evaluated chunk groups")
......
...@@ -589,6 +589,7 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> { ...@@ -589,6 +589,7 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
entry_module.ident(), entry_module.ident(),
ChunkGroup::Entry(entry_modules.into_iter().collect()), ChunkGroup::Entry(entry_modules.into_iter().collect()),
module_graph, module_graph,
OutputAssets::empty(),
AvailabilityInfo::root(), AvailabilityInfo::root(),
), ),
Runtime::NodeJs => { Runtime::NodeJs => {
......
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