From 4597ff35da282f19fbf6a8257b09162ce60314b3 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 17 Jan 2024 08:58:02 +0100 Subject: [PATCH] allow to pass available chunk items when creating a chunk group (#60554) ### What? api changes for https://github.com/vercel/turbo/pull/6988 ### Turbopack Changes * https://github.com/vercel/turbo/pull/6886 * https://github.com/vercel/turbo/pull/6866 * https://github.com/vercel/turbo/pull/6988 * https://github.com/vercel/turbo/pull/7013 * https://github.com/vercel/turbo/pull/7004 Closes PACK-2231 --- Cargo.lock | 69 ++++++++++--------- Cargo.toml | 6 +- packages/next-swc/crates/next-api/src/app.rs | 14 ++-- .../crates/next-api/src/dynamic_imports.rs | 10 ++- .../crates/next-api/src/instrumentation.rs | 33 +++++---- .../crates/next-api/src/middleware.rs | 9 ++- .../next-swc/crates/next-api/src/pages.rs | 26 ++++--- .../next_app/app_client_references_chunks.rs | 14 ++-- .../src/next_app/app_client_shared_chunks.rs | 11 +-- .../src/next_dynamic/dynamic_module.rs | 2 +- packages/next/package.json | 2 +- pnpm-lock.yaml | 10 +-- 12 files changed, 119 insertions(+), 87 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 63741ce01c..c4949656df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -321,7 +321,7 @@ dependencies = [ [[package]] name = "auto-hash-map" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "serde", "smallvec", @@ -3497,7 +3497,7 @@ dependencies = [ [[package]] name = "node-file-trace" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "serde", @@ -7537,7 +7537,7 @@ dependencies = [ [[package]] name = "turbo-tasks" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "async-trait", @@ -7569,7 +7569,7 @@ dependencies = [ [[package]] name = "turbo-tasks-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "cargo-lock", @@ -7581,7 +7581,7 @@ dependencies = [ [[package]] name = "turbo-tasks-bytes" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "bytes", @@ -7596,7 +7596,7 @@ dependencies = [ [[package]] name = "turbo-tasks-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "dotenvs", @@ -7610,7 +7610,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fetch" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7627,7 +7627,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fs" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "auto-hash-map", @@ -7658,7 +7658,7 @@ dependencies = [ [[package]] name = "turbo-tasks-hash" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "base16", "hex", @@ -7670,7 +7670,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -7684,7 +7684,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros-shared" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "proc-macro2", "quote", @@ -7694,7 +7694,7 @@ dependencies = [ [[package]] name = "turbo-tasks-malloc" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "mimalloc", ] @@ -7702,7 +7702,7 @@ dependencies = [ [[package]] name = "turbo-tasks-memory" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "auto-hash-map", @@ -7727,7 +7727,7 @@ dependencies = [ [[package]] name = "turbopack" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "async-recursion", @@ -7759,7 +7759,7 @@ dependencies = [ [[package]] name = "turbopack-binding" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "auto-hash-map", "mdxjs", @@ -7800,7 +7800,7 @@ dependencies = [ [[package]] name = "turbopack-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7824,7 +7824,7 @@ dependencies = [ [[package]] name = "turbopack-cli-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "clap 4.4.2", @@ -7842,7 +7842,7 @@ dependencies = [ [[package]] name = "turbopack-core" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "async-recursion", @@ -7872,7 +7872,7 @@ dependencies = [ [[package]] name = "turbopack-css" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "async-trait", @@ -7899,7 +7899,7 @@ dependencies = [ [[package]] name = "turbopack-dev" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7923,7 +7923,7 @@ dependencies = [ [[package]] name = "turbopack-dev-server" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "async-compression", @@ -7960,7 +7960,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "async-trait", @@ -7995,7 +7995,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-hmr-protocol" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "serde", "serde_json", @@ -8006,7 +8006,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-plugins" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "async-trait", @@ -8029,7 +8029,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-runtime" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "indoc", @@ -8046,7 +8046,7 @@ dependencies = [ [[package]] name = "turbopack-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -8062,7 +8062,7 @@ dependencies = [ [[package]] name = "turbopack-image" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "base64 0.21.4", @@ -8082,7 +8082,7 @@ dependencies = [ [[package]] name = "turbopack-json" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "serde", @@ -8097,7 +8097,7 @@ dependencies = [ [[package]] name = "turbopack-mdx" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "mdxjs", @@ -8112,7 +8112,7 @@ dependencies = [ [[package]] name = "turbopack-node" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "async-stream", @@ -8147,7 +8147,7 @@ dependencies = [ [[package]] name = "turbopack-static" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "serde", @@ -8163,7 +8163,7 @@ dependencies = [ [[package]] name = "turbopack-swc-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "swc_core", "turbo-tasks", @@ -8174,7 +8174,7 @@ dependencies = [ [[package]] name = "turbopack-trace-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "crossbeam-channel", @@ -8184,12 +8184,13 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", + "turbo-tasks-malloc", ] [[package]] name = "turbopack-wasm" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240110.4#35ade4e85b17a076fb4e6287e519c26b087d0bef" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240117.1#145d71b0a0e4ddaffda006a07eccc55e33aad75e" dependencies = [ "anyhow", "indexmap 1.9.3", diff --git a/Cargo.toml b/Cargo.toml index d60946f797..23d31e5c05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,11 +37,11 @@ swc_core = { version = "0.87.16", features = [ testing = { version = "0.35.14" } # Turbo crates -turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240110.4" } +turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240117.1" } # [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros.. -turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240110.4" } +turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240117.1" } # [TODO]: need to refactor embed_directory! macro usage in next-core -turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240110.4" } +turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240117.1" } # General Deps diff --git a/packages/next-swc/crates/next-api/src/app.rs b/packages/next-swc/crates/next-api/src/app.rs index d0878e6666..c31b1c31aa 100644 --- a/packages/next-swc/crates/next-api/src/app.rs +++ b/packages/next-swc/crates/next-api/src/app.rs @@ -44,9 +44,10 @@ use turbopack_binding::{ tasks_fs::{rope::RopeBuilder, File, FileContent, FileSystemPath}, }, turbopack::{ + build::EntryChunkGroupResult, core::{ asset::{Asset, AssetContent}, - chunk::{availability_info::AvailabilityInfo, ChunkingContext, EvaluatableAssets}, + chunk::{availability_info::AvailabilityInfo, ChunkingContextExt, EvaluatableAssets}, file_source::FileSource, module::Module, output::{OutputAsset, OutputAssets}, @@ -844,9 +845,10 @@ impl AppEndpoint { server_assets.push(manifest); evaluatable_assets.push(loader); - let files = chunking_context.evaluated_chunk_group( + let files = chunking_context.evaluated_chunk_group_assets( app_entry.rsc_entry.ident(), Vc::cell(evaluatable_assets.clone()), + Value::new(AvailabilityInfo::Root), ); let files_value = files.await?; @@ -976,7 +978,9 @@ impl AppEndpoint { server_assets.push(manifest); evaluatable_assets.push(loader); - let rsc_chunk = this + let EntryChunkGroupResult { + asset: rsc_chunk, .. + } = *this .app_project .project() .server_chunking_context() @@ -987,7 +991,9 @@ impl AppEndpoint { )), app_entry.rsc_entry, Vc::cell(evaluatable_assets), - ); + Value::new(AvailabilityInfo::Root), + ) + .await?; server_assets.push(rsc_chunk); let app_paths_manifest_output = create_app_paths_manifest( diff --git a/packages/next-swc/crates/next-api/src/dynamic_imports.rs b/packages/next-swc/crates/next-api/src/dynamic_imports.rs index fc93fc3a6d..72c934e2ac 100644 --- a/packages/next-swc/crates/next-api/src/dynamic_imports.rs +++ b/packages/next-swc/crates/next-api/src/dynamic_imports.rs @@ -15,7 +15,7 @@ use turbopack_binding::{ build::BuildChunkingContext, core::{ chunk::{ - availability_info::AvailabilityInfo, ChunkableModule, ChunkingContext, + availability_info::AvailabilityInfo, ChunkableModule, ChunkingContextExt, EvaluatableAssets, }, issue::IssueSeverity, @@ -84,7 +84,7 @@ pub(crate) async fn collect_chunk_group( availability_info: Value, ) -> Result> { collect_chunk_group_inner(dynamic_import_entries, |chunk_item| { - chunking_context.chunk_group(chunk_item, availability_info) + chunking_context.chunk_group_assets(chunk_item, availability_info) }) .await } @@ -95,7 +95,11 @@ pub(crate) async fn collect_evaluated_chunk_group( evaluatable_assets: Vc, ) -> Result> { collect_chunk_group_inner(dynamic_import_entries, |chunk_item| { - chunking_context.evaluated_chunk_group(chunk_item.ident(), evaluatable_assets) + chunking_context.evaluated_chunk_group_assets( + chunk_item.ident(), + evaluatable_assets, + Value::new(AvailabilityInfo::Root), + ) }) .await } diff --git a/packages/next-swc/crates/next-api/src/instrumentation.rs b/packages/next-swc/crates/next-api/src/instrumentation.rs index 97df566479..03912741f6 100644 --- a/packages/next-swc/crates/next-api/src/instrumentation.rs +++ b/packages/next-swc/crates/next-api/src/instrumentation.rs @@ -11,9 +11,10 @@ use turbo_tasks::{Completion, Value, Vc}; use turbopack_binding::{ turbo::tasks_fs::{File, FileContent}, turbopack::{ + build::EntryChunkGroupResult, core::{ asset::AssetContent, - chunk::ChunkingContext, + chunk::{availability_info::AvailabilityInfo, ChunkingContextExt}, context::AssetContext, module::Module, output::{OutputAsset, OutputAssets}, @@ -96,8 +97,11 @@ impl InstrumentationEndpoint { let edge_chunking_context = self.project.edge_chunking_context(); - let edge_files = edge_chunking_context - .evaluated_chunk_group(module.ident(), Vc::cell(evaluatable_assets)); + let edge_files = edge_chunking_context.evaluated_chunk_group_assets( + module.ident(), + Vc::cell(evaluatable_assets), + Value::new(AvailabilityInfo::Root), + ); Ok(edge_files) } @@ -124,17 +128,20 @@ impl InstrumentationEndpoint { bail!("Entry module must be evaluatable"); }; - let chunk = chunking_context.entry_chunk_group( - self.project - .node_root() - .join("server/instrumentation.js".to_string()), - module, - get_server_runtime_entries( - Value::new(ServerContextType::Instrumentation), - NextMode::Development, + let EntryChunkGroupResult { asset: chunk, .. } = *chunking_context + .entry_chunk_group( + self.project + .node_root() + .join("server/instrumentation.js".to_string()), + module, + get_server_runtime_entries( + Value::new(ServerContextType::Instrumentation), + NextMode::Development, + ) + .resolve_entries(self.context), + Value::new(AvailabilityInfo::Root), ) - .resolve_entries(self.context), - ); + .await?; Ok(chunk) } diff --git a/packages/next-swc/crates/next-api/src/middleware.rs b/packages/next-swc/crates/next-api/src/middleware.rs index 8472b4876f..b65aea3e5d 100644 --- a/packages/next-swc/crates/next-api/src/middleware.rs +++ b/packages/next-swc/crates/next-api/src/middleware.rs @@ -17,7 +17,7 @@ use turbopack_binding::{ turbopack::{ core::{ asset::AssetContent, - chunk::ChunkingContext, + chunk::{availability_info::AvailabilityInfo, ChunkingContextExt}, context::AssetContext, module::Module, output::{OutputAsset, OutputAssets}, @@ -99,8 +99,11 @@ impl MiddlewareEndpoint { let edge_chunking_context = self.project.edge_chunking_context(); - let edge_files = edge_chunking_context - .evaluated_chunk_group(module.ident(), Vc::cell(evaluatable_assets)); + let edge_files = edge_chunking_context.evaluated_chunk_group_assets( + module.ident(), + Vc::cell(evaluatable_assets), + Value::new(AvailabilityInfo::Root), + ); Ok(edge_files) } diff --git a/packages/next-swc/crates/next-api/src/pages.rs b/packages/next-swc/crates/next-api/src/pages.rs index 84c8bfd794..fa55888ef2 100644 --- a/packages/next-swc/crates/next-api/src/pages.rs +++ b/packages/next-swc/crates/next-api/src/pages.rs @@ -37,10 +37,10 @@ use turbopack_binding::{ File, FileContent, FileSystem, FileSystemPath, FileSystemPathOption, VirtualFileSystem, }, turbopack::{ - build::BuildChunkingContext, + build::{BuildChunkingContext, EntryChunkGroupResult}, core::{ asset::AssetContent, - chunk::{availability_info::AvailabilityInfo, ChunkingContext, EvaluatableAssets}, + chunk::{availability_info::AvailabilityInfo, ChunkingContextExt, EvaluatableAssets}, context::AssetContext, file_source::FileSource, issue::IssueSeverity, @@ -606,12 +606,13 @@ impl PageEndpoint { let client_chunking_context = this.pages_project.project().client_chunking_context(); let mut client_chunks = client_chunking_context - .evaluated_chunk_group( + .evaluated_chunk_group_assets( client_module.ident(), this.pages_project .client_runtime_entries() .with_entry(Vc::upcast(client_main_module)) .with_entry(Vc::upcast(client_module)), + Value::new(AvailabilityInfo::Root), ) .await? .clone_value(); @@ -670,9 +671,10 @@ impl PageEndpoint { .context("could not process page loader entry module")?; evaluatable_assets.push(evaluatable); - let edge_files = edge_chunking_context.evaluated_chunk_group( + let edge_files = edge_chunking_context.evaluated_chunk_group_assets( ssr_module.ident(), Vc::cell(evaluatable_assets.clone()), + Value::new(AvailabilityInfo::Root), ); let dynamic_import_modules = collect_next_dynamic_imports(ssr_module).await?; @@ -704,11 +706,17 @@ impl PageEndpoint { let ssr_entry_chunk_path_string = format!("pages{asset_path}"); let ssr_entry_chunk_path = node_path.join(ssr_entry_chunk_path_string); - let ssr_entry_chunk = chunking_context.entry_chunk_group( - ssr_entry_chunk_path, - ssr_module, - runtime_entries, - ); + let EntryChunkGroupResult { + asset: ssr_entry_chunk, + .. + } = *chunking_context + .entry_chunk_group( + ssr_entry_chunk_path, + ssr_module, + runtime_entries, + Value::new(AvailabilityInfo::Root), + ) + .await?; let availability_info = Value::new(AvailabilityInfo::Root); let dynamic_import_modules = collect_next_dynamic_imports(ssr_module).await?; diff --git a/packages/next-swc/crates/next-core/src/next_app/app_client_references_chunks.rs b/packages/next-swc/crates/next-core/src/next_app/app_client_references_chunks.rs index 2ba5f811ca..abf78766e6 100644 --- a/packages/next-swc/crates/next-core/src/next_app/app_client_references_chunks.rs +++ b/packages/next-swc/crates/next-core/src/next_app/app_client_references_chunks.rs @@ -55,18 +55,18 @@ pub async fn get_app_client_references_chunks( let ecmascript_client_reference_ref = ecmascript_client_reference.await?; ClientReferenceChunks { - client_chunks: client_chunking_context.root_chunk_group( + client_chunks: client_chunking_context.root_chunk_group_assets( Vc::upcast(ecmascript_client_reference_ref.client_module), ), - ssr_chunks: ssr_chunking_context.root_chunk_group(Vc::upcast( - ecmascript_client_reference_ref.ssr_module, - )), + ssr_chunks: ssr_chunking_context.root_chunk_group_assets( + Vc::upcast(ecmascript_client_reference_ref.ssr_module), + ), } } ClientReferenceType::CssClientReference(css_client_reference) => { let css_client_reference_ref = css_client_reference.await?; ClientReferenceChunks { - client_chunks: client_chunking_context.root_chunk_group( + client_chunks: client_chunking_context.root_chunk_group_assets( Vc::upcast(css_client_reference_ref.client_module), ), ssr_chunks: OutputAssets::empty(), @@ -128,11 +128,11 @@ pub async fn get_app_client_references_chunks( let global_entry_module = ClientReferenceChunks { client_chunks: { let _span = tracing::info_span!("client side rendering").entered(); - client_chunking_context.root_chunk_group(Vc::upcast(client_entry_module)) + client_chunking_context.root_chunk_group_assets(Vc::upcast(client_entry_module)) }, ssr_chunks: { let _span = tracing::info_span!("server side rendering").entered(); - ssr_chunking_context.root_chunk_group(Vc::upcast(ssr_entry_module)) + ssr_chunking_context.root_chunk_group_assets(Vc::upcast(ssr_entry_module)) }, }; diff --git a/packages/next-swc/crates/next-core/src/next_app/app_client_shared_chunks.rs b/packages/next-swc/crates/next-core/src/next_app/app_client_shared_chunks.rs index e7e2881816..4dbccf7f05 100644 --- a/packages/next-swc/crates/next-core/src/next_app/app_client_shared_chunks.rs +++ b/packages/next-swc/crates/next-core/src/next_app/app_client_shared_chunks.rs @@ -1,8 +1,8 @@ use anyhow::Result; -use turbo_tasks::Vc; +use turbo_tasks::{Value, Vc}; use turbopack_binding::turbopack::{ core::{ - chunk::{ChunkingContext, EvaluatableAssets}, + chunk::{availability_info::AvailabilityInfo, ChunkingContextExt, EvaluatableAssets}, ident::AssetIdent, output::OutputAssets, }, @@ -19,8 +19,11 @@ pub async fn get_app_client_shared_chunks( return Ok(OutputAssets::empty()); } - let app_client_shared_chunks = - client_chunking_context.evaluated_chunk_group(ident, app_client_runtime_entries); + let app_client_shared_chunks = client_chunking_context.evaluated_chunk_group_assets( + ident, + app_client_runtime_entries, + Value::new(AvailabilityInfo::Root), + ); Ok(app_client_shared_chunks) } diff --git a/packages/next-swc/crates/next-core/src/next_dynamic/dynamic_module.rs b/packages/next-swc/crates/next-core/src/next_dynamic/dynamic_module.rs index 8e20f4c4da..8ecd68fe40 100644 --- a/packages/next-swc/crates/next-core/src/next_dynamic/dynamic_module.rs +++ b/packages/next-swc/crates/next-core/src/next_dynamic/dynamic_module.rs @@ -41,7 +41,7 @@ impl NextDynamicEntryModule { bail!("dynamic client asset must be chunkable"); }; - Ok(client_chunking_context.root_chunk_group(client_entry_module)) + Ok(client_chunking_context.root_chunk_group_assets(client_entry_module)) } } diff --git a/packages/next/package.json b/packages/next/package.json index 0157fb5b4d..74bd2af94c 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -194,7 +194,7 @@ "@types/ws": "8.2.0", "@vercel/ncc": "0.34.0", "@vercel/nft": "0.26.2", - "@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240110.4", + "@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.1", "acorn": "8.5.0", "amphtml-validator": "1.0.35", "anser": "1.4.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 17e98fc252..eefa4a48de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1077,8 +1077,8 @@ importers: specifier: 0.26.2 version: 0.26.2 '@vercel/turbopack-ecmascript-runtime': - specifier: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240110.4 - version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240110.4(react-refresh@0.12.0)(webpack@5.86.0)' + specifier: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.1 + version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.1(react-refresh@0.12.0)(webpack@5.86.0)' acorn: specifier: 8.5.0 version: 8.5.0 @@ -25649,9 +25649,9 @@ packages: /zwitch@2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} - '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240110.4(react-refresh@0.12.0)(webpack@5.86.0)': - resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240110.4} - id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240110.4' + '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.1(react-refresh@0.12.0)(webpack@5.86.0)': + resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.1} + id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240117.1' name: '@vercel/turbopack-ecmascript-runtime' version: 0.0.0 dependencies: