From 04bad16bf4165809a83801c5b64a4ed8466acf41 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 13 Oct 2023 13:44:44 +0200 Subject: [PATCH] Turbopack: Chunking Refactoring (#56756) ### What? see https://github.com/vercel/turbo/pull/6160 ### Turbopack Changes * https://github.com/vercel/turbo/pull/6116 * https://github.com/vercel/turbo/pull/6140 * https://github.com/vercel/turbo/pull/6118 * https://github.com/vercel/turbo/pull/6128 * https://github.com/vercel/turbo/pull/6129 * https://github.com/vercel/turbo/pull/6160 Closes WEB-1772 Co-authored-by: Justin Ridgewell <112982+jridgewell@users.noreply.github.com> --- Cargo.lock | 68 ++++++++++--------- Cargo.toml | 6 +- packages/next-swc/crates/next-api/src/app.rs | 2 +- .../next-swc/crates/next-api/src/pages.rs | 7 +- .../next-build/src/next_app/app_entries.rs | 2 +- .../next-build/src/next_pages/page_entries.rs | 2 +- packages/next-swc/crates/next-core/Cargo.toml | 1 + .../crates/next-core/src/loader_tree.rs | 1 - .../with_client_chunks.rs | 10 +-- ...cmascript_client_reference_proxy_module.rs | 11 ++- .../server_component_reference.rs | 13 +--- packages/next/package.json | 2 +- pnpm-lock.yaml | 10 +-- test/build-turbopack-tests-manifest.js | 5 ++ .../__snapshots__/next-rs-api.test.ts.snap | 8 +++ .../integration/draft-mode/test/index.test.ts | 2 +- .../test/externals.test.js | 17 ++--- .../test/index.test.js | 2 +- .../prerender-preview/test/index.test.js | 2 +- test/turbopack-tests-manifest.json | 9 +-- 20 files changed, 91 insertions(+), 89 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4bfb6d1d07ea9..11129102795da 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-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "serde", "smallvec", @@ -3424,6 +3424,7 @@ dependencies = [ "serde_json", "swc_core", "thiserror", + "tracing", "turbo-tasks", "turbo-tasks-fs", "turbopack-binding", @@ -3515,7 +3516,7 @@ dependencies = [ [[package]] name = "node-file-trace" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "serde", @@ -7368,7 +7369,7 @@ dependencies = [ [[package]] name = "turbo-tasks" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "async-trait", @@ -7400,7 +7401,7 @@ dependencies = [ [[package]] name = "turbo-tasks-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "cargo-lock", @@ -7412,7 +7413,7 @@ dependencies = [ [[package]] name = "turbo-tasks-bytes" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "bytes", @@ -7427,7 +7428,7 @@ dependencies = [ [[package]] name = "turbo-tasks-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "dotenvs", @@ -7441,7 +7442,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fetch" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7458,7 +7459,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fs" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "auto-hash-map", @@ -7488,7 +7489,7 @@ dependencies = [ [[package]] name = "turbo-tasks-hash" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "base16", "hex", @@ -7500,7 +7501,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -7514,7 +7515,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros-shared" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "proc-macro2", "quote", @@ -7524,7 +7525,7 @@ dependencies = [ [[package]] name = "turbo-tasks-malloc" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "mimalloc", ] @@ -7532,7 +7533,7 @@ dependencies = [ [[package]] name = "turbo-tasks-memory" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "auto-hash-map", @@ -7557,7 +7558,7 @@ dependencies = [ [[package]] name = "turbopack" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "async-recursion", @@ -7588,7 +7589,7 @@ dependencies = [ [[package]] name = "turbopack-binding" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "auto-hash-map", "mdxjs", @@ -7628,7 +7629,7 @@ dependencies = [ [[package]] name = "turbopack-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7650,7 +7651,7 @@ dependencies = [ [[package]] name = "turbopack-cli-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "clap 4.4.2", @@ -7674,7 +7675,7 @@ dependencies = [ [[package]] name = "turbopack-core" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "async-recursion", @@ -7684,6 +7685,7 @@ dependencies = [ "futures", "indexmap 1.9.3", "lazy_static", + "once_cell", "patricia_tree", "qstring", "regex", @@ -7703,7 +7705,7 @@ dependencies = [ [[package]] name = "turbopack-css" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "async-trait", @@ -7725,7 +7727,7 @@ dependencies = [ [[package]] name = "turbopack-dev" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7749,7 +7751,7 @@ dependencies = [ [[package]] name = "turbopack-dev-server" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "async-compression", @@ -7786,7 +7788,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "async-trait", @@ -7820,7 +7822,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-hmr-protocol" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "serde", "serde_json", @@ -7831,7 +7833,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-plugins" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "async-trait", @@ -7854,7 +7856,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-runtime" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "indoc", @@ -7871,7 +7873,7 @@ dependencies = [ [[package]] name = "turbopack-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7887,7 +7889,7 @@ dependencies = [ [[package]] name = "turbopack-image" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "base64 0.21.4", @@ -7907,7 +7909,7 @@ dependencies = [ [[package]] name = "turbopack-json" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "serde", @@ -7922,7 +7924,7 @@ dependencies = [ [[package]] name = "turbopack-mdx" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "mdxjs", @@ -7937,7 +7939,7 @@ dependencies = [ [[package]] name = "turbopack-node" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "async-stream", @@ -7972,7 +7974,7 @@ dependencies = [ [[package]] name = "turbopack-static" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "serde", @@ -7988,7 +7990,7 @@ dependencies = [ [[package]] name = "turbopack-swc-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "swc_core", "turbo-tasks", @@ -7999,7 +8001,7 @@ dependencies = [ [[package]] name = "turbopack-wasm" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231006.4#8439948663a049728a48386cf4791693e264260e" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" dependencies = [ "anyhow", "indexmap 1.9.3", diff --git a/Cargo.toml b/Cargo.toml index 173a6453b4167..465220a2c2bd3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,11 +40,11 @@ swc_core = { version = "0.83.28", features = [ testing = { version = "0.34.1" } # Turbo crates -turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231006.4" } +turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231013.2" } # [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-231006.4" } +turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231013.2" } # [TODO]: need to refactor embed_directory! macro usage in next-core -turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231006.4" } +turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231013.2" } # 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 1b0684d6746d2..d1d64e41303b5 100644 --- a/packages/next-swc/crates/next-api/src/app.rs +++ b/packages/next-swc/crates/next-api/src/app.rs @@ -834,7 +834,7 @@ impl AppEndpoint { .app_project .project() .rsc_chunking_context() - .entry_chunk( + .entry_chunk_group( server_path.join(format!( "app{original_name}.js", original_name = app_entry.original_name diff --git a/packages/next-swc/crates/next-api/src/pages.rs b/packages/next-swc/crates/next-api/src/pages.rs index 8d8f6705e8b15..3754a4cce1b96 100644 --- a/packages/next-swc/crates/next-api/src/pages.rs +++ b/packages/next-swc/crates/next-api/src/pages.rs @@ -629,8 +629,11 @@ 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(ssr_entry_chunk_path, ssr_module, runtime_entries); + let ssr_entry_chunk = chunking_context.entry_chunk_group( + ssr_entry_chunk_path, + ssr_module, + runtime_entries, + ); Ok(SsrChunk::NodeJs { entry: ssr_entry_chunk, diff --git a/packages/next-swc/crates/next-build/src/next_app/app_entries.rs b/packages/next-swc/crates/next-build/src/next_app/app_entries.rs index e8a05d1a86260..c1d04ff2bf752 100644 --- a/packages/next-swc/crates/next-build/src/next_app/app_entries.rs +++ b/packages/next-swc/crates/next-build/src/next_app/app_entries.rs @@ -291,7 +291,7 @@ pub async fn compute_app_entries_chunks( .entry(Vc::upcast(app_entry.rsc_entry)) .await?; - let rsc_chunk = rsc_chunking_context.entry_chunk( + let rsc_chunk = rsc_chunking_context.entry_chunk_group( node_root.join(format!( "server/app/{original_name}.js", original_name = app_entry.original_name diff --git a/packages/next-swc/crates/next-build/src/next_pages/page_entries.rs b/packages/next-swc/crates/next-build/src/next_pages/page_entries.rs index 0b183f7e535ef..2fad04e0ae0da 100644 --- a/packages/next-swc/crates/next-build/src/next_pages/page_entries.rs +++ b/packages/next-swc/crates/next-build/src/next_pages/page_entries.rs @@ -387,7 +387,7 @@ pub async fn compute_page_entries_chunks( let pathname = page_entry.pathname.await?; let asset_path: String = get_asset_path_from_pathname(&pathname, ".js"); - let ssr_entry_chunk = ssr_chunking_context.entry_chunk( + let ssr_entry_chunk = ssr_chunking_context.entry_chunk_group( node_root.join(format!("server/pages/{asset_path}")), Vc::upcast(page_entry.ssr_module), page_entries.ssr_runtime_entries, diff --git a/packages/next-swc/crates/next-core/Cargo.toml b/packages/next-swc/crates/next-core/Cargo.toml index bcd6f3c1ebb51..16606e9a9bac0 100644 --- a/packages/next-swc/crates/next-core/Cargo.toml +++ b/packages/next-swc/crates/next-core/Cargo.toml @@ -29,6 +29,7 @@ allsorts = { workspace = true } futures = { workspace = true } lazy_static = { workspace = true } thiserror = { workspace = true } +tracing = { workspace = true } turbopack-binding = { workspace = true, features = [ "__swc_transform_modularize_imports", "__swc_transform_relay", diff --git a/packages/next-swc/crates/next-core/src/loader_tree.rs b/packages/next-swc/crates/next-core/src/loader_tree.rs index 492231448a522..90a58f207778f 100644 --- a/packages/next-swc/crates/next-core/src/loader_tree.rs +++ b/packages/next-swc/crates/next-core/src/loader_tree.rs @@ -116,7 +116,6 @@ impl LoaderTreeBuilder { )?; self.imports.push(formatdoc!( r#" - ("TURBOPACK {{ chunking-type: isolatedParallel }}"); import {}, {{ chunks as {} }} from "COMPONENT_{}"; "#, identifier, diff --git a/packages/next-swc/crates/next-core/src/next_client_component/with_client_chunks.rs b/packages/next-swc/crates/next-core/src/next_client_component/with_client_chunks.rs index 84ea9db26b1f6..94a3ffb96dd1d 100644 --- a/packages/next-swc/crates/next-core/src/next_client_component/with_client_chunks.rs +++ b/packages/next-swc/crates/next-core/src/next_client_component/with_client_chunks.rs @@ -8,8 +8,7 @@ use turbopack_binding::{ asset::{Asset, AssetContent}, chunk::{ ChunkData, ChunkItem, ChunkItemExt, ChunkType, ChunkableModule, - ChunkableModuleReference, ChunkingContext, ChunkingContextExt, ChunkingType, - ChunkingTypeOption, ChunksData, + ChunkableModuleReference, ChunkingContext, ChunkingContextExt, ChunksData, }, ident::AssetIdent, module::Module, @@ -274,9 +273,4 @@ impl ModuleReference for WithClientChunksAssetReference { } #[turbo_tasks::value_impl] -impl ChunkableModuleReference for WithClientChunksAssetReference { - #[turbo_tasks::function] - fn chunking_type(&self) -> Vc { - Vc::cell(Some(ChunkingType::IsolatedParallel)) - } -} +impl ChunkableModuleReference for WithClientChunksAssetReference {} diff --git a/packages/next-swc/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_proxy_module.rs b/packages/next-swc/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_proxy_module.rs index 48eb66dfe84ad..61b52dba9874c 100644 --- a/packages/next-swc/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_proxy_module.rs +++ b/packages/next-swc/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_proxy_module.rs @@ -7,10 +7,7 @@ use turbo_tasks_fs::File; use turbopack_binding::turbopack::{ core::{ asset::{Asset, AssetContent}, - chunk::{ - availability_info::AvailabilityInfo, ChunkItem, ChunkType, ChunkableModule, - ChunkingContext, - }, + chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkableModule, ChunkingContext}, code_builder::CodeBuilder, context::AssetContext, ident::AssetIdent, @@ -257,12 +254,12 @@ impl EcmascriptChunkItem for ProxyModuleChunkItem { } #[turbo_tasks::function] - fn content_with_availability_info( + fn content_with_async_module_info( &self, - availability_info: Value, + async_module_info: Option>, ) -> Vc { self.inner_proxy_module_chunk_item - .content_with_availability_info(availability_info) + .content_with_async_module_info(async_module_info) } #[turbo_tasks::function] diff --git a/packages/next-swc/crates/next-core/src/next_server_component/server_component_reference.rs b/packages/next-swc/crates/next-core/src/next_server_component/server_component_reference.rs index f1466de9e95e6..b82d1055c9f3d 100644 --- a/packages/next-swc/crates/next-core/src/next_server_component/server_component_reference.rs +++ b/packages/next-swc/crates/next-core/src/next_server_component/server_component_reference.rs @@ -1,9 +1,7 @@ use anyhow::Result; use turbo_tasks::{ValueToString, Vc}; use turbopack_binding::turbopack::core::{ - chunk::{ChunkableModuleReference, ChunkingType, ChunkingTypeOption}, - module::Module, - reference::ModuleReference, + chunk::ChunkableModuleReference, module::Module, reference::ModuleReference, resolve::ModuleResolveResult, }; @@ -40,11 +38,4 @@ impl ModuleReference for NextServerComponentModuleReference { } #[turbo_tasks::value_impl] -impl ChunkableModuleReference for NextServerComponentModuleReference { - #[turbo_tasks::function] - fn chunking_type(&self) -> Vc { - // TODO(alexkirsz) Instead of isolated parallel, have the server component - // reference create a new chunk group entirely? - Vc::cell(Some(ChunkingType::IsolatedParallel)) - } -} +impl ChunkableModuleReference for NextServerComponentModuleReference {} diff --git a/packages/next/package.json b/packages/next/package.json index 658ac474cecab..9300868c73837 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -191,7 +191,7 @@ "@types/ws": "8.2.0", "@vercel/ncc": "0.34.0", "@vercel/nft": "0.22.6", - "@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231006.4", + "@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231013.2", "acorn": "8.5.0", "amphtml-validator": "1.0.35", "anser": "1.4.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2bd236397921c..c6b5b43d22c0e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1061,8 +1061,8 @@ importers: specifier: 0.22.6 version: 0.22.6 '@vercel/turbopack-ecmascript-runtime': - specifier: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231006.4 - version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231006.4(react-refresh@0.12.0)(webpack@5.86.0)' + specifier: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231013.2 + version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231013.2(react-refresh@0.12.0)(webpack@5.86.0)' acorn: specifier: 8.5.0 version: 8.5.0 @@ -26805,9 +26805,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-231006.4(react-refresh@0.12.0)(webpack@5.86.0)': - resolution: {registry: https://registry.npmjs.org/, tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231006.4} - id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231006.4' + '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231013.2(react-refresh@0.12.0)(webpack@5.86.0)': + resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231013.2} + id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231013.2' name: '@vercel/turbopack-ecmascript-runtime' version: 0.0.0 dependencies: diff --git a/test/build-turbopack-tests-manifest.js b/test/build-turbopack-tests-manifest.js index 17c02a0e56e01..6e64d5a3b2507 100644 --- a/test/build-turbopack-tests-manifest.js +++ b/test/build-turbopack-tests-manifest.js @@ -28,6 +28,11 @@ const SKIPPED_TEST_SUITES = { 'ReactRefreshRegression app can fast refresh a page with dynamic rendering', 'ReactRefreshRegression app can fast refresh a page with config', ], + 'test/development/acceptance-app/ReactRefreshRequire.test.ts': [ + 'ReactRefreshRequire app re-runs accepted modules', + 'ReactRefreshRequire app propagates a hot update to closest accepted module', + 'ReactRefreshRequire app propagates hot update to all inverse dependencies', + ], 'test/development/acceptance/ReactRefreshRequire.test.ts': [ 'ReactRefreshRequire re-runs accepted modules', 'ReactRefreshRequire propagates a hot update to closest accepted module', diff --git a/test/development/basic/__snapshots__/next-rs-api.test.ts.snap b/test/development/basic/__snapshots__/next-rs-api.test.ts.snap index d5e11bcc3ff57..f0086cfb25d20 100644 --- a/test/development/basic/__snapshots__/next-rs-api.test.ts.snap +++ b/test/development/basic/__snapshots__/next-rs-api.test.ts.snap @@ -12,6 +12,14 @@ exports[`next.rs api should allow to write app Node.js route to disk: diagnostic exports[`next.rs api should allow to write app Node.js route to disk: issues 1`] = `Array []`; +exports[`next.rs api should allow to write app edge page to disk: diagnostics 1`] = `Array []`; + +exports[`next.rs api should allow to write app edge page to disk: issues 1`] = `Array []`; + +exports[`next.rs api should allow to write app edge page to disk: rsc diagnostics 1`] = `Array []`; + +exports[`next.rs api should allow to write app edge page to disk: rsc issues 1`] = `Array []`; + exports[`next.rs api should allow to write app edge route to disk: diagnostics 1`] = `Array []`; exports[`next.rs api should allow to write app edge route to disk: issues 1`] = `Array []`; diff --git a/test/integration/draft-mode/test/index.test.ts b/test/integration/draft-mode/test/index.test.ts index b08b00ecb51b3..7cb5461cd974c 100644 --- a/test/integration/draft-mode/test/index.test.ts +++ b/test/integration/draft-mode/test/index.test.ts @@ -71,7 +71,7 @@ describe('Test Draft Mode', () => { const body = await res.text() // "err":{"name":"TypeError","message":"Cannot read property 'previewModeId' of undefined" - expect(body).not.toContain('err') + expect(body).not.toContain('"err"') expect(body).not.toContain('TypeError') expect(body).not.toContain('previewModeId') diff --git a/test/integration/externals-pages-bundle/test/externals.test.js b/test/integration/externals-pages-bundle/test/externals.test.js index e79f4504a95c6..2b698534e4166 100644 --- a/test/integration/externals-pages-bundle/test/externals.test.js +++ b/test/integration/externals-pages-bundle/test/externals.test.js @@ -22,15 +22,16 @@ describe('default', () => { await renderViaHTTP(port, '/') if (process.env.TURBOPACK) { const ssrPath = join(appDir, '.next/server/chunks/ssr') - const pageBundleBasename = (await fs.readdir(ssrPath)).find((p) => - p.match(/pages_index_[0-9a-f]+\.js$/) + const pageBundleBasenames = (await fs.readdir(ssrPath)).filter((p) => + p.match(/\.js$/) ) - expect(pageBundleBasename).not.toBeUndefined() - const output = await fs.readFile( - join(ssrPath, pageBundleBasename), - 'utf8' - ) - expect(output).toContain( + expect(pageBundleBasenames).not.toBeEmpty() + let allBundles = '' + for (const basename of pageBundleBasenames) { + const output = await fs.readFile(join(ssrPath, basename), 'utf8') + allBundles += output + } + expect(allBundles).toContain( '__turbopack_external_require__("external-package", true)' ) } else { diff --git a/test/integration/getserversideprops-preview/test/index.test.js b/test/integration/getserversideprops-preview/test/index.test.js index 1e0a0dbf67458..e0c5e1b7800f9 100644 --- a/test/integration/getserversideprops-preview/test/index.test.js +++ b/test/integration/getserversideprops-preview/test/index.test.js @@ -210,7 +210,7 @@ describe('ServerSide Props Preview Mode', () => { const body = await res.text() // "err":{"name":"TypeError","message":"Cannot read property 'previewModeId' of undefined" - expect(body).not.toContain('err') + expect(body).not.toContain('"err"') expect(body).not.toContain('TypeError') expect(body).not.toContain('previewModeId') diff --git a/test/integration/prerender-preview/test/index.test.js b/test/integration/prerender-preview/test/index.test.js index 1fba4a08822f1..1126efb78ce7a 100644 --- a/test/integration/prerender-preview/test/index.test.js +++ b/test/integration/prerender-preview/test/index.test.js @@ -303,7 +303,7 @@ describe('Prerender Preview Mode', () => { const body = await res.text() // "err":{"name":"TypeError","message":"Cannot read property 'previewModeId' of undefined" - expect(body).not.toContain('err') + expect(body).not.toContain('"err"') expect(body).not.toContain('TypeError') expect(body).not.toContain('previewModeId') diff --git a/test/turbopack-tests-manifest.json b/test/turbopack-tests-manifest.json index 640e35bc0c0e8..9acc60dc3e211 100644 --- a/test/turbopack-tests-manifest.json +++ b/test/turbopack-tests-manifest.json @@ -917,13 +917,10 @@ "ReactRefreshRequire app can continue hot updates after module-level errors with module.exports", "ReactRefreshRequire app can replace a module before it is loaded", "ReactRefreshRequire app does not accumulate stale exports over time", - "ReactRefreshRequire app propagates a hot update to closest accepted module", - "ReactRefreshRequire app propagates hot update to all inverse dependencies", "ReactRefreshRequire app provides fresh value for ES6 default import in parents", "ReactRefreshRequire app provides fresh value for ES6 named import in parents", "ReactRefreshRequire app provides fresh value for exports.* in parents", "ReactRefreshRequire app provides fresh value for module.exports in parents", - "ReactRefreshRequire app re-runs accepted modules", "ReactRefreshRequire app runs dependencies before dependents", "ReactRefreshRequire app stops update propagation after module-level errors" ], @@ -931,7 +928,11 @@ "pending": [ "ReactRefreshRequire app propagates a module that stops accepting in next version" ], - "flakey": [], + "flakey": [ + "ReactRefreshRequire app propagates a hot update to closest accepted module", + "ReactRefreshRequire app propagates hot update to all inverse dependencies", + "ReactRefreshRequire app re-runs accepted modules" + ], "runtimeError": false }, "test/development/acceptance-app/app-hmr-changes.test.ts": {