From 81d5daddf365943e3f2c3a258d00c8ac76f9c81c Mon Sep 17 00:00:00 2001 From: Will Binns-Smith Date: Wed, 15 May 2024 08:51:08 -0700 Subject: [PATCH] Turbopack: Remove `EcmascriptChunkingContext` (#65716) Depends on vercel/turbo#8133. See that PR for rationale. --- Cargo.lock | 98 +++++++------------ Cargo.toml | 6 +- .../crates/next-api/src/dynamic_imports.rs | 7 +- .../next-swc/crates/next-api/src/pages.rs | 11 ++- .../next-swc/crates/next-api/src/project.rs | 6 +- .../crates/next-api/src/server_actions.rs | 9 +- .../next_app/app_client_references_chunks.rs | 15 ++- .../src/next_app/app_client_shared_chunks.rs | 16 ++- .../src/next_app/include_modules_module.rs | 15 +-- .../next-core/src/next_client/context.rs | 5 +- ...cmascript_client_reference_proxy_module.rs | 13 +-- .../crates/next-core/src/next_edge/context.rs | 6 +- .../client_reference_manifest.rs | 8 +- .../server_component_module.rs | 23 ++--- 14 files changed, 93 insertions(+), 145 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 71db5a3e33e1a..2eaac9be80f9b 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-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "serde", "smallvec", @@ -1144,7 +1144,7 @@ dependencies = [ "cssparser-macros", "dtoa-short", "itoa", - "phf 0.10.1", + "phf 0.11.2", "serde", "smallvec", ] @@ -3097,7 +3097,7 @@ dependencies = [ [[package]] name = "node-file-trace" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "serde", @@ -3567,9 +3567,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" dependencies = [ - "phf_macros 0.10.0", "phf_shared 0.10.0", - "proc-macro-hack", ] [[package]] @@ -3578,7 +3576,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" dependencies = [ - "phf_macros 0.11.2", + "phf_macros", "phf_shared 0.11.2", ] @@ -3612,20 +3610,6 @@ dependencies = [ "rand", ] -[[package]] -name = "phf_macros" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" -dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", - "proc-macro-hack", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "phf_macros" version = "0.11.2" @@ -3820,12 +3804,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - [[package]] name = "proc-macro2" version = "1.0.79" @@ -6965,7 +6943,7 @@ dependencies = [ [[package]] name = "turbo-tasks" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "async-trait", @@ -6996,7 +6974,7 @@ dependencies = [ [[package]] name = "turbo-tasks-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "cargo-lock", @@ -7008,7 +6986,7 @@ dependencies = [ [[package]] name = "turbo-tasks-bytes" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "bytes", @@ -7022,7 +7000,7 @@ dependencies = [ [[package]] name = "turbo-tasks-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "dotenvs", @@ -7036,7 +7014,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fetch" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "lazy_static", @@ -7052,7 +7030,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fs" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "auto-hash-map", @@ -7084,7 +7062,7 @@ dependencies = [ [[package]] name = "turbo-tasks-hash" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "base16", "hex", @@ -7096,7 +7074,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "proc-macro-error", @@ -7110,7 +7088,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros-shared" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "proc-macro2", "quote", @@ -7120,7 +7098,7 @@ dependencies = [ [[package]] name = "turbo-tasks-malloc" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "mimalloc", ] @@ -7128,7 +7106,7 @@ dependencies = [ [[package]] name = "turbo-tasks-memory" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "auto-hash-map", @@ -7154,7 +7132,7 @@ dependencies = [ [[package]] name = "turbopack" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "async-recursion", @@ -7184,7 +7162,7 @@ dependencies = [ [[package]] name = "turbopack-binding" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "auto-hash-map", "mdxjs", @@ -7225,7 +7203,7 @@ dependencies = [ [[package]] name = "turbopack-browser" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7248,7 +7226,7 @@ dependencies = [ [[package]] name = "turbopack-cli-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "clap", @@ -7265,7 +7243,7 @@ dependencies = [ [[package]] name = "turbopack-core" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "async-recursion", @@ -7294,7 +7272,7 @@ dependencies = [ [[package]] name = "turbopack-css" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7321,7 +7299,7 @@ dependencies = [ [[package]] name = "turbopack-dev-server" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "async-compression", @@ -7357,7 +7335,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "async-trait", @@ -7392,7 +7370,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-hmr-protocol" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "serde", "serde_json", @@ -7403,7 +7381,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-plugins" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "async-trait", @@ -7427,7 +7405,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-runtime" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "indoc", @@ -7443,7 +7421,7 @@ dependencies = [ [[package]] name = "turbopack-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7459,7 +7437,7 @@ dependencies = [ [[package]] name = "turbopack-image" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "base64 0.21.4", @@ -7478,7 +7456,7 @@ dependencies = [ [[package]] name = "turbopack-json" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "serde", @@ -7493,7 +7471,7 @@ dependencies = [ [[package]] name = "turbopack-mdx" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "mdxjs", @@ -7508,7 +7486,7 @@ dependencies = [ [[package]] name = "turbopack-node" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "async-stream", @@ -7542,7 +7520,7 @@ dependencies = [ [[package]] name = "turbopack-nodejs" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7562,7 +7540,7 @@ dependencies = [ [[package]] name = "turbopack-resolve" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7580,7 +7558,7 @@ dependencies = [ [[package]] name = "turbopack-static" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "serde", @@ -7596,7 +7574,7 @@ dependencies = [ [[package]] name = "turbopack-swc-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "swc_core", "turbo-tasks", @@ -7607,7 +7585,7 @@ dependencies = [ [[package]] name = "turbopack-trace-server" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "either", @@ -7626,7 +7604,7 @@ dependencies = [ [[package]] name = "turbopack-trace-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "crossbeam-channel", @@ -7642,7 +7620,7 @@ dependencies = [ [[package]] name = "turbopack-wasm" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240513.1#cc565e86be3506bc80592813a192217a8cc5b0c1" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-240514.2#27223f159654d687d04d789b3a6b862076c239e1" dependencies = [ "anyhow", "indexmap 1.9.3", diff --git a/Cargo.toml b/Cargo.toml index 472aa9fea9f8d..67d77ba9f1c30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,11 +37,11 @@ swc_core = { version = "0.90.33", features = [ testing = { version = "0.35.22" } # Turbo crates -turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240513.1" } +turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240514.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-240513.1" } +turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240514.2" } # [TODO]: need to refactor embed_directory! macro usage in next-core -turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240513.1" } +turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240514.2" } # General Deps diff --git a/packages/next-swc/crates/next-api/src/dynamic_imports.rs b/packages/next-swc/crates/next-api/src/dynamic_imports.rs index 12faec65f3038..d842e3c5c111d 100644 --- a/packages/next-swc/crates/next-api/src/dynamic_imports.rs +++ b/packages/next-swc/crates/next-api/src/dynamic_imports.rs @@ -27,10 +27,7 @@ use turbopack_binding::{ reference_type::EcmaScriptModulesReferenceSubType, resolve::{origin::PlainResolveOrigin, parse::Request, pattern::Pattern}, }, - ecmascript::{ - chunk::EcmascriptChunkingContext, parse::ParseResult, resolve::esm_resolve, - EcmascriptModuleAsset, - }, + ecmascript::{parse::ParseResult, resolve::esm_resolve, EcmascriptModuleAsset}, }, }; @@ -91,7 +88,7 @@ pub(crate) async fn collect_chunk_group( } pub(crate) async fn collect_evaluated_chunk_group( - chunking_context: Vc>, + chunking_context: Vc>, dynamic_import_entries: IndexMap>, DynamicImportedModules>, ) -> Result> { collect_chunk_group_inner(dynamic_import_entries, |module| async move { diff --git a/packages/next-swc/crates/next-api/src/pages.rs b/packages/next-swc/crates/next-api/src/pages.rs index fa630c16092b9..c13e046e7430f 100644 --- a/packages/next-swc/crates/next-api/src/pages.rs +++ b/packages/next-swc/crates/next-api/src/pages.rs @@ -34,7 +34,10 @@ use turbopack_binding::{ turbopack::{ core::{ asset::AssetContent, - chunk::{availability_info::AvailabilityInfo, ChunkingContextExt, EvaluatableAssets}, + chunk::{ + availability_info::AvailabilityInfo, ChunkingContext, ChunkingContextExt, + EvaluatableAssets, + }, context::AssetContext, file_source::FileSource, issue::IssueSeverity, @@ -48,9 +51,7 @@ use turbopack_binding::{ virtual_output::VirtualOutputAsset, }, ecmascript::{ - chunk::{EcmascriptChunkPlaceable, EcmascriptChunkingContext}, - resolve::esm_resolve, - EcmascriptModuleAsset, + chunk::EcmascriptChunkPlaceable, resolve::esm_resolve, EcmascriptModuleAsset, }, nodejs::{EntryChunkGroupResult, NodeJsChunkingContext}, turbopack::{ @@ -705,7 +706,7 @@ impl PageEndpoint { module_context: Vc, edge_module_context: Vc, chunking_context: Vc, - edge_chunking_context: Vc>, + edge_chunking_context: Vc>, runtime_entries: Vc, edge_runtime_entries: Vc, ) -> Result> { diff --git a/packages/next-swc/crates/next-api/src/project.rs b/packages/next-swc/crates/next-api/src/project.rs index 6d50dafd580b8..06471ac3dbf16 100644 --- a/packages/next-swc/crates/next-api/src/project.rs +++ b/packages/next-swc/crates/next-api/src/project.rs @@ -38,6 +38,7 @@ use turbopack_binding::{ browser::BrowserChunkingContext, core::{ changed::content_changed, + chunk::ChunkingContext, compile_time_info::CompileTimeInfo, context::AssetContext, diagnostics::DiagnosticExt, @@ -50,7 +51,6 @@ use turbopack_binding::{ version::{Update, Version, VersionState, VersionedContent}, PROJECT_FILESYSTEM_NAME, }, - ecmascript::chunk::EcmascriptChunkingContext, node::execution_context::ExecutionContext, nodejs::NodeJsChunkingContext, turbopack::{evaluate_context::node_build_environment, ModuleAssetContext}, @@ -625,7 +625,7 @@ impl Project { #[turbo_tasks::function] pub(super) async fn client_chunking_context( self: Vc, - ) -> Result>> { + ) -> Result>> { Ok(get_client_chunking_context( self.project_path(), self.client_relative_path(), @@ -663,7 +663,7 @@ impl Project { pub(super) fn edge_chunking_context( self: Vc, client_assets: bool, - ) -> Vc> { + ) -> Vc> { if client_assets { get_edge_chunking_context_with_client_assets( self.next_mode(), 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 7a8cb867bfa74..63770bfc178f5 100644 --- a/packages/next-swc/crates/next-api/src/server_actions.rs +++ b/packages/next-swc/crates/next-api/src/server_actions.rs @@ -17,7 +17,7 @@ use turbopack_binding::{ turbopack::{ core::{ asset::{Asset, AssetContent}, - chunk::{ChunkItemExt, ChunkableModule, EvaluatableAsset}, + chunk::{ChunkItemExt, ChunkableModule, ChunkingContext, EvaluatableAsset}, context::AssetContext, module::Module, output::OutputAsset, @@ -29,9 +29,8 @@ use turbopack_binding::{ virtual_source::VirtualSource, }, ecmascript::{ - chunk::{EcmascriptChunkPlaceable, EcmascriptChunkingContext}, - parse::ParseResult, - EcmascriptModuleAsset, EcmascriptModuleAssetType, + chunk::EcmascriptChunkPlaceable, parse::ParseResult, EcmascriptModuleAsset, + EcmascriptModuleAssetType, }, }, }; @@ -51,7 +50,7 @@ pub(crate) async fn create_server_actions_manifest( page_name: &str, runtime: NextRuntime, asset_context: Vc>, - chunking_context: Vc>, + chunking_context: Vc>, ) -> Result<(Vc>, Vc>)> { let actions = get_actions(rsc_entry, server_reference_modules, asset_context); let loader = 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 d00d0fc491dec..19f9f9762fa4b 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 @@ -2,13 +2,10 @@ use anyhow::Result; use indexmap::IndexMap; use tracing::Instrument; use turbo_tasks::{TryFlatJoinIterExt, TryJoinIterExt, Value, ValueToString, Vc}; -use turbopack_binding::turbopack::{ - core::{ - chunk::{availability_info::AvailabilityInfo, ChunkingContext, ChunkingContextExt}, - module::Module, - output::OutputAssets, - }, - ecmascript::chunk::EcmascriptChunkingContext, +use turbopack_binding::turbopack::core::{ + chunk::{availability_info::AvailabilityInfo, ChunkingContext, ChunkingContextExt}, + module::Module, + output::OutputAssets, }; use super::include_modules_module::IncludeModulesModule; @@ -44,9 +41,9 @@ pub struct ClientReferencesChunks { #[turbo_tasks::function] pub async fn get_app_client_references_chunks( app_client_references: Vc, - client_chunking_context: Vc>, + client_chunking_context: Vc>, client_availability_info: Value, - ssr_chunking_context: Option>>, + ssr_chunking_context: Option>>, ) -> Result> { async move { // TODO Reconsider this. Maybe it need to be true in production. diff --git a/packages/next-swc/crates/next-core/src/next_app/app_client_shared_chunks.rs b/packages/next-swc/crates/next-core/src/next_app/app_client_shared_chunks.rs index 5426e218528d7..169ee91147ee9 100644 --- a/packages/next-swc/crates/next-core/src/next_app/app_client_shared_chunks.rs +++ b/packages/next-swc/crates/next-core/src/next_app/app_client_shared_chunks.rs @@ -1,22 +1,18 @@ use anyhow::Result; use turbo_tasks::{Value, Vc}; -use turbopack_binding::turbopack::{ - core::{ - chunk::{ - availability_info::AvailabilityInfo, ChunkGroupResult, ChunkingContext, - EvaluatableAssets, - }, - ident::AssetIdent, - output::OutputAssets, +use turbopack_binding::turbopack::core::{ + chunk::{ + availability_info::AvailabilityInfo, ChunkGroupResult, ChunkingContext, EvaluatableAssets, }, - ecmascript::chunk::EcmascriptChunkingContext, + ident::AssetIdent, + output::OutputAssets, }; #[turbo_tasks::function] pub async fn get_app_client_shared_chunk_group( ident: Vc, app_client_runtime_entries: Vc, - client_chunking_context: Vc>, + client_chunking_context: Vc>, ) -> Result> { if app_client_runtime_entries.await?.is_empty() { return Ok(ChunkGroupResult { diff --git a/packages/next-swc/crates/next-core/src/next_app/include_modules_module.rs b/packages/next-swc/crates/next-core/src/next_app/include_modules_module.rs index 9bcd391b75044..9efd893388144 100644 --- a/packages/next-swc/crates/next-core/src/next_app/include_modules_module.rs +++ b/packages/next-swc/crates/next-core/src/next_app/include_modules_module.rs @@ -1,4 +1,4 @@ -use anyhow::{Context, Result}; +use anyhow::Result; use turbo_tasks::{TryJoinIterExt, ValueToString, Vc}; use turbo_tasks_fs::glob::Glob; use turbopack_binding::turbopack::{ @@ -12,7 +12,7 @@ use turbopack_binding::turbopack::{ }, ecmascript::chunk::{ EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkPlaceable, - EcmascriptChunkType, EcmascriptChunkingContext, EcmascriptExports, + EcmascriptChunkType, EcmascriptExports, }, }; @@ -81,13 +81,6 @@ impl ChunkableModule for IncludeModulesModule { self: Vc, chunking_context: Vc>, ) -> Result>> { - let chunking_context = - Vc::try_resolve_downcast::>(chunking_context) - .await? - .context( - "chunking context must impl EcmascriptChunkingContext to use \ - EcmascriptClientReferenceProxyModule", - )?; Ok(Vc::upcast( IncludeModulesChunkItem { module: self, @@ -102,7 +95,7 @@ impl ChunkableModule for IncludeModulesModule { #[turbo_tasks::value] struct IncludeModulesChunkItem { module: Vc, - chunking_context: Vc>, + chunking_context: Vc>, } #[turbo_tasks::value_impl] @@ -135,7 +128,7 @@ impl ChunkItem for IncludeModulesChunkItem { #[turbo_tasks::value_impl] impl EcmascriptChunkItem for IncludeModulesChunkItem { #[turbo_tasks::function] - fn chunking_context(&self) -> Vc> { + fn chunking_context(&self) -> Vc> { self.chunking_context } diff --git a/packages/next-swc/crates/next-core/src/next_client/context.rs b/packages/next-swc/crates/next-core/src/next_client/context.rs index 475c5e315f7d7..afcf3182bd6dc 100644 --- a/packages/next-swc/crates/next-core/src/next_client/context.rs +++ b/packages/next-swc/crates/next-core/src/next_client/context.rs @@ -9,6 +9,7 @@ use turbopack_binding::{ turbopack::{ browser::{react_refresh::assert_can_resolve_react_refresh, BrowserChunkingContext}, core::{ + chunk::ChunkingContext, compile_time_info::{ CompileTimeDefineValue, CompileTimeDefines, CompileTimeInfo, FreeVarReference, FreeVarReferences, @@ -17,7 +18,7 @@ use turbopack_binding::{ free_var_references, resolve::{parse::Request, pattern::Pattern}, }, - ecmascript::{chunk::EcmascriptChunkingContext, TreeShakingMode}, + ecmascript::TreeShakingMode, node::{ execution_context::ExecutionContext, transforms::postcss::{PostCssConfigLocation, PostCssTransformOptions}, @@ -324,7 +325,7 @@ pub async fn get_client_chunking_context( asset_prefix: Vc>, environment: Vc, mode: Vc, -) -> Result>> { +) -> Result>> { let next_mode = mode.await?; let mut builder = BrowserChunkingContext::builder( project_path, 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 c254882e22bd2..4a79236b1ed2b 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 @@ -19,7 +19,7 @@ use turbopack_binding::turbopack::{ ecmascript::{ chunk::{ EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkPlaceable, - EcmascriptChunkType, EcmascriptChunkingContext, EcmascriptExports, + EcmascriptChunkType, EcmascriptExports, }, utils::StringifyJs, EcmascriptModuleAsset, @@ -221,13 +221,6 @@ impl ChunkableModule for EcmascriptClientReferenceProxyModule { 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", - )?; Ok(Vc::upcast( ProxyModuleChunkItem { @@ -256,7 +249,7 @@ impl EcmascriptChunkPlaceable for EcmascriptClientReferenceProxyModule { struct ProxyModuleChunkItem { client_proxy_asset: Vc, inner_proxy_module_chunk_item: Vc>, - chunking_context: Vc>, + chunking_context: Vc>, } #[turbo_tasks::function] @@ -314,7 +307,7 @@ impl EcmascriptChunkItem for ProxyModuleChunkItem { } #[turbo_tasks::function] - fn chunking_context(&self) -> Vc> { + fn chunking_context(&self) -> Vc> { EcmascriptChunkItem::chunking_context(self.inner_proxy_module_chunk_item) } } diff --git a/packages/next-swc/crates/next-core/src/next_edge/context.rs b/packages/next-swc/crates/next-core/src/next_edge/context.rs index 8541bf74153a1..28e96e5471c2a 100644 --- a/packages/next-swc/crates/next-core/src/next_edge/context.rs +++ b/packages/next-swc/crates/next-core/src/next_edge/context.rs @@ -6,6 +6,7 @@ use turbopack_binding::{ turbopack::{ browser::BrowserChunkingContext, core::{ + chunk::ChunkingContext, compile_time_info::{ CompileTimeDefineValue, CompileTimeDefines, CompileTimeInfo, FreeVarReference, FreeVarReferences, @@ -13,7 +14,6 @@ use turbopack_binding::{ environment::{EdgeWorkerEnvironment, Environment, ExecutionEnvironment}, free_var_references, }, - ecmascript::chunk::EcmascriptChunkingContext, node::execution_context::ExecutionContext, turbopack::resolve_options_context::ResolveOptionsContext, }, @@ -173,7 +173,7 @@ pub async fn get_edge_chunking_context_with_client_assets( client_root: Vc, asset_prefix: Vc>, environment: Vc, -) -> Result>> { +) -> Result>> { let output_root = node_root.join("server/edge".to_string()); let next_mode = mode.await?; Ok(Vc::upcast( @@ -198,7 +198,7 @@ pub async fn get_edge_chunking_context( project_path: Vc, node_root: Vc, environment: Vc, -) -> Result>> { +) -> Result>> { let output_root = node_root.join("server/edge".to_string()); let next_mode = mode.await?; Ok(Vc::upcast( 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 286fe3837a239..2d9e831b41c5a 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 @@ -5,11 +5,11 @@ use turbo_tasks_fs::{File, FileSystemPath}; use turbopack_binding::turbopack::{ core::{ asset::AssetContent, - chunk::{ChunkItemExt, ChunkableModule, ModuleId as TurbopackModuleId}, + chunk::{ChunkItemExt, ChunkableModule, ChunkingContext, ModuleId as TurbopackModuleId}, output::OutputAsset, virtual_output::VirtualOutputAsset, }, - ecmascript::{chunk::EcmascriptChunkingContext, utils::StringifyJs}, + ecmascript::utils::StringifyJs, }; use super::{ClientReferenceManifest, ManifestNode, ManifestNodeEntry, ModuleId}; @@ -29,8 +29,8 @@ impl ClientReferenceManifest { entry_name: String, client_references: Vc, client_references_chunks: Vc, - client_chunking_context: Vc>, - ssr_chunking_context: Option>>, + client_chunking_context: Vc>, + ssr_chunking_context: Option>>, next_config: Vc, runtime: NextRuntime, ) -> Result>> { 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 8eb7a26fbe321..8aeb725046a91 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,6 +1,6 @@ use std::collections::BTreeMap; -use anyhow::{bail, Context, Result}; +use anyhow::{bail, Result}; use indoc::formatdoc; use turbo_tasks::Vc; use turbo_tasks_fs::FileSystemPath; @@ -19,7 +19,7 @@ use turbopack_binding::turbopack::{ turbopack::ecmascript::{ chunk::{ EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkPlaceable, - EcmascriptChunkingContext, EcmascriptExports, + EcmascriptExports, }, utils::StringifyJs, }, @@ -81,16 +81,9 @@ impl ChunkableModule for NextServerComponentModule { self: Vc, 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, + chunking_context, inner: self, } .cell(), @@ -122,15 +115,15 @@ impl EcmascriptChunkPlaceable for NextServerComponentModule { #[turbo_tasks::value] struct BuildServerComponentChunkItem { - context: Vc>, + chunking_context: Vc>, inner: Vc, } #[turbo_tasks::value_impl] impl EcmascriptChunkItem for BuildServerComponentChunkItem { #[turbo_tasks::function] - fn chunking_context(&self) -> Vc> { - self.context + fn chunking_context(&self) -> Vc> { + self.chunking_context } #[turbo_tasks::function] @@ -140,7 +133,7 @@ impl EcmascriptChunkItem for BuildServerComponentChunkItem { let module_id = inner .module - .as_chunk_item(Vc::upcast(this.context)) + .as_chunk_item(Vc::upcast(this.chunking_context)) .id() .await?; Ok(EcmascriptChunkItemContent { @@ -173,7 +166,7 @@ impl ChunkItem for BuildServerComponentChunkItem { #[turbo_tasks::function] async fn chunking_context(&self) -> Vc> { - Vc::upcast(self.context) + self.chunking_context } #[turbo_tasks::function]