diff --git a/Cargo.lock b/Cargo.lock index 11129102795da..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-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "serde", "smallvec", @@ -3516,7 +3516,7 @@ dependencies = [ [[package]] name = "node-file-trace" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "serde", @@ -7369,7 +7369,7 @@ dependencies = [ [[package]] name = "turbo-tasks" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "async-trait", @@ -7401,7 +7401,7 @@ dependencies = [ [[package]] name = "turbo-tasks-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "cargo-lock", @@ -7413,7 +7413,7 @@ dependencies = [ [[package]] name = "turbo-tasks-bytes" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "bytes", @@ -7428,7 +7428,7 @@ dependencies = [ [[package]] name = "turbo-tasks-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "dotenvs", @@ -7442,7 +7442,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fetch" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7459,7 +7459,7 @@ dependencies = [ [[package]] name = "turbo-tasks-fs" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "auto-hash-map", @@ -7489,7 +7489,7 @@ dependencies = [ [[package]] name = "turbo-tasks-hash" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "base16", "hex", @@ -7501,7 +7501,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -7515,7 +7515,7 @@ dependencies = [ [[package]] name = "turbo-tasks-macros-shared" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "proc-macro2", "quote", @@ -7525,7 +7525,7 @@ dependencies = [ [[package]] name = "turbo-tasks-malloc" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "mimalloc", ] @@ -7533,7 +7533,7 @@ dependencies = [ [[package]] name = "turbo-tasks-memory" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "auto-hash-map", @@ -7558,7 +7558,7 @@ dependencies = [ [[package]] name = "turbopack" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "async-recursion", @@ -7589,7 +7589,7 @@ dependencies = [ [[package]] name = "turbopack-binding" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "auto-hash-map", "mdxjs", @@ -7629,7 +7629,7 @@ dependencies = [ [[package]] name = "turbopack-build" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7651,7 +7651,7 @@ dependencies = [ [[package]] name = "turbopack-cli-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "clap 4.4.2", @@ -7675,7 +7675,7 @@ dependencies = [ [[package]] name = "turbopack-core" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "async-recursion", @@ -7705,7 +7705,7 @@ dependencies = [ [[package]] name = "turbopack-css" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "async-trait", @@ -7727,7 +7727,7 @@ dependencies = [ [[package]] name = "turbopack-dev" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7751,7 +7751,7 @@ dependencies = [ [[package]] name = "turbopack-dev-server" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "async-compression", @@ -7788,7 +7788,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "async-trait", @@ -7822,7 +7822,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-hmr-protocol" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "serde", "serde_json", @@ -7833,7 +7833,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-plugins" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "async-trait", @@ -7856,7 +7856,7 @@ dependencies = [ [[package]] name = "turbopack-ecmascript-runtime" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "indoc", @@ -7873,7 +7873,7 @@ dependencies = [ [[package]] name = "turbopack-env" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "indexmap 1.9.3", @@ -7889,7 +7889,7 @@ dependencies = [ [[package]] name = "turbopack-image" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "base64 0.21.4", @@ -7909,7 +7909,7 @@ dependencies = [ [[package]] name = "turbopack-json" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "serde", @@ -7924,7 +7924,7 @@ dependencies = [ [[package]] name = "turbopack-mdx" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "mdxjs", @@ -7939,7 +7939,7 @@ dependencies = [ [[package]] name = "turbopack-node" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "async-stream", @@ -7974,7 +7974,7 @@ dependencies = [ [[package]] name = "turbopack-static" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "anyhow", "serde", @@ -7990,7 +7990,7 @@ dependencies = [ [[package]] name = "turbopack-swc-utils" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.3#1e7c4b84f11561db5c6c671480e55e6cc8d9f481" dependencies = [ "swc_core", "turbo-tasks", @@ -8001,7 +8001,7 @@ dependencies = [ [[package]] name = "turbopack-wasm" version = "0.1.0" -source = "git+https://github.com/vercel/turbo.git?tag=turbopack-231013.2#9c1b3ba96b6f452c2c6d46b2c0d50c80df1b4699" +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 465220a2c2bd3..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-231013.2" } +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-231013.2" } +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-231013.2" } +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/pages.rs b/packages/next-swc/crates/next-api/src/pages.rs index 3754a4cce1b96..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)) 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/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 9300868c73837..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-231013.2", + "@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 c6b5b43d22c0e..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-231013.2 - version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231013.2(react-refresh@0.12.0)(webpack@5.86.0)' + 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-231013.2(react-refresh@0.12.0)(webpack@5.86.0)': - resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231013.2} - id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231013.2' + '@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: