diff --git a/Cargo.lock b/Cargo.lock index cbe4f11704aff..9691bd3826777 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-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "serde", "smallvec", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "node-file-trace" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "serde", @@ -7368,7 +7368,7 @@ dependencies = [ [[package]] name = "turbo-tasks" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "async-trait", @@ -7400,7 +7400,7 @@ dependencies = [ [[package]] name = "turbo-tasks-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "cargo-lock", @@ -7412,7 +7412,7 @@ dependencies = [ [[package]] name = "turbo-tasks-bytes" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "bytes", @@ -7427,7 +7427,7 @@ dependencies = [ [[package]] name = "turbo-tasks-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "dotenvs", @@ -7441,7 +7441,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fetch" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7458,7 +7458,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fs" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "auto-hash-map", @@ -7488,7 +7488,7 @@ dependencies = [ [[package]] name = "turbo-tasks-hash" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "base16", "hex", @@ -7500,7 +7500,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -7514,7 +7514,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros-shared" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "proc-macro2", "quote", @@ -7524,7 +7524,7 @@ dependencies = [ [[package]] name = "turbo-tasks-malloc" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "mimalloc", ] @@ -7532,7 +7532,7 @@ dependencies = [ [[package]] name = "turbo-tasks-memory" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "auto-hash-map", @@ -7557,7 +7557,7 @@ dependencies = [ [[package]] name = "turbopack" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "async-recursion", @@ -7588,7 +7588,7 @@ dependencies = [ [[package]] name = "turbopack-binding" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "auto-hash-map", "mdxjs", @@ -7628,7 +7628,7 @@ dependencies = [ [[package]] name = "turbopack-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7650,7 +7650,7 @@ dependencies = [ [[package]] name = "turbopack-cli-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "clap 4.4.2", @@ -7674,7 +7674,7 @@ dependencies = [ [[package]] name = "turbopack-core" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "async-recursion", @@ -7703,7 +7703,7 @@ dependencies = [ [[package]] name = "turbopack-css" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "async-trait", @@ -7725,7 +7725,7 @@ dependencies = [ [[package]] name = "turbopack-dev" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7749,7 +7749,7 @@ dependencies = [ [[package]] name = "turbopack-dev-server" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "async-compression", @@ -7786,7 +7786,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "async-trait", @@ -7820,7 +7820,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-hmr-protocol" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "serde", "serde_json", @@ -7831,7 +7831,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-plugins" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "async-trait", @@ -7854,7 +7854,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-runtime" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "indoc", @@ -7871,7 +7871,7 @@ dependencies = [ [[package]] name = "turbopack-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7887,7 +7887,7 @@ dependencies = [ [[package]] name = "turbopack-image" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "base64 0.21.4", @@ -7907,7 +7907,7 @@ dependencies = [ [[package]] name = "turbopack-json" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "serde", @@ -7922,7 +7922,7 @@ dependencies = [ [[package]] name = "turbopack-mdx" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "mdxjs", @@ -7937,7 +7937,7 @@ dependencies = [ [[package]] name = "turbopack-node" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "async-stream", @@ -7972,7 +7972,7 @@ dependencies = [ [[package]] name = "turbopack-static" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "serde", @@ -7988,7 +7988,7 @@ dependencies = [ [[package]] name = "turbopack-swc-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "swc_core", "turbo-tasks", @@ -7999,7 +7999,7 @@ dependencies = [ [[package]] name = "turbopack-wasm" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231002.1#dc1e2a7a4aa4cbd88c7144bf0bdd4fd0589373c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231005.2#2207c3eb716b81c719385e43d25d7399f673fc11" dependencies = [ "anyhow", "indexmap 1.9.3", diff --git a/Cargo.toml b/Cargo.toml index 5d2d40a9adb0f..6bd1c3e771296 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-231002.1" } +turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231005.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-231002.1" } +turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231005.2" } # [TODO]: need to refactor embed_directory! macro usage in next-core -turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231002.1" } +turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231005.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 cd9ac1a0e3523..05d7a0008e33b 100644 --- a/packages/next-swc/crates/next-api/src/app.rs +++ b/packages/next-swc/crates/next-api/src/app.rs @@ -39,7 +39,7 @@ use turbopack_binding::{ turbopack::{ core::{ asset::{Asset, AssetContent}, - chunk::{ChunkableModule, ChunkingContext, EvaluatableAssets}, + chunk::{ChunkableModuleExt, ChunkingContext, EvaluatableAssets}, file_source::FileSource, output::{OutputAsset, OutputAssets}, virtual_output::VirtualOutputAsset, diff --git a/packages/next-swc/crates/next-api/src/middleware.rs b/packages/next-swc/crates/next-api/src/middleware.rs index b86185ccb80ec..b7fedd56befb0 100644 --- a/packages/next-swc/crates/next-api/src/middleware.rs +++ b/packages/next-swc/crates/next-api/src/middleware.rs @@ -13,7 +13,7 @@ use turbopack_binding::{ turbopack::{ core::{ asset::AssetContent, - chunk::{ChunkableModule, ChunkingContext}, + chunk::{ChunkableModuleExt, ChunkingContext}, context::AssetContext, module::Module, output::{OutputAsset, OutputAssets}, diff --git a/packages/next-swc/crates/next-api/src/pages.rs b/packages/next-swc/crates/next-api/src/pages.rs index b4e5ec17bc77e..e198e346a3e05 100644 --- a/packages/next-swc/crates/next-api/src/pages.rs +++ b/packages/next-swc/crates/next-api/src/pages.rs @@ -37,7 +37,7 @@ use turbopack_binding::{ build::BuildChunkingContext, core::{ asset::AssetContent, - chunk::{ChunkableModule, ChunkingContext, EvaluatableAssets}, + chunk::{ChunkableModuleExt, ChunkingContext, EvaluatableAssets}, context::AssetContext, file_source::FileSource, issue::{IssueSeverity, OptionIssueSource}, diff --git a/packages/next-swc/crates/next-api/src/server_actions.rs b/packages/next-swc/crates/next-api/src/server_actions.rs index 7b0428d5ad393..3ef3583dee0b5 100644 --- a/packages/next-swc/crates/next-api/src/server_actions.rs +++ b/packages/next-swc/crates/next-api/src/server_actions.rs @@ -16,13 +16,18 @@ use turbopack_binding::{ turbo::tasks_fs::{rope::RopeBuilder, File, FileSystemPath}, turbopack::{ core::{ - asset::AssetContent, chunk::EvaluatableAsset, context::AssetContext, module::Module, - output::OutputAsset, reference::primary_referenced_modules, - reference_type::ReferenceType, virtual_output::VirtualOutputAsset, + asset::AssetContent, + chunk::{ChunkItemExt, ChunkableModule, EvaluatableAsset}, + context::AssetContext, + module::Module, + output::OutputAsset, + reference::primary_referenced_modules, + reference_type::ReferenceType, + virtual_output::VirtualOutputAsset, virtual_source::VirtualSource, }, ecmascript::{ - chunk::{EcmascriptChunkItemExt, EcmascriptChunkPlaceable, EcmascriptChunkingContext}, + chunk::{EcmascriptChunkPlaceable, EcmascriptChunkingContext}, parse::ParseResult, EcmascriptModuleAsset, }, @@ -72,7 +77,10 @@ pub(crate) async fn create_server_actions_manifest( bail!("loader module must be evaluatable"); }; - let loader_id = loader.as_chunk_item(chunking_context).id().to_string(); + let loader_id = loader + .as_chunk_item(Vc::upcast(chunking_context)) + .id() + .to_string(); let manifest = build_manifest(node_root, pathname, page_name, runtime, actions, loader_id).await?; Ok((Some(evaluable), manifest)) 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 bbbe6c9ae3fc6..1f024e90e1c64 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 @@ -27,7 +27,7 @@ use turbopack_binding::{ turbopack::{ build::BuildChunkingContext, core::{ - chunk::{ChunkableModule, ChunkingContext, EvaluatableAssets}, + chunk::{ChunkableModuleExt, ChunkingContext, EvaluatableAssets}, compile_time_info::CompileTimeInfo, context::AssetContext, file_source::FileSource, 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 554b11e92e400..ea67efab3a447 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 @@ -5,7 +5,7 @@ use turbo_tasks::{debug::ValueDebugFormat, trace::TraceRawVcs, TryJoinIterExt, V use turbopack_binding::turbopack::{ build::BuildChunkingContext, core::{ - chunk::{ChunkableModule, ChunkingContext}, + chunk::{ChunkableModuleExt, ChunkingContext}, output::OutputAssets, }, ecmascript::chunk::EcmascriptChunkingContext, diff --git a/packages/next-swc/crates/next-core/src/next_client_component/with_chunking_context_scope_asset.rs b/packages/next-swc/crates/next-core/src/next_client_component/with_chunking_context_scope_asset.rs index f8cede2ba285c..694db16ba4d1f 100644 --- a/packages/next-swc/crates/next-core/src/next_client_component/with_chunking_context_scope_asset.rs +++ b/packages/next-swc/crates/next-core/src/next_client_component/with_chunking_context_scope_asset.rs @@ -1,17 +1,13 @@ -use anyhow::{Context, Result}; -use turbo_tasks::{Value, Vc}; +use turbo_tasks::Vc; use turbopack_binding::turbopack::{ core::{ asset::{Asset, AssetContent}, - chunk::{availability_info::AvailabilityInfo, Chunk, ChunkableModule, ChunkingContext}, + chunk::{ChunkableModule, ChunkingContext}, ident::AssetIdent, module::Module, reference::ModuleReferences, }, - ecmascript::chunk::EcmascriptChunkingContext, - turbopack::ecmascript::chunk::{ - EcmascriptChunk, EcmascriptChunkItem, EcmascriptChunkPlaceable, EcmascriptExports, - }, + turbopack::ecmascript::chunk::{EcmascriptChunkPlaceable, EcmascriptExports}, }; #[turbo_tasks::function] @@ -49,38 +45,19 @@ impl Asset for WithChunkingContextScopeAsset { #[turbo_tasks::value_impl] impl ChunkableModule for WithChunkingContextScopeAsset { #[turbo_tasks::function] - fn as_chunk( + fn as_chunk_item( &self, - context: Vc>, - availability_info: Value, - ) -> Vc> { - Vc::upcast(EcmascriptChunk::new( - context.with_layer(self.layer.clone()), + chunking_context: Vc>, + ) -> Vc> { + Vc::upcast(ChunkableModule::as_chunk_item( self.asset, - availability_info, + chunking_context.with_layer(self.layer.clone()), )) } } #[turbo_tasks::value_impl] impl EcmascriptChunkPlaceable for WithChunkingContextScopeAsset { - #[turbo_tasks::function] - async fn as_chunk_item( - &self, - context: Vc>, - ) -> Result>> { - Ok(self.asset.as_chunk_item( - Vc::try_resolve_sidecast::>( - context.with_layer(self.layer.clone()), - ) - .await? - .context( - "ChunkingContext::with_layer should not return a different kind of chunking \ - context", - )?, - )) - } - #[turbo_tasks::function] fn get_exports(&self) -> Vc { self.asset.get_exports() 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 87779c061e8b5..d5499cc0de811 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 @@ -7,9 +7,9 @@ use turbopack_binding::{ core::{ asset::{Asset, AssetContent}, chunk::{ - availability_info::AvailabilityInfo, Chunk, ChunkData, ChunkItem, ChunkableModule, - ChunkableModuleReference, ChunkingContext, ChunkingType, ChunkingTypeOption, - ChunksData, + availability_info::AvailabilityInfo, Chunk, ChunkData, ChunkItem, ChunkItemExt, + ChunkableModule, ChunkableModuleExt, ChunkableModuleReference, ChunkingContext, + ChunkingType, ChunkingTypeOption, ChunksData, }, ident::AssetIdent, module::Module, @@ -18,7 +18,7 @@ use turbopack_binding::{ reference::{ModuleReference, ModuleReferences, SingleOutputAssetReference}, resolve::ModuleResolveResult, }, - ecmascript::chunk::{EcmascriptChunkData, EcmascriptChunkItemExt}, + ecmascript::chunk::EcmascriptChunkData, turbopack::ecmascript::{ chunk::{ EcmascriptChunk, EcmascriptChunkItem, EcmascriptChunkItemContent, @@ -68,43 +68,30 @@ impl Asset for WithClientChunksAsset { #[turbo_tasks::value_impl] impl ChunkableModule for WithClientChunksAsset { - #[turbo_tasks::function] - fn as_chunk( - self: Vc, - context: Vc>, - availability_info: Value, - ) -> Vc> { - Vc::upcast(EcmascriptChunk::new( - context.with_layer("rsc".to_string()), - Vc::upcast(self), - availability_info, - )) - } -} - -#[turbo_tasks::value_impl] -impl EcmascriptChunkPlaceable for WithClientChunksAsset { #[turbo_tasks::function] async fn as_chunk_item( self: Vc, - context: Vc>, - ) -> Result>> { + chunking_context: Vc>, + ) -> Result>> { + let context = Vc::try_resolve_sidecast::>( + chunking_context.with_layer("rsc".to_string()), + ) + .await? + .context( + "ChunkingContext::with_layer should not return a different kind of chunking context", + )?; Ok(Vc::upcast( WithClientChunksChunkItem { - context: Vc::try_resolve_sidecast::>( - context.with_layer("rsc".to_string()), - ) - .await? - .context( - "ChunkingContext::with_layer should not return a different kind of chunking \ - context", - )?, + context, inner: self, } .cell(), )) } +} +#[turbo_tasks::value_impl] +impl EcmascriptChunkPlaceable for WithClientChunksAsset { #[turbo_tasks::function] fn get_exports(&self) -> Vc { // TODO This should be EsmExports @@ -183,7 +170,11 @@ impl EcmascriptChunkItem for WithClientChunksChunkItem { .map(|chunk_data| EcmascriptChunkData::new(chunk_data)) .collect(); - let module_id = inner.asset.as_chunk_item(this.context).id().await?; + let module_id = inner + .asset + .as_chunk_item(Vc::upcast(this.context)) + .id() + .await?; Ok(EcmascriptChunkItemContent { inner_code: formatdoc!( // We store the chunks in a binding, otherwise a new array would be created every @@ -243,6 +234,20 @@ impl ChunkItem for WithClientChunksChunkItem { } Ok(Vc::cell(references)) } + + #[turbo_tasks::function] + async fn chunking_context(&self) -> Vc> { + Vc::upcast(self.context) + } + + #[turbo_tasks::function] + fn as_chunk(&self, availability_info: Value) -> Vc> { + Vc::upcast(EcmascriptChunk::new( + Vc::upcast(self.context.with_layer("rsc".to_string())), + Vc::upcast(self.inner), + availability_info, + )) + } } #[turbo_tasks::value] 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 b4adf43c325e8..fe3c06999ff39 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 @@ -1,6 +1,6 @@ use std::{io::Write, iter::once}; -use anyhow::{bail, Result}; +use anyhow::{bail, Context, Result}; use indoc::writedoc; use turbo_tasks::{Value, ValueToString, Vc}; use turbo_tasks_fs::File; @@ -85,7 +85,7 @@ impl EcmascriptClientReferenceProxyModule { // and the $$typeof value is for rendering logic to determine if the module // is a client boundary. const {{ __esModule, $$typeof }} = proxy; - + export {{ __esModule, $$typeof }}; export default proxy; "#, @@ -164,36 +164,35 @@ impl Asset for EcmascriptClientReferenceProxyModule { #[turbo_tasks::value_impl] impl ChunkableModule for EcmascriptClientReferenceProxyModule { #[turbo_tasks::function] - fn as_chunk( + async fn as_chunk_item( self: Vc, - context: Vc>, - availability_info: Value, - ) -> Vc> { - Vc::upcast(EcmascriptChunk::new( - context, - Vc::upcast(self), - availability_info, - )) - } -} + chunking_context: Vc>, + ) -> Result>> { + let item = self.proxy_module().as_chunk_item(chunking_context); + let ecmascript_item = Vc::try_resolve_downcast::>(item) + .await? + .context("EcmascriptModuleAsset must implement EcmascriptChunkItem")?; + let chunking_context = + Vc::try_resolve_downcast::>(chunking_context) + .await? + .context( + "chunking context must impl EcmascriptChunkingContext to use \ + EcmascriptClientReferenceProxyModule", + )?; -#[turbo_tasks::value_impl] -impl EcmascriptChunkPlaceable for EcmascriptClientReferenceProxyModule { - #[turbo_tasks::function] - fn as_chunk_item( - self: Vc, - chunking_context: Vc>, - ) -> Vc> { - Vc::upcast( + Ok(Vc::upcast( ProxyModuleChunkItem { client_proxy_asset: self, - inner_proxy_module_chunk_item: self.proxy_module().as_chunk_item(chunking_context), + inner_proxy_module_chunk_item: ecmascript_item, chunking_context, } .cell(), - ) + )) } +} +#[turbo_tasks::value_impl] +impl EcmascriptChunkPlaceable for EcmascriptClientReferenceProxyModule { #[turbo_tasks::function] fn get_exports(self: Vc) -> Vc { self.proxy_module().get_exports() @@ -232,6 +231,20 @@ impl ChunkItem for ProxyModuleChunkItem { fn references(&self) -> Vc { self.client_proxy_asset.references() } + + #[turbo_tasks::function] + async fn chunking_context(&self) -> Vc> { + Vc::upcast(self.chunking_context) + } + + #[turbo_tasks::function] + fn as_chunk(&self, availability_info: Value) -> Vc> { + Vc::upcast(EcmascriptChunk::new( + Vc::upcast(self.chunking_context), + Vc::upcast(self.client_proxy_asset), + availability_info, + )) + } } #[turbo_tasks::value_impl] @@ -252,6 +265,6 @@ impl EcmascriptChunkItem for ProxyModuleChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - self.inner_proxy_module_chunk_item.chunking_context() + EcmascriptChunkItem::chunking_context(self.inner_proxy_module_chunk_item) } } 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 b4fe032aa82d6..b5cd908992b66 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 @@ -2,7 +2,7 @@ use anyhow::{bail, Result}; use turbo_tasks::Vc; use turbopack_binding::turbopack::core::{ asset::{Asset, AssetContent}, - chunk::{ChunkableModule, ChunkingContext}, + chunk::{ChunkableModule, ChunkableModuleExt, ChunkingContext}, ident::AssetIdent, module::Module, output::OutputAssets, diff --git a/packages/next-swc/crates/next-core/src/next_manifests/client_reference_manifest.rs b/packages/next-swc/crates/next-core/src/next_manifests/client_reference_manifest.rs index 527f588da1c34..f99625cec5e2e 100644 --- a/packages/next-swc/crates/next-core/src/next_manifests/client_reference_manifest.rs +++ b/packages/next-swc/crates/next-core/src/next_manifests/client_reference_manifest.rs @@ -4,13 +4,12 @@ use turbo_tasks::{TryJoinIterExt, ValueToString, Vc}; use turbo_tasks_fs::{File, FileSystemPath}; use turbopack_binding::turbopack::{ core::{ - asset::AssetContent, chunk::ModuleId as TurbopackModuleId, output::OutputAsset, + asset::AssetContent, + chunk::{ChunkItemExt, ChunkableModule, ModuleId as TurbopackModuleId}, + output::OutputAsset, virtual_output::VirtualOutputAsset, }, - ecmascript::{ - chunk::{EcmascriptChunkItemExt, EcmascriptChunkPlaceable, EcmascriptChunkingContext}, - utils::StringifyJs, - }, + ecmascript::{chunk::EcmascriptChunkingContext, utils::StringifyJs}, }; use super::{ClientReferenceManifest, ManifestNode, ManifestNodeEntry, ModuleId}; @@ -117,12 +116,12 @@ impl ClientReferenceManifest { let client_module_id = ecmascript_client_reference .client_module - .as_chunk_item(client_chunking_context) + .as_chunk_item(Vc::upcast(client_chunking_context)) .id() .await?; let ssr_module_id = ecmascript_client_reference .ssr_module - .as_chunk_item(ssr_chunking_context) + .as_chunk_item(Vc::upcast(ssr_chunking_context)) .id() .await?; diff --git a/packages/next-swc/crates/next-core/src/next_server_component/server_component_module.rs b/packages/next-swc/crates/next-core/src/next_server_component/server_component_module.rs index f5253735faa9a..bd89ee6081954 100644 --- a/packages/next-swc/crates/next-core/src/next_server_component/server_component_module.rs +++ b/packages/next-swc/crates/next-core/src/next_server_component/server_component_module.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Result}; +use anyhow::{bail, Context, Result}; use indoc::formatdoc; use turbo_tasks::{Value, Vc}; use turbo_tasks_fs::FileSystemPath; @@ -6,13 +6,13 @@ use turbopack_binding::turbopack::{ core::{ asset::{Asset, AssetContent}, chunk::{ - availability_info::AvailabilityInfo, Chunk, ChunkItem, ChunkableModule, ChunkingContext, + availability_info::AvailabilityInfo, Chunk, ChunkItem, ChunkItemExt, ChunkableModule, + ChunkingContext, }, ident::AssetIdent, module::Module, reference::ModuleReferences, }, - ecmascript::chunk::EcmascriptChunkItemExt, turbopack::ecmascript::{ chunk::{ EcmascriptChunk, EcmascriptChunkItem, EcmascriptChunkItemContent, @@ -73,27 +73,18 @@ impl Asset for NextServerComponentModule { #[turbo_tasks::value_impl] impl ChunkableModule for NextServerComponentModule { - #[turbo_tasks::function] - fn as_chunk( - self: Vc, - context: Vc>, - availability_info: Value, - ) -> Vc> { - Vc::upcast(EcmascriptChunk::new( - context, - Vc::upcast(self), - availability_info, - )) - } -} - -#[turbo_tasks::value_impl] -impl EcmascriptChunkPlaceable for NextServerComponentModule { #[turbo_tasks::function] async fn as_chunk_item( self: Vc, - context: Vc>, - ) -> Result>> { + chunking_context: Vc>, + ) -> Result>> { + let context = + Vc::try_resolve_downcast::>(chunking_context) + .await? + .context( + "chunking context must impl EcmascriptChunkingContext to use \ + NextServerComponentModule", + )?; Ok(Vc::upcast( BuildServerComponentChunkItem { context, @@ -102,7 +93,10 @@ impl EcmascriptChunkPlaceable for NextServerComponentModule { .cell(), )) } +} +#[turbo_tasks::value_impl] +impl EcmascriptChunkPlaceable for NextServerComponentModule { #[turbo_tasks::function] fn get_exports(&self) -> Vc { // TODO This should be EsmExports @@ -128,7 +122,11 @@ impl EcmascriptChunkItem for BuildServerComponentChunkItem { let this = self.await?; let inner = this.inner.await?; - let module_id = inner.module.as_chunk_item(this.context).id().await?; + let module_id = inner + .module + .as_chunk_item(Vc::upcast(this.context)) + .id() + .await?; Ok(EcmascriptChunkItemContent { inner_code: formatdoc!( r#" @@ -156,4 +154,18 @@ impl ChunkItem for BuildServerComponentChunkItem { fn references(&self) -> Vc { self.inner.references() } + + #[turbo_tasks::function] + async fn chunking_context(&self) -> Vc> { + Vc::upcast(self.context) + } + + #[turbo_tasks::function] + fn as_chunk(&self, availability_info: Value) -> Vc> { + Vc::upcast(EcmascriptChunk::new( + Vc::upcast(self.context), + Vc::upcast(self.inner), + availability_info, + )) + } } 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 b1f37a0d5c593..56d240b1a476b 100644 --- a/packages/next-swc/crates/next-core/src/page_loader.rs +++ b/packages/next-swc/crates/next-core/src/page_loader.rs @@ -10,7 +10,7 @@ use turbopack_binding::{ core::{ asset::{Asset, AssetContent}, chunk::{ - ChunkData, ChunkableModule, ChunkingContext, ChunksData, EvaluatableAsset, + ChunkData, ChunkableModuleExt, ChunkingContext, ChunksData, EvaluatableAsset, EvaluatableAssets, }, context::AssetContext, diff --git a/packages/next/package.json b/packages/next/package.json index fc8b1aabde29f..85d14ea8518d8 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-231002.1", + "@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231005.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 5237d8843b00a..7f6605037d310 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1058,8 +1058,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-231002.1 - version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231002.1(react-refresh@0.12.0)(webpack@5.86.0)' + specifier: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231005.2 + version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231005.2(react-refresh@0.12.0)(webpack@5.86.0)' acorn: specifier: 8.5.0 version: 8.5.0 @@ -26762,9 +26762,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-231002.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-231002.1} - id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231002.1' + '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231005.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-231005.2} + id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231005.2' name: '@vercel/turbopack-ecmascript-runtime' version: 0.0.0 dependencies: