diff --git a/Cargo.lock b/Cargo.lock index 4bfb6d1d07ea9..0133cf263a80f 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" 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.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "indexmap 1.9.3", diff --git a/Cargo.toml b/Cargo.toml index 173a6453b4167..d8f5ed3050deb 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.3" } # [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.3" } # [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.3" } # 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..b3fd51f922442 100644 --- a/packages/next-swc/crates/next-api/src/pages.rs +++ b/packages/next-swc/crates/next-api/src/pages.rs @@ -563,11 +563,9 @@ impl PageEndpoint { client_chunks.push(Vc::upcast(PageLoaderAsset::new( this.pages_project.project().client_root(), - client_module_context, - Vc::upcast(client_chunking_context), - self.source(), this.pathname, self.client_relative_path(), + Vc::cell(client_chunks.clone()), ))); Ok(Vc::cell(client_chunks)) @@ -629,8 +627,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_import_map.rs b/packages/next-swc/crates/next-core/src/next_import_map.rs index 13e360f084719..a3c06f3954071 100644 --- a/packages/next-swc/crates/next-core/src/next_import_map.rs +++ b/packages/next-swc/crates/next-core/src/next_import_map.rs @@ -737,14 +737,6 @@ async fn insert_next_server_special_aliases( }, ), ); - import_map.insert_exact_alias( - "server-only", - request_to_import_mapping(app_dir, "next/dist/compiled/server-only"), - ); - import_map.insert_exact_alias( - "client-only", - request_to_import_mapping(app_dir, "next/dist/compiled/client-only"), - ); import_map.insert_exact_alias( "react", request_to_import_mapping( @@ -841,9 +833,9 @@ async fn insert_next_server_special_aliases( project_path, indexmap! { "server-only" => "next/dist/compiled/server-only/empty".to_string(), - "client-only" => "next/dist/compiled/client-only/error".to_string(), + "client-only" => "next/dist/compiled/client-only/index".to_string(), "next/dist/compiled/server-only" => "next/dist/compiled/server-only/empty".to_string(), - "next/dist/compiled/client-only" => "next/dist/compiled/client-only/error".to_string(), + "next/dist/compiled/client-only" => "next/dist/compiled/client-only/index".to_string(), }, ); diff --git a/packages/next-swc/crates/next-core/src/next_server/resolve.rs b/packages/next-swc/crates/next-core/src/next_server/resolve.rs index 5a720139d2c56..21646a4330bd1 100644 --- a/packages/next-swc/crates/next-core/src/next_server/resolve.rs +++ b/packages/next-swc/crates/next-core/src/next_server/resolve.rs @@ -1,13 +1,14 @@ use anyhow::Result; -use turbo_tasks::Vc; +use turbo_tasks::{Value, Vc}; use turbopack_binding::{ turbo::tasks_fs::{glob::Glob, FileJsonContent, FileSystemPath}, turbopack::core::{ resolve::{ find_context_file, - node::node_cjs_resolve_options, + node::{node_cjs_resolve_options, node_esm_resolve_options}, package_json, parse::Request, + pattern::Pattern, plugin::{ResolvePlugin, ResolvePluginCondition}, resolve, FindContextFileResult, ResolveResult, ResolveResultItem, ResolveResultOption, }, @@ -58,8 +59,17 @@ async fn is_node_resolveable( context: Vc, request: Vc, expected: Vc, + is_esm: bool, ) -> Result> { - let node_resolve_result = resolve(context, request, node_cjs_resolve_options(context.root())); + let node_resolve_result = resolve( + context, + request, + if is_esm { + node_cjs_resolve_options(context.root()) + } else { + node_esm_resolve_options(context.root()) + }, + ); let primary_node_assets = node_resolve_result.primary_sources().await?; let Some(&node_asset) = primary_node_assets.first() else { // can't resolve request with node.js options @@ -153,11 +163,34 @@ impl ResolvePlugin for ExternalCjsModulesResolvePlugin { // check if we can resolve the package from the project dir with node.js resolve // options (might be hidden by pnpm) - if *is_node_resolveable(self.project_path, request, fs_path).await? { - // mark as external - return Ok(ResolveResultOption::some( - ResolveResult::primary(ResolveResultItem::OriginalReferenceExternal).cell(), - )); + if *is_node_resolveable(self.project_path, request, fs_path, false).await? { + // We don't know if this is a ESM reference, so also check if it is resolveable + // as ESM. + if *is_node_resolveable(self.project_path, request, fs_path, true).await? { + // mark as external + return Ok(ResolveResultOption::some( + ResolveResult::primary(ResolveResultItem::OriginalReferenceExternal).cell(), + )); + } else if let Some(mut request_str) = request.await?.request() { + // When it's not resolveable as ESM, there is maybe an extension missing, try + // .js + if !request_str.ends_with(".js") { + request_str += ".js"; + let request = + Request::parse(Value::new(Pattern::Constant(request_str.clone()))); + if *is_node_resolveable(self.project_path, request, fs_path, false).await? + && *is_node_resolveable(self.project_path, request, fs_path, true).await? + { + // mark as external, but with .js extension + return Ok(ResolveResultOption::some( + ResolveResult::primary( + ResolveResultItem::OriginalReferenceTypeExternal(request_str), + ) + .cell(), + )); + } + } + } } Ok(ResolveResultOption::none()) 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-swc/crates/next-core/src/page_loader.rs b/packages/next-swc/crates/next-core/src/page_loader.rs index 7ac15c7b65a93..a8b2f2a907560 100644 --- a/packages/next-swc/crates/next-core/src/page_loader.rs +++ b/packages/next-swc/crates/next-core/src/page_loader.rs @@ -9,7 +9,7 @@ use turbopack_binding::{ turbopack::{ core::{ asset::{Asset, AssetContent}, - chunk::{ChunkData, ChunkingContext, ChunksData, EvaluatableAsset, EvaluatableAssets}, + chunk::{ChunkData, ChunksData}, context::AssetContext, ident::AssetIdent, module::Module, @@ -19,38 +19,12 @@ use turbopack_binding::{ source::Source, virtual_source::VirtualSource, }, - dev_server::source::{asset_graph::AssetGraphContentSource, ContentSource}, ecmascript::{chunk::EcmascriptChunkData, utils::StringifyJs}, }, }; use crate::{embed_js::next_js_file_path, util::get_asset_path_from_pathname}; -#[turbo_tasks::function] -pub async fn create_page_loader( - server_root: Vc, - client_context: Vc>, - client_chunking_context: Vc>, - entry_asset: Vc>, - pathname: Vc, - rebase_prefix_path: Vc, -) -> Result>> { - let asset = PageLoaderAsset { - server_root, - client_context, - client_chunking_context, - entry_asset, - pathname, - rebase_prefix_path, - } - .cell(); - - Ok(Vc::upcast(AssetGraphContentSource::new_lazy( - server_root, - Vc::upcast(asset), - ))) -} - #[turbo_tasks::function] pub async fn create_page_loader_entry_module( client_context: Vc>, @@ -93,11 +67,9 @@ pub async fn create_page_loader_entry_module( #[turbo_tasks::value(shared)] pub struct PageLoaderAsset { pub server_root: Vc, - pub client_context: Vc>, - pub client_chunking_context: Vc>, - pub entry_asset: Vc>, pub pathname: Vc, pub rebase_prefix_path: Vc, + pub page_chunks: Vc, } #[turbo_tasks::value_impl] @@ -105,48 +77,26 @@ impl PageLoaderAsset { #[turbo_tasks::function] pub fn new( server_root: Vc, - client_context: Vc>, - client_chunking_context: Vc>, - entry_asset: Vc>, pathname: Vc, rebase_prefix_path: Vc, + page_chunks: Vc, ) -> Vc { Self { server_root, - client_context, - client_chunking_context, - entry_asset, pathname, rebase_prefix_path, + page_chunks, } .cell() } - #[turbo_tasks::function] - async fn get_page_chunks(self: Vc) -> Result> { - let this = &*self.await?; - - let page_loader_entry_asset = - create_page_loader_entry_module(this.client_context, this.entry_asset, this.pathname); - - let Some(module) = - Vc::try_resolve_sidecast::>(page_loader_entry_asset).await? - else { - bail!("internal module must be evaluatable"); - }; - - Ok(this - .client_chunking_context - .evaluated_chunk_group(module.ident(), EvaluatableAssets::one(module))) - } - #[turbo_tasks::function] async fn chunks_data( self: Vc, rebase_prefix_path: Vc, ) -> Result> { let this = self.await?; - let mut chunks = self.get_page_chunks(); + let mut chunks = this.page_chunks; // If we are provided a prefix path, we need to rewrite our chunk paths to // remove that prefix. @@ -187,7 +137,7 @@ impl OutputAsset for PageLoaderAsset { #[turbo_tasks::function] async fn references(self: Vc) -> Result> { - let chunks = self.get_page_chunks().await?; + let chunks = self.await?.page_chunks.await?; let mut references = Vec::with_capacity(chunks.len()); for &chunk in chunks.iter() { diff --git a/packages/next/package.json b/packages/next/package.json index 658ac474cecab..ac3c4ff68a265 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.3", "acorn": "8.5.0", "amphtml-validator": "1.0.35", "anser": "1.4.9", diff --git a/packages/next/src/build/swc/index.ts b/packages/next/src/build/swc/index.ts index 7d7f2ea107d49..b838a158c9ee2 100644 --- a/packages/next/src/build/swc/index.ts +++ b/packages/next/src/build/swc/index.ts @@ -179,18 +179,16 @@ export async function loadBindings(): Promise { return pendingBindings } - if (process.platform === 'darwin') { - // rust needs stdout to be blocking, otherwise it will throw an error (on macOS at least) when writing a lot of data (logs) to it - // see https://github.com/napi-rs/napi-rs/issues/1630 - // and https://github.com/nodejs/node/blob/main/doc/api/process.md#a-note-on-process-io - if (process.stdout._handle != null) { - // @ts-ignore - process.stdout._handle.setBlocking(true) - } - if (process.stderr._handle != null) { - // @ts-ignore - process.stderr._handle.setBlocking(true) - } + // rust needs stdout to be blocking, otherwise it will throw an error (on macOS at least) when writing a lot of data (logs) to it + // see https://github.com/napi-rs/napi-rs/issues/1630 + // and https://github.com/nodejs/node/blob/main/doc/api/process.md#a-note-on-process-io + if (process.stdout._handle != null) { + // @ts-ignore + process.stdout._handle.setBlocking(true) + } + if (process.stderr._handle != null) { + // @ts-ignore + process.stderr._handle.setBlocking(true) } pendingBindings = new Promise(async (resolve, _reject) => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2bd236397921c..bdeab22f1f744 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.3 + version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231013.3(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.3(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.3} + id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231013.3' 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": {