From 0f43e4ea387850b683037566cbb1dfd0df8a6040 Mon Sep 17 00:00:00 2001 From: Jude Gao Date: Sun, 27 Oct 2024 13:45:30 -0400 Subject: [PATCH 1/6] Add Jude to nextjs team (#71936) ### What? Add @gaojude to Next.js team user group --------- Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com> --- .github/labeler.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/labeler.json b/.github/labeler.json index 0f1575da620bb..8c6ffd1d05b4c 100644 --- a/.github/labeler.json +++ b/.github/labeler.json @@ -21,18 +21,15 @@ ], "created-by: Next.js team": [ { "type": "user", "pattern": "acdlite" }, - { "type": "user", "pattern": "balazsorban44" }, { "type": "user", "pattern": "devjiwonchoi" }, { "type": "user", "pattern": "eps1lon" }, { "type": "user", "pattern": "feedthejim" }, + { "type": "user", "pattern": "gaojude" }, { "type": "user", "pattern": "gnoff" }, { "type": "user", "pattern": "huozhi" }, { "type": "user", "pattern": "ijjk" }, - { "type": "user", "pattern": "javivelasco" }, - { "type": "user", "pattern": "kikobeats" }, { "type": "user", "pattern": "lubieowoce" }, { "type": "user", "pattern": "samcx" }, - { "type": "user", "pattern": "schniz" }, { "type": "user", "pattern": "sebmarkbage" }, { "type": "user", "pattern": "shuding" }, { "type": "user", "pattern": "styfle" }, From ea7319c13c541c4e8a0cc55badc9621647b02e19 Mon Sep 17 00:00:00 2001 From: Benjamin Woodruff Date: Sun, 27 Oct 2024 13:15:20 -0700 Subject: [PATCH 2/6] codemod(turbopack): Rewrite Vc fields in structs as ResolvedVc (part 4) (#71804) Generated using a version of https://github.com/vercel/turbopack-resolved-vc-codemod . This uses Anthropic Claude Sonnet 3.5 for more complicated errors we don't have hardcoded logic for. - Part 1: #70927 - Part 2: #71172 - Part 3: #71665 Closes PACK-3336 --- .../ecmascript_client_reference_transition.rs | 2 +- turbopack/crates/node-file-trace/src/lib.rs | 24 +-- .../turbopack-browser/src/chunking_context.rs | 4 +- .../src/ecmascript/merged/update.rs | 4 +- .../src/ecmascript/update.rs | 14 +- .../turbopack-cli-utils/src/runtime_entry.rs | 2 +- .../crates/turbopack-cli/src/build/mod.rs | 2 +- .../turbopack-cli/src/dev/web_entry_source.rs | 4 +- turbopack/crates/turbopack-cli/src/util.rs | 4 +- .../src/chunk/available_chunk_items.rs | 14 +- .../turbopack-core/src/chunk/chunk_group.rs | 27 +++- .../crates/turbopack-core/src/chunk/mod.rs | 40 ++--- .../turbopack-core/src/chunk/optimize.rs | 6 +- .../src/introspect/output_asset.rs | 14 +- .../turbopack-core/src/reference_type.rs | 4 +- .../crates/turbopack-core/src/resolve/mod.rs | 143 ++++++++++-------- .../turbopack-core/src/resolve/options.rs | 37 +++-- .../turbopack-core/src/resolve/pattern.rs | 14 +- .../src/references/async_module.rs | 2 +- .../src/references/esm/base.rs | 2 +- .../turbopack-nodejs/src/chunking_context.rs | 4 +- turbopack/crates/turbopack/src/lib.rs | 2 +- 22 files changed, 209 insertions(+), 160 deletions(-) diff --git a/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_transition.rs b/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_transition.rs index 045d2c7035b69..8c74b601d2f8a 100644 --- a/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_transition.rs +++ b/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_transition.rs @@ -61,7 +61,7 @@ impl Transition for NextEcmascriptClientReferenceTransition { let this = self.await?; let ident = match part { - Some(part) => source.ident().with_part(part), + Some(part) => source.ident().with_part(*part), None => source.ident(), }; let ident_ref = ident.await?; diff --git a/turbopack/crates/node-file-trace/src/lib.rs b/turbopack/crates/node-file-trace/src/lib.rs index 197248c429954..993cbf5e681c6 100644 --- a/turbopack/crates/node-file-trace/src/lib.rs +++ b/turbopack/crates/node-file-trace/src/lib.rs @@ -23,8 +23,8 @@ use serde::Deserialize; use serde::Serialize; use tokio::sync::mpsc::channel; use turbo_tasks::{ - backend::Backend, util::FormatDuration, RcStr, ReadConsistency, TaskId, TransientInstance, - TransientValue, TurboTasks, UpdateInfo, Value, Vc, + backend::Backend, util::FormatDuration, RcStr, ReadConsistency, ResolvedVc, TaskId, + TransientInstance, TransientValue, TurboTasks, UpdateInfo, Value, Vc, }; use turbo_tasks_fs::{ glob::Glob, DirectoryEntry, DiskFileSystem, FileSystem, FileSystemPath, ReadGlobResult, @@ -565,11 +565,11 @@ async fn main_operation( #[turbo_tasks::function] async fn create_module_asset( - root: Vc, + root: ResolvedVc, process_cwd: Option, module_options: TransientInstance, resolve_options: TransientInstance, -) -> Vc { +) -> Result> { let env = Environment::new(Value::new(ExecutionEnvironment::NodeJsLambda( NodeJsEnvironment { cwd: Vc::cell(process_cwd), @@ -581,13 +581,17 @@ async fn create_module_asset( let glob_mappings = vec![ ( root, - Glob::new("**/*/next/dist/server/next.js".into()), - ImportMapping::Ignore.into(), + Glob::new("**/*/next/dist/server/next.js".into()) + .to_resolved() + .await?, + ImportMapping::Ignore.resolved_cell(), ), ( root, - Glob::new("**/*/next/dist/bin/next".into()), - ImportMapping::Ignore.into(), + Glob::new("**/*/next/dist/bin/next".into()) + .to_resolved() + .await?, + ImportMapping::Ignore.resolved_cell(), ), ]; let mut resolve_options = ResolveOptionsContext::clone(&*resolve_options); @@ -603,13 +607,13 @@ async fn create_module_asset( ); } - ModuleAssetContext::new( + Ok(ModuleAssetContext::new( Default::default(), compile_time_info, ModuleOptionsContext::clone(&*module_options).cell(), resolve_options.cell(), Vc::cell("node_file_trace".into()), - ) + )) } fn register() { diff --git a/turbopack/crates/turbopack-browser/src/chunking_context.rs b/turbopack/crates/turbopack-browser/src/chunking_context.rs index d1bab2c0355e1..4f677f4248fb6 100644 --- a/turbopack/crates/turbopack-browser/src/chunking_context.rs +++ b/turbopack/crates/turbopack-browser/src/chunking_context.rs @@ -386,7 +386,7 @@ impl ChunkingContext for BrowserChunkingContext { let mut assets: Vec>> = chunks .iter() - .map(|chunk| self.generate_chunk(*chunk)) + .map(|chunk| self.generate_chunk(**chunk)) .collect(); if this.enable_hot_module_replacement { @@ -455,7 +455,7 @@ impl ChunkingContext for BrowserChunkingContext { let mut assets: Vec>> = chunks .iter() - .map(|chunk| self.generate_chunk(*chunk)) + .map(|chunk| self.generate_chunk(**chunk)) .collect(); let other_assets = Vc::cell(assets.clone()); diff --git a/turbopack/crates/turbopack-browser/src/ecmascript/merged/update.rs b/turbopack/crates/turbopack-browser/src/ecmascript/merged/update.rs index 79809d5395d6a..48ea045b72879 100644 --- a/turbopack/crates/turbopack-browser/src/ecmascript/merged/update.rs +++ b/turbopack/crates/turbopack-browser/src/ecmascript/merged/update.rs @@ -215,7 +215,7 @@ pub(super) async fn update_ecmascript_merged_chunk( if merged_module_map.get(&module_id) != Some(module_hash) { let entry = EcmascriptModuleEntry::from_code( &module_id, - module_code, + *module_code, chunk_path, ) .await?; @@ -227,7 +227,7 @@ pub(super) async fn update_ecmascript_merged_chunk( for (module_id, module_code) in chunk_partial.modified { let entry = - EcmascriptModuleEntry::from_code(&module_id, module_code, chunk_path) + EcmascriptModuleEntry::from_code(&module_id, *module_code, chunk_path) .await?; merged_update.entries.insert(module_id, entry); } diff --git a/turbopack/crates/turbopack-browser/src/ecmascript/update.rs b/turbopack/crates/turbopack-browser/src/ecmascript/update.rs index 5c54f8aeb4b22..fb92948275f64 100644 --- a/turbopack/crates/turbopack-browser/src/ecmascript/update.rs +++ b/turbopack/crates/turbopack-browser/src/ecmascript/update.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::{FxIndexMap, ReadRef, Vc}; +use turbo_tasks::{FxIndexMap, ReadRef, ResolvedVc, Vc}; use turbopack_core::{chunk::ModuleId, code_builder::Code}; use super::{content::EcmascriptDevChunkContent, version::EcmascriptDevChunkVersion}; @@ -11,9 +11,9 @@ pub(super) enum EcmascriptChunkUpdate { } pub(super) struct EcmascriptChunkPartialUpdate { - pub added: FxIndexMap, (u64, Vc)>, + pub added: FxIndexMap, (u64, ResolvedVc)>, pub deleted: FxIndexMap, u64>, - pub modified: FxIndexMap, Vc>, + pub modified: FxIndexMap, ResolvedVc>, } pub(super) async fn update_ecmascript_chunk( @@ -40,7 +40,8 @@ pub(super) async fn update_ecmascript_chunk( for (id, from_hash) in &from.entries_hashes { if let Some(entry) = entries.get(id) { if *entry.hash.await? != *from_hash { - modified.insert(id.clone(), entry.code); + let resolved_code = entry.code.to_resolved().await?; + modified.insert(id.clone(), resolved_code); } } else { deleted.insert(id.clone(), *from_hash); @@ -50,7 +51,10 @@ pub(super) async fn update_ecmascript_chunk( // Remaining entries are added for (id, entry) in entries.iter() { if !from.entries_hashes.contains_key(id) { - added.insert(id.clone(), (*entry.hash.await?, entry.code)); + added.insert( + id.clone(), + (*entry.hash.await?, entry.code.to_resolved().await?), + ); } } diff --git a/turbopack/crates/turbopack-cli-utils/src/runtime_entry.rs b/turbopack/crates/turbopack-cli-utils/src/runtime_entry.rs index 6bee158c7413f..8f38df55b861a 100644 --- a/turbopack/crates/turbopack-cli-utils/src/runtime_entry.rs +++ b/turbopack/crates/turbopack-cli-utils/src/runtime_entry.rs @@ -62,7 +62,7 @@ impl RuntimeEntry { } #[turbo_tasks::value(transparent)] -pub struct RuntimeEntries(Vec>); +pub struct RuntimeEntries(Vec>); #[turbo_tasks::value_impl] impl RuntimeEntries { diff --git a/turbopack/crates/turbopack-cli/src/build/mod.rs b/turbopack/crates/turbopack-cli/src/build/mod.rs index 635fa6f6472fd..bc794d3f1bdd6 100644 --- a/turbopack/crates/turbopack-cli/src/build/mod.rs +++ b/turbopack/crates/turbopack-cli/src/build/mod.rs @@ -118,7 +118,7 @@ impl TurbopackBuildBuilder { self.entry_requests .iter() .cloned() - .map(EntryRequest::cell) + .map(EntryRequest::resolved_cell) .collect(), ) .cell(), diff --git a/turbopack/crates/turbopack-cli/src/dev/web_entry_source.rs b/turbopack/crates/turbopack-cli/src/dev/web_entry_source.rs index 5412fecaa604a..e336c8abe54d4 100644 --- a/turbopack/crates/turbopack-cli/src/dev/web_entry_source.rs +++ b/turbopack/crates/turbopack-cli/src/dev/web_entry_source.rs @@ -72,7 +72,7 @@ pub async fn get_client_runtime_entries( request.to_resolved().await?, project_path.join("_".into()).to_resolved().await?, ) - .cell(), + .resolved_cell(), ) }; @@ -82,7 +82,7 @@ pub async fn get_client_runtime_entries( .to_resolved() .await?, )) - .cell(), + .resolved_cell(), ); Ok(Vc::cell(runtime_entries)) diff --git a/turbopack/crates/turbopack-cli/src/util.rs b/turbopack/crates/turbopack-cli/src/util.rs index 69ebdf0da9d4f..6e5c6a449a131 100644 --- a/turbopack/crates/turbopack-cli/src/util.rs +++ b/turbopack/crates/turbopack-cli/src/util.rs @@ -2,11 +2,11 @@ use std::{env::current_dir, path::PathBuf}; use anyhow::{Context, Result}; use dunce::canonicalize; -use turbo_tasks::{RcStr, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, Vc}; use turbo_tasks_fs::{DiskFileSystem, FileSystem}; #[turbo_tasks::value(transparent)] -pub struct EntryRequests(pub Vec>); +pub struct EntryRequests(pub Vec>); #[turbo_tasks::value(shared)] #[derive(Clone)] diff --git a/turbopack/crates/turbopack-core/src/chunk/available_chunk_items.rs b/turbopack/crates/turbopack-core/src/chunk/available_chunk_items.rs index b05c9d31f1de0..279e172a928e5 100644 --- a/turbopack/crates/turbopack-core/src/chunk/available_chunk_items.rs +++ b/turbopack/crates/turbopack-core/src/chunk/available_chunk_items.rs @@ -17,7 +17,9 @@ pub struct AvailableChunkItemInfo { pub struct OptionAvailableChunkItemInfo(Option); #[turbo_tasks::value(transparent)] -pub struct AvailableChunkItemInfoMap(FxIndexMap>, AvailableChunkItemInfo>); +pub struct AvailableChunkItemInfoMap( + FxIndexMap>, AvailableChunkItemInfo>, +); /// Allows to gather information about which assets are already available. /// Adding more roots will form a linked list like structure to allow caching @@ -41,7 +43,7 @@ impl AvailableChunkItems { #[turbo_tasks::function] pub async fn with_chunk_items( - self: Vc, + self: ResolvedVc, chunk_items: Vc, ) -> Result> { let chunk_items = chunk_items @@ -49,7 +51,7 @@ impl AvailableChunkItems { .into_iter() .map(|(&chunk_item, &info)| async move { Ok(self - .get(chunk_item) + .get(*chunk_item) .await? .is_none() .then_some((chunk_item, info))) @@ -57,7 +59,7 @@ impl AvailableChunkItems { .try_flat_join() .await?; Ok(AvailableChunkItems { - parent: Some(self.to_resolved().await?), + parent: Some(self), chunk_items: Vc::cell(chunk_items.into_iter().collect()), } .cell()) @@ -87,13 +89,13 @@ impl AvailableChunkItems { #[turbo_tasks::function] pub async fn get( &self, - chunk_item: Vc>, + chunk_item: ResolvedVc>, ) -> Result> { if let Some(&info) = self.chunk_items.await?.get(&chunk_item) { return Ok(Vc::cell(Some(info))); }; if let Some(parent) = self.parent { - return Ok(parent.get(chunk_item)); + return Ok(parent.get(*chunk_item)); } Ok(Vc::cell(None)) } diff --git a/turbopack/crates/turbopack-core/src/chunk/chunk_group.rs b/turbopack/crates/turbopack-core/src/chunk/chunk_group.rs index 2cebdd266cf39..b6e8c3035e37b 100644 --- a/turbopack/crates/turbopack-core/src/chunk/chunk_group.rs +++ b/turbopack/crates/turbopack-core/src/chunk/chunk_group.rs @@ -2,7 +2,9 @@ use std::collections::HashSet; use anyhow::Result; use auto_hash_map::AutoSet; -use turbo_tasks::{FxIndexMap, FxIndexSet, TryFlatJoinIterExt, TryJoinIterExt, Value, Vc}; +use turbo_tasks::{ + FxIndexMap, FxIndexSet, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Value, Vc, +}; use super::{ availability_info::AvailabilityInfo, available_chunk_items::AvailableChunkItemInfo, @@ -12,7 +14,7 @@ use super::{ use crate::{module::Module, output::OutputAssets, reference::ModuleReference}; pub struct MakeChunkGroupResult { - pub chunks: Vec>>, + pub chunks: Vec>>, pub availability_info: AvailabilityInfo, } @@ -104,14 +106,17 @@ pub async fn make_chunk_group( let availability_info = { let map = chunk_items .iter() - .map(|(&chunk_item, async_info)| { - ( - chunk_item, + .map(|(&chunk_item, async_info)| async move { + Ok(( + chunk_item.to_resolved().await?, AvailableChunkItemInfo { is_async: async_info.is_some(), }, - ) + )) }) + .try_join() + .await? + .into_iter() .collect(); let map = Vc::cell(map); availability_info.with_chunk_items(map).await? @@ -121,7 +126,7 @@ pub async fn make_chunk_group( let async_loaders = async_modules .into_iter() .map(|module| { - chunking_context.async_loader_chunk_item(module, Value::new(availability_info)) + chunking_context.async_loader_chunk_item(*module, Value::new(availability_info)) }) .collect::>(); let has_async_loaders = !async_loaders.is_empty(); @@ -164,8 +169,14 @@ pub async fn make_chunk_group( chunks.extend(async_loader_chunks.iter().copied()); } + let resolved_chunks = chunks + .into_iter() + .map(|chunk| chunk.to_resolved()) + .try_join() + .await?; + Ok(MakeChunkGroupResult { - chunks, + chunks: resolved_chunks, availability_info, }) } diff --git a/turbopack/crates/turbopack-core/src/chunk/mod.rs b/turbopack/crates/turbopack-core/src/chunk/mod.rs index 1daf8422e0e06..ebb8e19394cdd 100644 --- a/turbopack/crates/turbopack-core/src/chunk/mod.rs +++ b/turbopack/crates/turbopack-core/src/chunk/mod.rs @@ -190,7 +190,7 @@ type AsyncInfo = FxIndexMap>, Vec>>> pub struct ChunkContentResult { pub chunk_items: FxIndexSet>>, - pub async_modules: FxIndexSet>>, + pub async_modules: FxIndexSet>>, pub external_module_references: FxIndexSet>>, /// A map from local module to all children from which the async module /// status is inherited @@ -245,7 +245,7 @@ enum ChunkContentGraphNode { /// will be inherited. InheritAsyncInfo { item: Vc>, - references: Vec<(Vc>, InheritAsyncEdge)>, + references: Vec<(ResolvedVc>, InheritAsyncEdge)>, }, } @@ -413,7 +413,10 @@ async fn graph_node_to_referenced_nodes( ident: module.ident().to_string().await?, }, }), - Some((chunk_item, InheritAsyncEdge::LocalModule)), + Some(( + chunk_item.to_resolved().await?, + InheritAsyncEdge::LocalModule, + )), )) } ChunkingType::Passthrough => { @@ -590,10 +593,7 @@ async fn chunk_content_internal_parallel( Ok(Some(ChunkGraphEdge { key: Some(entry.to_resolved().await?), node: ChunkContentGraphNode::ChunkItem { - item: chunkable_module - .as_chunk_item(chunking_context) - .resolve() - .await?, + item: chunkable_module.as_chunk_item(chunking_context), ident: chunkable_module.ident().to_string().await?, }, })) @@ -626,10 +626,10 @@ async fn chunk_content_internal_parallel( match graph_node { ChunkContentGraphNode::PassthroughChunkItem { .. } => {} ChunkContentGraphNode::ChunkItem { item, .. } => { - chunk_items.insert(item); + chunk_items.insert(*item.to_resolved().await?); } ChunkContentGraphNode::AsyncModule { module } => { - let module = module.resolve().await?; + let module = module.to_resolved().await?; async_modules.insert(module); } ChunkContentGraphNode::ExternalModuleReference(reference) => { @@ -640,12 +640,12 @@ async fn chunk_content_internal_parallel( for &(reference, ty) in &references { match ty { InheritAsyncEdge::LocalModule => local_back_edges_inherit_async - .entry(reference) + .entry(*reference) .or_insert_with(Vec::new) .push(item), InheritAsyncEdge::AvailableAsyncModule => { available_async_modules_back_edges_inherit_async - .entry(reference) + .entry(*reference) .or_insert_with(Vec::new) .push(item) } @@ -654,7 +654,7 @@ async fn chunk_content_internal_parallel( forward_edges_inherit_async .entry(item) .or_insert_with(Vec::new) - .extend(references.into_iter().map(|(r, _)| r)); + .extend(references.into_iter().map(|(r, _)| *r)); } } } @@ -733,17 +733,23 @@ pub struct ChunkItems(pub Vec>>); #[turbo_tasks::value] pub struct AsyncModuleInfo { - pub referenced_async_modules: AutoSet>>, + pub referenced_async_modules: AutoSet>>, } #[turbo_tasks::value_impl] impl AsyncModuleInfo { #[turbo_tasks::function] - pub fn new(referenced_async_modules: Vec>>) -> Vc { - Self { - referenced_async_modules: referenced_async_modules.into_iter().collect(), + pub async fn new(referenced_async_modules: Vec>>) -> Result> { + let resolved_modules = referenced_async_modules + .into_iter() + .map(|m| m.to_resolved()) + .try_join() + .await?; + + Ok(Self { + referenced_async_modules: resolved_modules.into_iter().collect(), } - .cell() + .cell()) } } diff --git a/turbopack/crates/turbopack-core/src/chunk/optimize.rs b/turbopack/crates/turbopack-core/src/chunk/optimize.rs index bea7a542ce426..4da9b7a8cac53 100644 --- a/turbopack/crates/turbopack-core/src/chunk/optimize.rs +++ b/turbopack/crates/turbopack-core/src/chunk/optimize.rs @@ -4,17 +4,17 @@ //! their size and eliminating duplicates between them. use anyhow::Result; -use turbo_tasks::{TryJoinIterExt, Vc}; +use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc}; use turbo_tasks_fs::{FileSystemPath, FileSystemPathOption}; use crate::chunk::containment_tree::{ContainmentTree, ContainmentTreeKey}; #[derive(Debug, Clone, Eq, PartialEq, Hash)] -struct FileSystemPathKey(Vc); +struct FileSystemPathKey(ResolvedVc); impl FileSystemPathKey { async fn new(path: Vc) -> Result { - Ok(Self(path.resolve().await?)) + Ok(Self(path.to_resolved().await?)) } } diff --git a/turbopack/crates/turbopack-core/src/introspect/output_asset.rs b/turbopack/crates/turbopack-core/src/introspect/output_asset.rs index 946cdd30a8dd4..f681e72689aa9 100644 --- a/turbopack/crates/turbopack-core/src/introspect/output_asset.rs +++ b/turbopack/crates/turbopack-core/src/introspect/output_asset.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::{RcStr, ValueToString, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, ValueToString, Vc}; use super::{ utils::{children_from_output_assets, content_to_details}, @@ -8,15 +8,19 @@ use super::{ use crate::{asset::Asset, output::OutputAsset}; #[turbo_tasks::value] -pub struct IntrospectableOutputAsset(Vc>); +pub struct IntrospectableOutputAsset(ResolvedVc>); #[turbo_tasks::value_impl] impl IntrospectableOutputAsset { #[turbo_tasks::function] - pub async fn new(asset: Vc>) -> Result>> { - Ok(Vc::try_resolve_sidecast::>(asset) + pub async fn new( + asset: ResolvedVc>, + ) -> Result>> { + Ok(*ResolvedVc::try_sidecast::>(asset) .await? - .unwrap_or_else(|| Vc::upcast(IntrospectableOutputAsset(asset).cell()))) + .unwrap_or_else(|| { + ResolvedVc::upcast(IntrospectableOutputAsset(asset).resolved_cell()) + })) } } diff --git a/turbopack/crates/turbopack-core/src/reference_type.rs b/turbopack/crates/turbopack-core/src/reference_type.rs index 735e51bf79620..76fd2c332a354 100644 --- a/turbopack/crates/turbopack-core/src/reference_type.rs +++ b/turbopack/crates/turbopack-core/src/reference_type.rs @@ -1,7 +1,7 @@ use std::fmt::Display; use anyhow::Result; -use turbo_tasks::{FxIndexMap, RcStr, Vc}; +use turbo_tasks::{FxIndexMap, RcStr, ResolvedVc, Vc}; use crate::{module::Module, resolve::ModulePart}; @@ -42,7 +42,7 @@ pub enum ImportWithType { #[turbo_tasks::value(serialization = "auto_for_input")] #[derive(Debug, Default, Clone, Hash)] pub enum EcmaScriptModulesReferenceSubType { - ImportPart(Vc), + ImportPart(ResolvedVc), Import, ImportWithType(ImportWithType), DynamicImport, diff --git a/turbopack/crates/turbopack-core/src/resolve/mod.rs b/turbopack/crates/turbopack-core/src/resolve/mod.rs index 48cd30d40cc0b..2b8b044001569 100644 --- a/turbopack/crates/turbopack-core/src/resolve/mod.rs +++ b/turbopack/crates/turbopack-core/src/resolve/mod.rs @@ -1070,7 +1070,7 @@ async fn exports_field(package_json_path: Vc) -> Result, + ResolvedVc, ), None, } @@ -1094,7 +1094,7 @@ async fn imports_field(lookup_path: Vc) -> Result Ok(ImportsFieldResult::Some(imports, **package_json_path).cell()), + Ok(imports) => Ok(ImportsFieldResult::Some(imports, *package_json_path).cell()), Err(err) => { PackageJsonIssue { path: **package_json_path, @@ -1136,6 +1136,8 @@ pub async fn find_context_file( if refs.is_empty() { // Tailcall Ok(find_context_file( + // Hot codepath optimization: resolve all arguments to avoid an automatically-created + // intermediate task lookup_path.parent().resolve().await?, names, )) @@ -1151,7 +1153,7 @@ pub async fn find_context_file( FindContextFileResult::NotFound(refs) } } - .into()) + .cell()) } } @@ -1584,16 +1586,16 @@ async fn handle_after_resolve_plugins( #[turbo_tasks::function] async fn resolve_internal( - lookup_path: Vc, - request: Vc, + lookup_path: ResolvedVc, + request: ResolvedVc, options: Vc, ) -> Result> { resolve_internal_inline(lookup_path, request, options).await } async fn resolve_internal_inline( - lookup_path: Vc, - request: Vc, + lookup_path: ResolvedVc, + request: ResolvedVc, options: Vc, ) -> Result> { let span = { @@ -1614,17 +1616,17 @@ async fn resolve_internal_inline( if let Some(import_map) = &options_value.import_map { let request_parts = match &*request_value { Request::Alternatives { requests } => requests.as_slice(), - _ => &[request], + _ => &[*request], }; for request in request_parts { - let result = import_map.await?.lookup(lookup_path, *request).await?; + let result = import_map.await?.lookup(*lookup_path, *request).await?; if !matches!(result, ImportMapResult::NoEntry) { has_alias = true; let resolved_result = resolve_import_map_result( &result, lookup_path, lookup_path, - *request, + request.to_resolved().await?, options, request.query(), ) @@ -1649,7 +1651,10 @@ async fn resolve_internal_inline( Request::Alternatives { requests } => { let results = requests .iter() - .map(|req| Box::pin(resolve_internal_inline(lookup_path, *req, options))) + .map(|req| async { + resolve_internal_inline(lookup_path, req.to_resolved().await?, options) + .await + }) .try_join() .await?; @@ -1663,7 +1668,7 @@ async fn resolve_internal_inline( } => { let mut results = Vec::new(); let matches = read_matches( - lookup_path, + *lookup_path, "".into(), *force_in_lookup_dir, Pattern::new(path.clone()).resolve().await?, @@ -1764,8 +1769,8 @@ async fn resolve_internal_inline( ResolvingIssue { severity: error_severity(options).await?, request_type: "server relative import: not implemented yet".to_string(), - request, - file_path: lookup_path, + request: *request, + file_path: *lookup_path, resolve_options: options, error_message: Some( "server relative imports are not implemented yet. Please try an \ @@ -1779,8 +1784,8 @@ async fn resolve_internal_inline( } Box::pin(resolve_internal_inline( - lookup_path.root().resolve().await?, - relative.resolve().await?, + lookup_path.root().to_resolved().await?, + relative.to_resolved().await?, options, )) .await? @@ -1794,8 +1799,8 @@ async fn resolve_internal_inline( ResolvingIssue { severity: error_severity(options).await?, request_type: "windows import: not implemented yet".to_string(), - request, - file_path: lookup_path, + request: *request, + file_path: *lookup_path, resolve_options: options, error_message: Some("windows imports are not implemented yet".to_string()), source: None, @@ -1848,8 +1853,8 @@ async fn resolve_internal_inline( ResolvingIssue { severity: error_severity(options).await?, request_type: format!("unknown import: `{}`", path), - request, - file_path: lookup_path, + request: *request, + file_path: *lookup_path, resolve_options: options, error_message: None, source: None, @@ -1864,7 +1869,7 @@ async fn resolve_internal_inline( // Apply fallback import mappings if provided if let Some(import_map) = &options_value.fallback_import_map { if *result.is_unresolvable().await? { - let result = import_map.await?.lookup(lookup_path, request).await?; + let result = import_map.await?.lookup(*lookup_path, *request).await?; let resolved_result = resolve_import_map_result( &result, lookup_path, @@ -1890,7 +1895,7 @@ async fn resolve_internal_inline( #[turbo_tasks::function] async fn resolve_into_folder( - package_path: Vc, + package_path: ResolvedVc, options: Vc, ) -> Result> { let package_json_path = package_path.join("package.json".into()); @@ -1908,7 +1913,9 @@ async fn resolve_into_folder( { continue; } - let request = Request::parse(Value::new(normalized_request.into())); + let request = Request::parse(Value::new(normalized_request.into())) + .to_resolved() + .await?; // main field will always resolve not fully specified let options = if options_value.fully_specified { @@ -1954,7 +1961,7 @@ async fn resolve_into_folder( let request = Request::parse(Value::new(pattern)); Ok( - resolve_internal_inline(package_path, request.resolve().await?, options) + resolve_internal_inline(package_path, request.to_resolved().await?, options) .await? .with_request(".".into()), ) @@ -1962,8 +1969,8 @@ async fn resolve_into_folder( #[tracing::instrument(level = Level::TRACE, skip_all)] async fn resolve_relative_request( - lookup_path: Vc, - request: Vc, + lookup_path: ResolvedVc, + request: ResolvedVc, options: Vc, options_value: &ResolveOptions, path_pattern: &Pattern, @@ -1974,7 +1981,7 @@ async fn resolve_relative_request( // Check alias field for aliases first let lookup_path_ref = &*lookup_path.await?; if let Some(result) = apply_in_package( - lookup_path, + *lookup_path, options, options_value, |package_path| { @@ -2061,7 +2068,7 @@ async fn resolve_relative_request( let mut results = Vec::new(); let matches = read_matches( - lookup_path, + *lookup_path, "".into(), force_in_lookup_dir, Pattern::new(new_path).resolve().await?, @@ -2304,8 +2311,8 @@ async fn find_self_reference( #[tracing::instrument(level = Level::TRACE, skip_all)] async fn resolve_module_request( - lookup_path: Vc, - request: Vc, + lookup_path: ResolvedVc, + request: ResolvedVc, options: Vc, options_value: &ResolveOptions, module: &str, @@ -2315,7 +2322,7 @@ async fn resolve_module_request( ) -> Result> { // Check alias field for module aliases first if let Some(result) = apply_in_package( - lookup_path, + *lookup_path, options, options_value, |_| { @@ -2334,7 +2341,7 @@ async fn resolve_module_request( // module. This should match only using the exports field and no other // fields/fallbacks. if let FindSelfReferencePackageResult::Found { name, package_path } = - &*find_self_reference(lookup_path).await? + &*find_self_reference(*lookup_path).await? { if name == module { let result = resolve_into_package( @@ -2351,7 +2358,7 @@ async fn resolve_module_request( } let result = find_package( - lookup_path, + *lookup_path, module.into(), resolve_modules_options(options).resolve().await?, ) @@ -2412,13 +2419,11 @@ async fn resolve_module_request( RcStr::from("/").into(), path.clone(), ]); - let relative = Request::relative(Value::new(pattern), query, fragment, true); - let relative_result = Box::pin(resolve_internal_inline( - lookup_path, - relative.resolve().await?, - options, - )) - .await?; + let relative = Request::relative(Value::new(pattern), query, fragment, true) + .to_resolved() + .await?; + let relative_result = + Box::pin(resolve_internal_inline(lookup_path, relative, options)).await?; let relative_result = relative_result .with_replaced_request_key(module_prefix, Value::new(RequestKey::new(module.into()))); @@ -2431,7 +2436,7 @@ async fn resolve_module_request( #[turbo_tasks::function] async fn resolve_into_package( path: Value, - package_path: Vc, + package_path: ResolvedVc, query: Vc, fragment: Vc, options: Vc, @@ -2492,7 +2497,7 @@ async fn resolve_into_package( // apply main field(s) or fallback to index.js if there's no subpath if is_root_match { results.push(resolve_into_folder( - package_path, + *package_path, options.with_fully_specified(false), )); } @@ -2501,9 +2506,10 @@ async fn resolve_into_package( let mut new_pat = path.clone(); new_pat.push_front(RcStr::from(".").into()); - let relative = Request::relative(Value::new(new_pat), query, fragment, true); - results - .push(resolve_internal_inline(package_path, relative.resolve().await?, options).await?); + let relative = Request::relative(Value::new(new_pat), query, fragment, true) + .to_resolved() + .await?; + results.push(resolve_internal_inline(package_path, relative, options).await?); } Ok(merge_results(results)) @@ -2512,9 +2518,9 @@ async fn resolve_into_package( #[tracing::instrument(level = Level::TRACE, skip_all)] async fn resolve_import_map_result( result: &ImportMapResult, - lookup_path: Vc, - original_lookup_path: Vc, - original_request: Vc, + lookup_path: ResolvedVc, + original_lookup_path: ResolvedVc, + original_request: ResolvedVc, options: Vc, query: Vc, ) -> Result>> { @@ -2522,14 +2528,15 @@ async fn resolve_import_map_result( ImportMapResult::Result(result) => Some(*result), ImportMapResult::Alias(request, alias_lookup_path) => { let request = *request; - let lookup_path = alias_lookup_path.unwrap_or(lookup_path); + let lookup_path = match alias_lookup_path { + Some(path) => *path, + None => lookup_path, + }; // We must avoid cycles during resolving - if request.resolve().await? == original_request - && lookup_path.resolve().await? == original_lookup_path - { + if request == original_request && lookup_path == original_lookup_path { None } else { - let result = resolve_internal(lookup_path, request, options); + let result = resolve_internal(*lookup_path, *request, options); Some(result.with_replaced_request_key_pattern( request.request_pattern(), original_request.request_pattern(), @@ -2562,8 +2569,8 @@ async fn resolve_import_map_result( async fn resolved( request_key: RequestKey, fs_path: Vc, - original_context: Vc, - original_request: Vc, + original_context: ResolvedVc, + original_request: ResolvedVc, options_value: &ResolveOptions, options: Vc, query: Vc, @@ -2588,12 +2595,12 @@ async fn resolved( if let Some(resolved_map) = options_value.resolved_map { let result = resolved_map - .lookup(**path, original_context, original_request) + .lookup(**path, *original_context, *original_request) .await?; let resolved_result = resolve_import_map_result( &result, - path.parent(), + path.parent().to_resolved().await?, original_context, original_request, options, @@ -2620,7 +2627,7 @@ async fn resolved( } async fn handle_exports_imports_field( - package_path: Vc, + package_path: ResolvedVc, package_json_path: Vc, options: Vc, exports_imports_field: &AliasMap, @@ -2657,7 +2664,9 @@ async fn handle_exports_imports_field( let request = Request::parse(Value::new(Pattern::Concatenation(vec![ Pattern::Constant("./".into()), result_path, - ]))); + ]))) + .to_resolved() + .await?; let resolve_result = Box::pin(resolve_internal_inline(package_path, request, options)).await?; @@ -2683,8 +2692,8 @@ async fn handle_exports_imports_field( /// static strings or conditions like `import` or `require` to handle ESM/CJS /// with differently compiled files. async fn resolve_package_internal_with_imports_field( - file_path: Vc, - request: Vc, + file_path: ResolvedVc, + request: ResolvedVc, resolve_options: Vc, pattern: &Pattern, conditions: &BTreeMap, @@ -2697,9 +2706,9 @@ async fn resolve_package_internal_with_imports_field( if specifier == "#" || specifier.starts_with("#/") || specifier.ends_with('/') { ResolvingIssue { severity: error_severity(resolve_options).await?, - file_path, + file_path: *file_path, request_type: format!("package imports request: `{specifier}`"), - request, + request: *request, resolve_options, error_message: None, source: None, @@ -2709,14 +2718,14 @@ async fn resolve_package_internal_with_imports_field( return Ok(ResolveResult::unresolvable().into()); } - let imports_result = imports_field(file_path).await?; + let imports_result = imports_field(*file_path).await?; let (imports, package_json_path) = match &*imports_result { - ImportsFieldResult::Some(i, p) => (i, p), - ImportsFieldResult::None => return Ok(ResolveResult::unresolvable().into()), + ImportsFieldResult::Some(i, p) => (i, *p), + ImportsFieldResult::None => return Ok(ResolveResult::unresolvable().cell()), }; handle_exports_imports_field( - package_json_path.parent(), + package_json_path.parent().to_resolved().await?, *package_json_path, resolve_options, imports, diff --git a/turbopack/crates/turbopack-core/src/resolve/options.rs b/turbopack/crates/turbopack-core/src/resolve/options.rs index 762c70b900d1e..9297d235e3f51 100644 --- a/turbopack/crates/turbopack-core/src/resolve/options.rs +++ b/turbopack/crates/turbopack-core/src/resolve/options.rs @@ -117,7 +117,7 @@ pub enum ReplacedImportMapping { Ignore, Empty, Alternatives(Vec>), - Dynamic(Vc>), + Dynamic(ResolvedVc>), } impl ImportMapping { @@ -162,7 +162,9 @@ impl AliasTemplate for Vc { .try_join() .await?, ), - ImportMapping::Dynamic(replacement) => ReplacedImportMapping::Dynamic(*replacement), + ImportMapping::Dynamic(replacement) => { + ReplacedImportMapping::Dynamic(replacement.to_resolved().await?) + } } .cell()) }) @@ -300,14 +302,18 @@ impl ImportMap { #[turbo_tasks::value(shared)] #[derive(Clone, Default)] pub struct ResolvedMap { - pub by_glob: Vec<(Vc, Vc, Vc)>, + pub by_glob: Vec<( + ResolvedVc, + ResolvedVc, + ResolvedVc, + )>, } #[turbo_tasks::value(shared)] #[derive(Clone, Debug)] pub enum ImportMapResult { Result(Vc), - Alias(Vc, Option>), + Alias(ResolvedVc, Option>), Alternatives(Vec), NoEntry, } @@ -320,25 +326,28 @@ async fn import_mapping_to_result( Ok(match &*mapping.await? { ReplacedImportMapping::Direct(result) => ImportMapResult::Result(*result), ReplacedImportMapping::External(name, ty) => ImportMapResult::Result( - ResolveResult::primary(if let Some(name) = name { + *ResolveResult::primary(if let Some(name) = name { ResolveResultItem::External(name.clone(), *ty) } else if let Some(request) = request.await?.request() { ResolveResultItem::External(request, *ty) } else { bail!("Cannot resolve external reference without request") }) - .cell(), + .resolved_cell(), + ), + ReplacedImportMapping::Ignore => ImportMapResult::Result( + *ResolveResult::primary(ResolveResultItem::Ignore).resolved_cell(), + ), + ReplacedImportMapping::Empty => ImportMapResult::Result( + *ResolveResult::primary(ResolveResultItem::Empty).resolved_cell(), ), - ReplacedImportMapping::Ignore => { - ImportMapResult::Result(ResolveResult::primary(ResolveResultItem::Ignore).into()) - } - ReplacedImportMapping::Empty => { - ImportMapResult::Result(ResolveResult::primary(ResolveResultItem::Empty).into()) - } ReplacedImportMapping::PrimaryAlternative(name, context) => { let request = Request::parse(Value::new(name.clone())); - - ImportMapResult::Alias(request, *context) + let context_resolved = match context { + Some(c) => Some((*c).to_resolved().await?), + None => None, + }; + ImportMapResult::Alias(request.to_resolved().await?, context_resolved) } ReplacedImportMapping::Alternatives(list) => ImportMapResult::Alternatives( list.iter() diff --git a/turbopack/crates/turbopack-core/src/resolve/pattern.rs b/turbopack/crates/turbopack-core/src/resolve/pattern.rs index 14297dcff4971..1f5b34013dac7 100644 --- a/turbopack/crates/turbopack-core/src/resolve/pattern.rs +++ b/turbopack/crates/turbopack-core/src/resolve/pattern.rs @@ -9,7 +9,7 @@ use lazy_static::lazy_static; use regex::Regex; use serde::{Deserialize, Serialize}; use tracing::Instrument; -use turbo_tasks::{trace::TraceRawVcs, RcStr, Value, ValueToString, Vc}; +use turbo_tasks::{trace::TraceRawVcs, RcStr, ResolvedVc, Value, ValueToString, Vc}; use turbo_tasks_fs::{ util::normalize_path, DirectoryContent, DirectoryEntry, FileSystemEntryType, FileSystemPath, LinkContent, LinkType, @@ -1322,7 +1322,7 @@ pub struct PatternMatches(Vec); /// symlinks when they are interested in that. #[turbo_tasks::function] pub async fn read_matches( - lookup_dir: Vc, + lookup_dir: ResolvedVc, prefix: RcStr, force_in_lookup_dir: bool, pattern: Vc, @@ -1468,17 +1468,17 @@ pub async fn read_matches( if let Some(pos) = pat.match_position(&prefix) { results.push(( pos, - PatternMatch::Directory(prefix.clone().into(), lookup_dir), + PatternMatch::Directory(prefix.clone().into(), *lookup_dir), )); } prefix.pop(); } if prefix.is_empty() { if let Some(pos) = pat.match_position("./") { - results.push((pos, PatternMatch::Directory("./".into(), lookup_dir))); + results.push((pos, PatternMatch::Directory("./".into(), *lookup_dir))); } if let Some(pos) = pat.could_match_position("./") { - nested.push((pos, read_matches(lookup_dir, "./".into(), false, pattern))); + nested.push((pos, read_matches(*lookup_dir, "./".into(), false, pattern))); } } else { prefix.push('/'); @@ -1486,7 +1486,7 @@ pub async fn read_matches( if let Some(pos) = pat.could_match_position(&prefix) { nested.push(( pos, - read_matches(lookup_dir, prefix.to_string().into(), false, pattern), + read_matches(*lookup_dir, prefix.to_string().into(), false, pattern), )); } prefix.pop(); @@ -1495,7 +1495,7 @@ pub async fn read_matches( if let Some(pos) = pat.could_match_position(&prefix) { nested.push(( pos, - read_matches(lookup_dir, prefix.to_string().into(), false, pattern), + read_matches(*lookup_dir, prefix.to_string().into(), false, pattern), )); } prefix.pop(); diff --git a/turbopack/crates/turbopack-ecmascript/src/references/async_module.rs b/turbopack/crates/turbopack-ecmascript/src/references/async_module.rs index 1be520f9e505d..67520294e2a6a 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/async_module.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/async_module.rs @@ -123,7 +123,7 @@ impl AsyncModule { ReferencedAsset::Some(placeable) => { let chunk_item = placeable .as_chunk_item(Vc::upcast(chunking_context)) - .resolve() + .to_resolved() .await?; if async_module_info .referenced_async_modules diff --git a/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs b/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs index b41a16c8b904b..190e745d0115f 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs @@ -153,7 +153,7 @@ impl ModuleReference for EsmAssetReference { let ty = if matches!(self.annotations.module_type(), Some("json")) { EcmaScriptModulesReferenceSubType::ImportWithType(ImportWithType::Json) } else if let Some(part) = &self.export_name { - EcmaScriptModulesReferenceSubType::ImportPart(**part) + EcmaScriptModulesReferenceSubType::ImportPart(*part) } else { EcmaScriptModulesReferenceSubType::Import }; diff --git a/turbopack/crates/turbopack-nodejs/src/chunking_context.rs b/turbopack/crates/turbopack-nodejs/src/chunking_context.rs index 719856fc7e721..3bad35b5c4134 100644 --- a/turbopack/crates/turbopack-nodejs/src/chunking_context.rs +++ b/turbopack/crates/turbopack-nodejs/src/chunking_context.rs @@ -282,7 +282,7 @@ impl ChunkingContext for NodeJsChunkingContext { let mut assets: Vec>> = chunks .iter() - .map(|chunk| self.generate_chunk(*chunk)) + .map(|chunk| self.generate_chunk(**chunk)) .collect(); // Resolve assets @@ -333,7 +333,7 @@ impl ChunkingContext for NodeJsChunkingContext { let other_chunks: Vec<_> = extra_chunks .iter() .copied() - .chain(chunks.iter().map(|chunk| self.generate_chunk(*chunk))) + .chain(chunks.iter().map(|chunk| self.generate_chunk(**chunk))) .collect(); let Some(module) = Vc::try_resolve_downcast(module).await? else { diff --git a/turbopack/crates/turbopack/src/lib.rs b/turbopack/crates/turbopack/src/lib.rs index 3dc82e7e63aa1..61d90bdee2541 100644 --- a/turbopack/crates/turbopack/src/lib.rs +++ b/turbopack/crates/turbopack/src/lib.rs @@ -484,7 +484,7 @@ async fn process_default_internal( let reference_type = reference_type.into_value(); let part: Option> = match &reference_type { ReferenceType::EcmaScriptModules(EcmaScriptModulesReferenceSubType::ImportPart(part)) => { - Some(*part) + Some(**part) } _ => None, }; From 35d757bb6fa551492762c2822d2b08ac2281ab10 Mon Sep 17 00:00:00 2001 From: vercel-release-bot Date: Sun, 27 Oct 2024 23:24:28 +0000 Subject: [PATCH 3/6] v15.0.2-canary.9 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/eslint-config-next/package.json | 4 ++-- packages/eslint-plugin-next/package.json | 2 +- packages/font/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-codemod/package.json | 2 +- packages/next-env/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-storybook/package.json | 2 +- packages/next-polyfill-module/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next-swc/package.json | 2 +- packages/next/package.json | 14 +++++++------- packages/react-refresh-utils/package.json | 2 +- packages/third-parties/package.json | 4 ++-- pnpm-lock.yaml | 16 ++++++++-------- 17 files changed, 32 insertions(+), 32 deletions(-) diff --git a/lerna.json b/lerna.json index 8f39c49b28c71..5b7fa07a3c9ae 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "15.0.2-canary.8" + "version": "15.0.2-canary.9" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 7f5230b9006ee..0bb9d0a1065a3 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index d9e98c6c6ca2d..35253f86897cd 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "description": "ESLint configuration used by Next.js.", "main": "index.js", "license": "MIT", @@ -10,7 +10,7 @@ }, "homepage": "https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-config", "dependencies": { - "@next/eslint-plugin-next": "15.0.2-canary.8", + "@next/eslint-plugin-next": "15.0.2-canary.9", "@rushstack/eslint-patch": "^1.10.3", "@typescript-eslint/eslint-plugin": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0", "@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 1145002c629fb..3093471b57e72 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "description": "ESLint plugin for Next.js.", "main": "dist/index.js", "license": "MIT", diff --git a/packages/font/package.json b/packages/font/package.json index 1794114118436..cc44dbd88fdab 100644 --- a/packages/font/package.json +++ b/packages/font/package.json @@ -1,7 +1,7 @@ { "name": "@next/font", "private": true, - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "repository": { "url": "vercel/next.js", "directory": "packages/font" diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 8dd36f02be162..0090c493d0b20 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 8dfde19ef9089..21a566226a6aa 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "license": "MIT", "repository": { "type": "git", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 2bdd8e5aa0363..ad62fe61653e4 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index b7952b0151652..7c04529e750cd 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index b33aac9453a11..e0b8553935419 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index df573b822f6f4..1783cab28bb2c 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)", "main": "dist/polyfill-module.js", "license": "MIT", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index 6dded6475d1b4..7162152bfde7e 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index f322162e0d507..32fc9c5d76651 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "private": true, "scripts": { "clean": "node ../../scripts/rm.mjs native", diff --git a/packages/next/package.json b/packages/next/package.json index 318141d938a03..b163286e1a71b 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -95,7 +95,7 @@ ] }, "dependencies": { - "@next/env": "15.0.2-canary.8", + "@next/env": "15.0.2-canary.9", "@swc/counter": "0.1.3", "@swc/helpers": "0.5.13", "busboy": "1.6.0", @@ -159,11 +159,11 @@ "@jest/types": "29.5.0", "@mswjs/interceptors": "0.23.0", "@napi-rs/triples": "1.2.0", - "@next/font": "15.0.2-canary.8", - "@next/polyfill-module": "15.0.2-canary.8", - "@next/polyfill-nomodule": "15.0.2-canary.8", - "@next/react-refresh-utils": "15.0.2-canary.8", - "@next/swc": "15.0.2-canary.8", + "@next/font": "15.0.2-canary.9", + "@next/polyfill-module": "15.0.2-canary.9", + "@next/polyfill-nomodule": "15.0.2-canary.9", + "@next/react-refresh-utils": "15.0.2-canary.9", + "@next/swc": "15.0.2-canary.9", "@opentelemetry/api": "1.6.0", "@playwright/test": "1.41.2", "@swc/core": "1.7.0-nightly-20240714.1", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index 58dc84ec33f0f..469c81aa76d3a 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", diff --git a/packages/third-parties/package.json b/packages/third-parties/package.json index cba03e35bf3b7..be9fbb2fd1087 100644 --- a/packages/third-parties/package.json +++ b/packages/third-parties/package.json @@ -1,6 +1,6 @@ { "name": "@next/third-parties", - "version": "15.0.2-canary.8", + "version": "15.0.2-canary.9", "repository": { "url": "vercel/next.js", "directory": "packages/third-parties" @@ -26,7 +26,7 @@ "third-party-capital": "1.0.20" }, "devDependencies": { - "next": "15.0.2-canary.8", + "next": "15.0.2-canary.9", "outdent": "0.8.0", "prettier": "2.5.1", "typescript": "5.5.3" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 67a6f617bb3f6..6e4cfadeaeef9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -795,7 +795,7 @@ importers: packages/eslint-config-next: dependencies: '@next/eslint-plugin-next': - specifier: 15.0.2-canary.8 + specifier: 15.0.2-canary.9 version: link:../eslint-plugin-next '@rushstack/eslint-patch': specifier: ^1.10.3 @@ -859,7 +859,7 @@ importers: packages/next: dependencies: '@next/env': - specifier: 15.0.2-canary.8 + specifier: 15.0.2-canary.9 version: link:../next-env '@swc/counter': specifier: 0.1.3 @@ -987,19 +987,19 @@ importers: specifier: 1.2.0 version: 1.2.0 '@next/font': - specifier: 15.0.2-canary.8 + specifier: 15.0.2-canary.9 version: link:../font '@next/polyfill-module': - specifier: 15.0.2-canary.8 + specifier: 15.0.2-canary.9 version: link:../next-polyfill-module '@next/polyfill-nomodule': - specifier: 15.0.2-canary.8 + specifier: 15.0.2-canary.9 version: link:../next-polyfill-nomodule '@next/react-refresh-utils': - specifier: 15.0.2-canary.8 + specifier: 15.0.2-canary.9 version: link:../react-refresh-utils '@next/swc': - specifier: 15.0.2-canary.8 + specifier: 15.0.2-canary.9 version: link:../next-swc '@opentelemetry/api': specifier: 1.6.0 @@ -1633,7 +1633,7 @@ importers: version: 1.0.20 devDependencies: next: - specifier: 15.0.2-canary.8 + specifier: 15.0.2-canary.9 version: link:../next outdent: specifier: 0.8.0 From ba9879bf98e793f1dca419aa5acf9f7e5869cf73 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Mon, 28 Oct 2024 04:16:20 +0100 Subject: [PATCH 4/6] Implement information byte in Server Reference ID and other optimizations (#71463) With this PR, we're adding one extra leading byte to Server Reference IDs (both Server Actions and `"use cache"` functions), to include some static information about the function itself. The information byte has the following format: ``` 0 000000 0 ^type ^arg mask ^rest args ``` The type bit represents if the action is a cache function or not. For cache functions, the type bit is set to `1`. Otherwise, it's `0`. The arg mask bit is used to determine which arguments are used by the function itself, up to 6 arguments. The bit is set to `1` if the argument is used, or being spread or destructured (so it can be indirectly or partially used). The bit is set to `0` otherwise. The rest args bit is used to determine if there's a `...` rest argument in the function signature. If there is, the bit is set to `1`. For example: ```tsx async function foo(a, foo, b, bar, ...baz) { 'use cache'; return a + b; } ``` will have it encoded as `[1][101011][1]`. The first bit is set to `1` because it's a cache function. The second part has `1010` because the only arguments used are `a` and `b`. The subsequent `11` bits are set to `1` because there's a `...baz` argument starting from the 5th. The last bit is set to `1` as well for the same reason. Note: Currently in this PR we don't track if an argument is actually referenced in the function body or not. That will be implemented as a follow-up optimization. Also, the reference ID is currently hex-encoded so there will be exact 2 characters for easier decoding. This encoding might change though. With this extra byte, the client can do some further optimizations. More details can be found in the code comment. --- .../src/transforms/server_actions.rs | 559 +++++++++++++----- .../server-actions/server-graph/1/output.js | 4 +- .../server-actions/server-graph/2/output.js | 4 +- .../server-actions/server-graph/6/output.js | 4 +- .../server-actions/server-graph/8/output.js | 4 +- .../fixture/server-actions/client/1/output.js | 6 +- .../fixture/server-actions/client/2/output.js | 4 +- .../fixture/server-actions/client/3/output.js | 10 +- .../fixture/server-actions/client/4/output.js | 4 +- .../fixture/server-actions/client/5/output.js | 4 +- .../fixture/server-actions/client/6/output.js | 6 +- .../fixture/server-actions/client/7/output.js | 4 +- .../fixture/server-actions/client/8/output.js | 4 +- .../fixture/server-actions/server/1/output.js | 10 +- .../server-actions/server/10/output.js | 4 +- .../server-actions/server/11/output.js | 4 +- .../server-actions/server/12/output.js | 4 +- .../server-actions/server/13/output.js | 6 +- .../server-actions/server/14/output.js | 4 +- .../server-actions/server/15/output.js | 4 +- .../server-actions/server/16/output.js | 14 +- .../server-actions/server/17/output.js | 6 +- .../server-actions/server/18/output.js | 10 +- .../server-actions/server/19/output.js | 6 +- .../fixture/server-actions/server/2/output.js | 6 +- .../server-actions/server/20/output.js | 4 +- .../server-actions/server/21/output.js | 10 +- .../server-actions/server/22/output.js | 6 +- .../server-actions/server/23/output.js | 10 +- .../server-actions/server/24/output.js | 6 +- .../server-actions/server/25/output.js | 10 +- .../server-actions/server/26/output.js | 4 +- .../server-actions/server/27/output.js | 12 +- .../server-actions/server/28/output.js | 14 +- .../server-actions/server/29/output.js | 6 +- .../fixture/server-actions/server/3/output.js | 4 +- .../server-actions/server/30/output.js | 16 +- .../server-actions/server/31/output.js | 6 +- .../server-actions/server/32/output.js | 6 +- .../server-actions/server/33/output.js | 6 +- .../server-actions/server/34/output.js | 18 +- .../server-actions/server/35/output.js | 6 +- .../server-actions/server/36/output.js | 18 +- .../server-actions/server/37/output.js | 6 +- .../server-actions/server/38/output.js | 6 +- .../server-actions/server/39/output.js | 10 +- .../fixture/server-actions/server/4/output.js | 10 +- .../server-actions/server/40/output.js | 14 +- .../server-actions/server/41/output.js | 10 +- .../server-actions/server/42/output.js | 10 +- .../server-actions/server/43/output.js | 10 +- .../server-actions/server/44/output.js | 12 +- .../server-actions/server/45/output.js | 6 +- .../fixture/server-actions/server/46/input.js | 37 ++ .../server-actions/server/46/output.js | 77 +++ .../fixture/server-actions/server/47/input.js | 23 + .../server-actions/server/47/output.js | 16 + .../fixture/server-actions/server/48/input.js | 45 ++ .../server-actions/server/48/output.js | 47 ++ .../fixture/server-actions/server/49/input.js | 13 + .../server-actions/server/49/output.js | 11 + .../fixture/server-actions/server/5/output.js | 6 +- .../fixture/server-actions/server/50/input.js | 13 + .../server-actions/server/50/output.js | 15 + .../fixture/server-actions/server/51/input.js | 35 ++ .../server-actions/server/51/output.js | 29 + .../fixture/server-actions/server/6/output.js | 6 +- .../fixture/server-actions/server/7/output.js | 18 +- .../fixture/server-actions/server/8/output.js | 4 +- .../fixture/server-actions/server/9/output.js | 8 +- .../next/src/build/webpack/loaders/utils.ts | 1 + .../plugins/flight-client-entry-plugin.ts | 4 +- 72 files changed, 979 insertions(+), 380 deletions(-) create mode 100644 crates/next-custom-transforms/tests/fixture/server-actions/server/46/input.js create mode 100644 crates/next-custom-transforms/tests/fixture/server-actions/server/46/output.js create mode 100644 crates/next-custom-transforms/tests/fixture/server-actions/server/47/input.js create mode 100644 crates/next-custom-transforms/tests/fixture/server-actions/server/47/output.js create mode 100644 crates/next-custom-transforms/tests/fixture/server-actions/server/48/input.js create mode 100644 crates/next-custom-transforms/tests/fixture/server-actions/server/48/output.js create mode 100644 crates/next-custom-transforms/tests/fixture/server-actions/server/49/input.js create mode 100644 crates/next-custom-transforms/tests/fixture/server-actions/server/49/output.js create mode 100644 crates/next-custom-transforms/tests/fixture/server-actions/server/50/input.js create mode 100644 crates/next-custom-transforms/tests/fixture/server-actions/server/50/output.js create mode 100644 crates/next-custom-transforms/tests/fixture/server-actions/server/51/input.js create mode 100644 crates/next-custom-transforms/tests/fixture/server-actions/server/51/output.js diff --git a/crates/next-custom-transforms/src/transforms/server_actions.rs b/crates/next-custom-transforms/src/transforms/server_actions.rs index 9db269ff46a2a..2207a2f5aab75 100644 --- a/crates/next-custom-transforms/src/transforms/server_actions.rs +++ b/crates/next-custom-transforms/src/transforms/server_actions.rs @@ -115,13 +115,16 @@ struct ServerActions { rewrite_default_fn_expr_to_proxy_expr: Option>, rewrite_expr_to_proxy_expr: Option>, - // (ident, export name) - exported_idents: Vec<(Ident, String)>, + exported_idents: Vec<( + /* ident */ Ident, + /* name */ String, + /* id */ String, + )>, annotations: Vec, extra_items: Vec, hoisted_extra_items: Vec, - export_actions: Vec, + export_actions: Vec<(/* name */ String, /* id */ String)>, private_ctxt: SyntaxContext, @@ -130,6 +133,107 @@ struct ServerActions { } impl ServerActions { + fn generate_server_reference_id( + &self, + export_name: &str, + is_cache: bool, + params: Option<&Vec>, + ) -> String { + // Attach a checksum to the action using sha1: + // $$id = special_byte + sha1('hash_salt' + 'file_name' + ':' + 'export_name'); + // Currently encoded as hex. + + let mut hasher = Sha1::new(); + hasher.update(self.config.hash_salt.as_bytes()); + hasher.update(self.file_name.as_bytes()); + hasher.update(b":"); + hasher.update(export_name.as_bytes()); + let mut result = hasher.finalize().to_vec(); + + // Prepend an extra byte to the ID, with the following format: + // 0 000000 0 + // ^type ^arg mask ^rest args + // + // The type bit represents if the action is a cache function or not. + // For cache functions, the type bit is set to 1. Otherwise, it's 0. + // + // The arg mask bit is used to determine which arguments are used by + // the function itself, up to 6 arguments. The bit is set to 1 if the + // argument is used, or being spread or destructured (so it can be + // indirectly or partially used). The bit is set to 0 otherwise. + // + // The rest args bit is used to determine if there's a ...rest argument + // in the function signature. If there is, the bit is set to 1. + // + // For example: + // + // async function foo(a, foo, b, bar, ...baz) { + // 'use cache'; + // return a + b; + // } + // + // will have it encoded as [1][101011][1]. The first bit is set to 1 + // because it's a cache function. The second part has 1010 because the + // only arguments used are `a` and `b`. The subsequent 11 bits are set + // to 1 because there's a ...rest argument starting from the 5th. The + // last bit is set to 1 as well for the same reason. + let type_bit = if is_cache { 1u8 } else { 0u8 }; + let mut arg_mask = 0u8; + let mut rest_args = 0u8; + + if let Some(params) = params { + // TODO: For the current implementation, we don't track if an + // argument ident is actually referenced in the function body. + // Instead, we go with the easy route and assume defined ones are + // used. This can be improved in the future. + for (i, param) in params.iter().enumerate() { + if let Pat::Rest(_) = param { + // If there's a ...rest argument, we set the rest args bit + // to 1 and set the arg mask to 0b111111. + arg_mask = 0b111111; + rest_args = 0b1; + break; + } + if i < 6 { + arg_mask |= 0b1 << (5 - i); + } else { + // More than 6 arguments, we set the rest args bit to 1. + // This is rare for a Server Action, usually. + rest_args = 0b1; + break; + } + } + } else { + // If we can't determine the arguments (e.g. not staticaly analyzable), + // we assume all arguments are used. + arg_mask = 0b111111; + rest_args = 0b1; + } + + result.push((type_bit << 7) | (arg_mask << 1) | rest_args); + result.rotate_right(1); + + hex_encode(result) + } + + fn gen_action_ident(&mut self) -> JsWord { + let id: JsWord = format!("$$RSC_SERVER_ACTION_{0}", self.reference_index).into(); + self.reference_index += 1; + id + } + + fn gen_cache_ident(&mut self) -> JsWord { + let id: JsWord = format!("$$RSC_SERVER_CACHE_{0}", self.reference_index).into(); + self.reference_index += 1; + id + } + + fn gen_ref_ident(&mut self) -> JsWord { + let id: JsWord = format!("$$RSC_SERVER_REF_{0}", self.reference_index).into(); + self.reference_index += 1; + id + } + // Check if the function or arrow function is an action or cache function fn get_body_info(&mut self, maybe_body: Option<&mut BlockStmt>) -> (bool, Option) { let mut is_action_fn = false; @@ -183,7 +287,8 @@ impl ServerActions { } } - if self.in_exported_expr { + // Self-annotations take precedence over module-level annotations. + if self.in_exported_expr && !is_action_fn && cache_type.is_none() { if self.in_action_file { // All export functions in a server file are actions is_action_fn = true; @@ -201,17 +306,14 @@ impl ServerActions { ids_from_closure: Vec, arrow: &mut ArrowExpr, ) -> Box { - let action_name = gen_action_ident(&mut self.reference_index).to_string(); - - self.has_action = true; - self.export_actions.push(action_name.to_string()); + let action_name = self.gen_action_ident().to_string(); let action_ident = Ident::new(action_name.clone().into(), arrow.span, self.private_ctxt); - let action_id = generate_action_id( - &self.config.hash_salt, - &self.file_name, - action_name.to_string().as_str(), - ); + let action_id = self.generate_server_reference_id(&action_name, false, Some(&arrow.params)); + + self.has_action = true; + self.export_actions + .push((action_name.to_string(), action_id.clone())); let register_action_expr = bind_args_to_ref_expr( annotate_ident_as_server_reference(action_ident.clone(), action_id.clone(), arrow.span), @@ -220,7 +322,7 @@ impl ServerActions { .cloned() .map(|id| Some(id.as_arg())) .collect(), - action_id, + action_id.clone(), ); if let BlockStmtOrExpr::BlockStmt(block) = &mut *arrow.body { @@ -274,12 +376,7 @@ impl ServerActions { span: DUMMY_SP, callee: quote_ident!("decryptActionBoundArgs").as_callee(), args: vec![ - generate_action_id( - &self.config.hash_salt, - &self.file_name, - &action_name, - ) - .as_arg(), + action_id.as_arg(), quote_ident!("$$ACTION_CLOSURE_BOUND").as_arg(), ], ..Default::default() @@ -368,13 +465,18 @@ impl ServerActions { function: &mut Box, fn_name: Option, ) -> Box { - let action_name: JsWord = gen_action_ident(&mut self.reference_index); - - self.has_action = true; - self.export_actions.push(action_name.to_string()); + let action_name: JsWord = self.gen_action_ident(); let action_ident = Ident::new(action_name.clone(), function.span, self.private_ctxt); - let action_id = generate_action_id(&self.config.hash_salt, &self.file_name, &action_name); + let action_id = self.generate_server_reference_id( + &action_name, + false, + Some(&function.params.iter().map(|p| p.pat.clone()).collect()), + ); + + self.has_action = true; + self.export_actions + .push((action_name.to_string(), action_id.clone())); let register_action_expr = bind_args_to_ref_expr( annotate_ident_as_server_reference( @@ -387,7 +489,7 @@ impl ServerActions { .cloned() .map(|id| Some(id.as_arg())) .collect(), - action_id, + action_id.clone(), ); function.body.visit_mut_with(&mut ClosureReplacer { @@ -439,12 +541,7 @@ impl ServerActions { span: DUMMY_SP, callee: quote_ident!("decryptActionBoundArgs").as_callee(), args: vec![ - generate_action_id( - &self.config.hash_salt, - &self.file_name, - &action_name, - ) - .as_arg(), + action_id.as_arg(), quote_ident!("$$ACTION_CLOSURE_BOUND").as_arg(), ], ..Default::default() @@ -506,16 +603,17 @@ impl ServerActions { cache_type: &str, arrow: &mut ArrowExpr, ) -> Box { - let cache_name: JsWord = gen_cache_ident(&mut self.reference_index); + let cache_name: JsWord = self.gen_cache_ident(); let cache_ident = private_ident!(cache_name.clone()); let export_name: JsWord = cache_name; + let reference_id = + self.generate_server_reference_id(&export_name, true, Some(&arrow.params)); + self.has_cache = true; self.has_action = true; - self.export_actions.push(export_name.to_string()); - - let reference_id = - generate_action_id(&self.config.hash_salt, &self.file_name, &export_name); + self.export_actions + .push((export_name.to_string(), reference_id.clone())); if let BlockStmtOrExpr::BlockStmt(block) = &mut *arrow.body { block.visit_mut_with(&mut ClosureReplacer { @@ -568,12 +666,7 @@ impl ServerActions { span: DUMMY_SP, callee: quote_ident!("decryptActionBoundArgs").as_callee(), args: vec![ - generate_action_id( - &self.config.hash_salt, - &self.file_name, - &export_name, - ) - .as_arg(), + reference_id.clone().as_arg(), quote_ident!("$$ACTION_CLOSURE_BOUND").as_arg(), ], ..Default::default() @@ -676,7 +769,7 @@ impl ServerActions { // register action expression to the top-level, and return the bind // expression inline. if !bound_args.is_empty() { - let ref_ident = private_ident!(gen_ref_ident(&mut self.reference_index)); + let ref_ident = private_ident!(self.gen_ref_ident()); let ref_decl = VarDecl { span: DUMMY_SP, @@ -711,14 +804,19 @@ impl ServerActions { cache_type: &str, function: &mut Box, ) -> Box { - let cache_name: JsWord = gen_cache_ident(&mut self.reference_index); + let cache_name: JsWord = self.gen_cache_ident(); let cache_ident = private_ident!(cache_name.clone()); + let reference_id = self.generate_server_reference_id( + &cache_name, + true, + Some(&function.params.iter().map(|p| p.pat.clone()).collect()), + ); + self.has_cache = true; self.has_action = true; - self.export_actions.push(cache_name.to_string()); - - let reference_id = generate_action_id(&self.config.hash_salt, &self.file_name, &cache_name); + self.export_actions + .push((cache_name.to_string(), reference_id.clone())); let register_action_expr = annotate_ident_as_server_reference( cache_ident.clone(), @@ -776,12 +874,7 @@ impl ServerActions { span: DUMMY_SP, callee: quote_ident!("decryptActionBoundArgs").as_callee(), args: vec![ - generate_action_id( - &self.config.hash_salt, - &self.file_name, - &cache_name, - ) - .as_arg(), + reference_id.clone().as_arg(), quote_ident!("$$ACTION_CLOSURE_BOUND").as_arg(), ], ..Default::default() @@ -852,7 +945,7 @@ impl ServerActions { // register action expression to the top-level, and return the bind // expression inline. if !bound_args.is_empty() { - let ref_ident = private_ident!(gen_ref_ident(&mut self.reference_index)); + let ref_ident = private_ident!(self.gen_ref_ident()); let ref_decl = VarDecl { span: DUMMY_SP, @@ -1398,13 +1491,17 @@ impl VisitMut for ServerActions { } } + // Only track exported identifiers in action files or cache files. + let is_cache_file = self.in_cache_file.is_some(); + let should_track_exports = self.in_action_file || is_cache_file; + let old_annotations = self.annotations.take(); let mut new = Vec::with_capacity(stmts.len()); for mut stmt in stmts.take() { // For server boundary files, it's not allowed to export things other than async // functions. - if self.in_action_file || self.in_cache_file.is_some() { + if should_track_exports { let mut disallowed_export_span = DUMMY_SP; // Currently only function exports are allowed. @@ -1413,18 +1510,57 @@ impl VisitMut for ServerActions { match decl { Decl::Fn(f) => { // export function foo() {} - self.exported_idents - .push((f.ident.clone(), f.ident.sym.to_string())); + + let (is_action_fn, is_cache_fn) = + has_body_directive(&f.function.body); + + let ref_id = if is_action_fn { + false + } else if is_cache_fn { + true + } else { + is_cache_file + }; + + // If it's a self-annotated cache function, we need to skip + // collecting the exported ident. Otherwise it will be double- + // annotated. + // TODO(shu): This is a workaround. We should have a better way + // to skip self-annotated exports here. + if !(is_cache_fn && self.config.is_react_server_layer) { + self.exported_idents.push(( + f.ident.clone(), + f.ident.sym.to_string(), + self.generate_server_reference_id( + f.ident.sym.as_ref(), + ref_id, + Some( + &f.function + .params + .iter() + .map(|p| p.pat.clone()) + .collect(), + ), + ), + )); + } } Decl::Var(var) => { // export const foo = 1 let mut idents: Vec = Vec::new(); collect_idents_in_var_decls(&var.decls, &mut idents); - self.exported_idents.extend( - idents - .into_iter() - .map(|ident| (ident.clone(), ident.to_id().0.to_string())), - ); + + for ident in &idents { + self.exported_idents.push(( + ident.clone(), + ident.sym.to_string(), + self.generate_server_reference_id( + ident.sym.as_ref(), + is_cache_file, + None, + ), + )); + } for decl in &mut var.decls { if let Some(init) = &decl.init { @@ -1456,17 +1592,38 @@ impl VisitMut for ServerActions { export_name { // export { foo as bar } - self.exported_idents - .push((ident.clone(), sym.to_string())); + self.exported_idents.push(( + ident.clone(), + sym.to_string(), + self.generate_server_reference_id( + sym.as_ref(), + is_cache_file, + None, + ), + )); } else if let ModuleExportName::Str(str) = export_name { // export { foo as "bar" } - self.exported_idents - .push((ident.clone(), str.value.to_string())); + self.exported_idents.push(( + ident.clone(), + str.value.to_string(), + self.generate_server_reference_id( + str.value.as_ref(), + is_cache_file, + None, + ), + )); } } else { // export { foo } - self.exported_idents - .push((ident.clone(), ident.sym.to_string())); + self.exported_idents.push(( + ident.clone(), + ident.sym.to_string(), + self.generate_server_reference_id( + ident.sym.as_ref(), + is_cache_file, + None, + ), + )); } } else { disallowed_export_span = named.span; @@ -1480,26 +1637,62 @@ impl VisitMut for ServerActions { .. })) => match decl { DefaultDecl::Fn(f) => { - if let Some(ident) = &f.ident { - // export default function foo() {} - self.exported_idents.push((ident.clone(), "default".into())); + let (is_action_fn, is_cache_fn) = has_body_directive(&f.function.body); + + let is_cache = if is_action_fn { + false + } else if is_cache_fn { + true } else { - // export default function() {} - // Use the span from the function expression - let span = f.function.span; - - let new_ident = Ident::new( - gen_action_ident(&mut self.reference_index), - span, - self.private_ctxt, + is_cache_file + }; + + // If it's a self-annotated cache function, we need to skip + // collecting the exported ident. Otherwise it will be double- + // annotated. + // TODO(shu): This is a workaround. We should have a better way + // to skip self-annotated exports here. + if !(is_cache_fn && self.config.is_react_server_layer) { + let ref_id = self.generate_server_reference_id( + "default", + is_cache, + Some( + &f.function.params.iter().map(|p| p.pat.clone()).collect(), + ), ); - f.ident = Some(new_ident.clone()); - - self.exported_idents - .push((new_ident.clone(), "default".into())); - - assign_name_to_ident(&new_ident, "default", &mut self.extra_items); + if let Some(ident) = &f.ident { + // export default function foo() {} + self.exported_idents.push(( + ident.clone(), + "default".into(), + ref_id, + )); + } else { + // export default function() {} + // Use the span from the function expression + let span = f.function.span; + + let new_ident = Ident::new( + self.gen_action_ident(), + span, + self.private_ctxt, + ); + + f.ident = Some(new_ident.clone()); + + self.exported_idents.push(( + new_ident.clone(), + "default".into(), + ref_id, + )); + + assign_name_to_ident( + &new_ident, + "default", + &mut self.extra_items, + ); + } } } _ => { @@ -1514,38 +1707,85 @@ impl VisitMut for ServerActions { // Use the span of the arrow function let span = arrow.span; - let new_ident = Ident::new( - gen_action_ident(&mut self.reference_index), - span, - self.private_ctxt, - ); + let (is_action_fn, is_cache_fn) = + has_body_directive(&if let BlockStmtOrExpr::BlockStmt(block) = + &*arrow.body + { + Some(block.clone()) + } else { + None + }); - self.exported_idents - .push((new_ident.clone(), "default".into())); + let is_cache = if is_action_fn { + false + } else if is_cache_fn { + true + } else { + is_cache_file + }; + + // If it's a self-annotated cache function, we need to skip + // collecting the exported ident. Otherwise it will be double- + // annotated. + // TODO(shu): This is a workaround. We should have a better way + // to skip self-annotated exports here. + if !(is_cache_fn && self.config.is_react_server_layer) { + let new_ident = Ident::new( + self.gen_action_ident(), + span, + self.private_ctxt, + ); + + self.exported_idents.push(( + new_ident.clone(), + "default".into(), + self.generate_server_reference_id( + "default", + is_cache, + Some(&arrow.params), + ), + )); - create_var_declarator(&new_ident, &mut self.extra_items); - assign_name_to_ident(&new_ident, "default", &mut self.extra_items); + create_var_declarator(&new_ident, &mut self.extra_items); + assign_name_to_ident( + &new_ident, + "default", + &mut self.extra_items, + ); - *default_expr.expr = - assign_arrow_expr(&new_ident, Expr::Arrow(arrow.clone())); + *default_expr.expr = + assign_arrow_expr(&new_ident, Expr::Arrow(arrow.clone())); + } } Expr::Ident(ident) => { // export default foo - self.exported_idents.push((ident.clone(), "default".into())); + self.exported_idents.push(( + ident.clone(), + "default".into(), + self.generate_server_reference_id( + "default", + is_cache_file, + None, + ), + )); } Expr::Call(call) => { // export default fn() // Determining a useful span here is tricky. let span = call.span; - let new_ident = Ident::new( - gen_action_ident(&mut self.reference_index), - span, - self.private_ctxt, - ); + let new_ident = + Ident::new(self.gen_action_ident(), span, self.private_ctxt); - self.exported_idents - .push((new_ident.clone(), "default".into())); + self.exported_idents.push(( + new_ident.clone(), + "default".into(), + self.generate_server_reference_id( + "default", + is_cache_file, + None, + ), + )); create_var_declarator(&new_ident, &mut self.extra_items); assign_name_to_ident(&new_ident, "default", &mut self.extra_items); @@ -1617,9 +1857,7 @@ impl VisitMut for ServerActions { let call_server_ident = private_ident!("callServer"); let find_source_map_url_ident = private_ident!("findSourceMapURL"); - if (self.in_action_file || self.in_cache_file.is_some()) - && !self.config.is_react_server_layer - { + if should_track_exports && !self.config.is_react_server_layer { // import { // createServerReference, // callServer, @@ -1661,12 +1899,9 @@ impl VisitMut for ServerActions { } // If it's a "use server" or a "use cache" file, all exports need to be annotated. - if self.in_action_file || self.in_cache_file.is_some() { - for (ident, export_name) in self.exported_idents.iter() { + if should_track_exports { + for (ident, export_name, ref_id) in self.exported_idents.iter() { if !self.config.is_react_server_layer { - let action_id = - generate_action_id(&self.config.hash_salt, &self.file_name, export_name); - if export_name == "default" { self.comments.add_pure_comment(ident.span.lo); @@ -1679,7 +1914,7 @@ impl VisitMut for ServerActions { create_ref_ident.clone(), ))), args: vec![ - action_id.as_arg(), + ref_id.clone().as_arg(), call_server_ident.clone().as_arg(), Expr::undefined(DUMMY_SP).as_arg(), find_source_map_url_ident.clone().as_arg(), @@ -1712,7 +1947,7 @@ impl VisitMut for ServerActions { create_ref_ident.clone(), ))), args: vec![ - action_id.as_arg(), + ref_id.clone().as_arg(), call_server_ident.clone().as_arg(), Expr::undefined(DUMMY_SP).as_arg(), find_source_map_url_ident.clone().as_arg(), @@ -1728,28 +1963,29 @@ impl VisitMut for ServerActions { new.push(export_expr); } } else if self.in_cache_file.is_none() { - let action_id = - generate_action_id(&self.config.hash_salt, &self.file_name, export_name); - self.annotations.push(Stmt::Expr(ExprStmt { span: DUMMY_SP, expr: Box::new(annotate_ident_as_server_reference( ident.clone(), - action_id, + ref_id.to_string(), ident.span, )), })); } } + // Ensure that the exports are functions by appending a runtime check: + // + // import { ensureServerEntryExports } from 'private-next-rsc-action-validate' + // ensureServerEntryExports([action1, action2, ...]) + // + // But it's only needed for the server layer, because on the client + // layer they're transformed into references already. if self.config.is_react_server_layer { new.append(&mut self.extra_items); // For "use cache" files, there's no need to do extra annotations. if self.in_cache_file.is_none() && !self.exported_idents.is_empty() { - // Ensure that the exports are valid by appending a check - // import { ensureServerEntryExports } from 'private-next-rsc-action-validate' - // ensureServerEntryExports([action1, action2, ...]) let ensure_ident = private_ident!("ensureServerEntryExports"); new.push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { span: DUMMY_SP, @@ -1780,7 +2016,7 @@ impl VisitMut for ServerActions { elems: self .exported_idents .iter() - .map(|(ident, _span)| { + .map(|(ident, _, _)| { Some(ExprOrSpread { spread: None, expr: Box::new(Expr::Ident(ident.clone())), @@ -1806,18 +2042,19 @@ impl VisitMut for ServerActions { if self.in_action_file || self.in_cache_file.is_some() && !self.config.is_react_server_layer { - actions.extend(self.exported_idents.iter().map(|e| e.1.clone())); + actions.extend( + self.exported_idents + .iter() + .map(|e| (e.1.clone(), e.2.clone())), + ); }; + // Make it a hashmap of id -> name. let actions = actions .into_iter() - .map(|name| { - ( - generate_action_id(&self.config.hash_salt, &self.file_name, &name), - name, - ) - }) + .map(|a| (a.1, a.0)) .collect::(); + // Prepend a special comment to the top of the file. self.comments.add_leading( self.start_pos, @@ -2037,24 +2274,6 @@ fn retain_names_from_declared_idents( *child_names = retained_names; } -fn gen_action_ident(cnt: &mut u32) -> JsWord { - let id: JsWord = format!("$$RSC_SERVER_ACTION_{cnt}").into(); - *cnt += 1; - id -} - -fn gen_cache_ident(cnt: &mut u32) -> JsWord { - let id: JsWord = format!("$$RSC_SERVER_CACHE_{cnt}").into(); - *cnt += 1; - id -} - -fn gen_ref_ident(cnt: &mut u32) -> JsWord { - let id: JsWord = format!("$$RSC_SERVER_REF_{cnt}").into(); - *cnt += 1; - id -} - fn wrap_cache_expr(expr: Box, name: &str, id: &str) -> Box { // expr -> $$cache__("name", "id", expr) Box::new(Expr::Call(CallExpr { @@ -2153,19 +2372,6 @@ fn assign_arrow_expr(ident: &Ident, expr: Expr) -> Expr { } } -fn generate_action_id(hash_salt: &str, file_name: &str, export_name: &str) -> String { - // Attach a checksum to the action using sha1: - // $$id = sha1('hash_salt' + 'file_name' + ':' + 'export_name'); - let mut hasher = Sha1::new(); - hasher.update(hash_salt.as_bytes()); - hasher.update(file_name.as_bytes()); - hasher.update(b":"); - hasher.update(export_name.as_bytes()); - let result = hasher.finalize(); - - hex_encode(result) -} - fn annotate_ident_as_server_reference( ident: Ident, action_id: String, @@ -2445,6 +2651,37 @@ fn remove_server_directive_index_in_module( }); } +// Check if the function or arrow function has any action or cache directives, +// without mutating the function body or erroring out. +// This is used to quickly determine if we need to use the module-level +// directives for this function or not. +fn has_body_directive(maybe_body: &Option) -> (bool, bool) { + let mut is_action_fn = false; + let mut is_cache_fn = false; + + if let Some(body) = maybe_body { + for stmt in body.stmts.iter() { + match stmt { + Stmt::Expr(ExprStmt { + expr: box Expr::Lit(Lit::Str(Str { value, .. })), + .. + }) => { + if value == "use server" { + is_action_fn = true; + break; + } else if value == "use cache" || value.starts_with("use cache: ") { + is_cache_fn = true; + break; + } + } + _ => break, + } + } + } + + (is_action_fn, is_cache_fn) +} + fn remove_server_directive_index_in_fn( stmts: &mut Vec, is_action_fn: &mut bool, diff --git a/crates/next-custom-transforms/tests/errors/server-actions/server-graph/1/output.js b/crates/next-custom-transforms/tests/errors/server-actions/server-graph/1/output.js index 01b76c30cb1b6..025c36246e3fc 100644 --- a/crates/next-custom-transforms/tests/errors/server-actions/server-graph/1/output.js +++ b/crates/next-custom-transforms/tests/errors/server-actions/server-graph/1/output.js @@ -1,8 +1,8 @@ -/* __next_internal_action_entry_do_not_use__ {"ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"00ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export function foo() {} import { ensureServerEntryExports } from "private-next-rsc-action-validate"; ensureServerEntryExports([ foo ]); -registerServerReference(foo, "ab21efdafbe611287bc25c0462b1e0510d13e48b", null); +registerServerReference(foo, "00ab21efdafbe611287bc25c0462b1e0510d13e48b", null); diff --git a/crates/next-custom-transforms/tests/errors/server-actions/server-graph/2/output.js b/crates/next-custom-transforms/tests/errors/server-actions/server-graph/2/output.js index 31450221dc7b6..e9f6847c43eb4 100644 --- a/crates/next-custom-transforms/tests/errors/server-actions/server-graph/2/output.js +++ b/crates/next-custom-transforms/tests/errors/server-actions/server-graph/2/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"00ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; 'use strict'; export function bar() {} @@ -6,4 +6,4 @@ import { ensureServerEntryExports } from "private-next-rsc-action-validate"; ensureServerEntryExports([ bar ]); -registerServerReference(bar, "ac840dcaf5e8197cb02b7f3a43c119b7a770b272", null); +registerServerReference(bar, "00ac840dcaf5e8197cb02b7f3a43c119b7a770b272", null); diff --git a/crates/next-custom-transforms/tests/errors/server-actions/server-graph/6/output.js b/crates/next-custom-transforms/tests/errors/server-actions/server-graph/6/output.js index 281ae22a8f035..ede9aaeb162ff 100644 --- a/crates/next-custom-transforms/tests/errors/server-actions/server-graph/6/output.js +++ b/crates/next-custom-transforms/tests/errors/server-actions/server-graph/6/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export default $$RSC_SERVER_ACTION_0 = ()=>{}; var $$RSC_SERVER_ACTION_0; @@ -10,4 +10,4 @@ import { ensureServerEntryExports } from "private-next-rsc-action-validate"; ensureServerEntryExports([ $$RSC_SERVER_ACTION_0 ]); -registerServerReference($$RSC_SERVER_ACTION_0, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); +registerServerReference($$RSC_SERVER_ACTION_0, "00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); diff --git a/crates/next-custom-transforms/tests/errors/server-actions/server-graph/8/output.js b/crates/next-custom-transforms/tests/errors/server-actions/server-graph/8/output.js index a2ac78bbd60ec..52754aa562f9f 100644 --- a/crates/next-custom-transforms/tests/errors/server-actions/server-graph/8/output.js +++ b/crates/next-custom-transforms/tests/errors/server-actions/server-graph/8/output.js @@ -1,9 +1,9 @@ -/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export const $$RSC_SERVER_ACTION_0 = async function foo() { 'use strict'; }; -const foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); +const foo = registerServerReference($$RSC_SERVER_ACTION_0, "006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); const bar = async ()=>{ const x = 1; // prettier-ignore diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/client/1/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/client/1/output.js index fc7f21eff86dd..c19f55642934b 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/client/1/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/client/1/output.js @@ -1,4 +1,4 @@ // app/send.ts -/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default","e10665baac148856374b2789aceb970f66fec33e":"myAction"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; -export var myAction = /*#__PURE__*/ createServerReference("e10665baac148856374b2789aceb970f66fec33e", callServer, void 0, findSourceMapURL, "myAction"); -export default /*#__PURE__*/ createServerReference("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", callServer, void 0, findSourceMapURL, "default"); +/* __next_internal_action_entry_do_not_use__ {"00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default","70e10665baac148856374b2789aceb970f66fec33e":"myAction"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; +export var myAction = /*#__PURE__*/ createServerReference("70e10665baac148856374b2789aceb970f66fec33e", callServer, void 0, findSourceMapURL, "myAction"); +export default /*#__PURE__*/ createServerReference("00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", callServer, void 0, findSourceMapURL, "default"); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/client/2/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/client/2/output.js index acf440a6ed4ee..3a85bb2c0107d 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/client/2/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/client/2/output.js @@ -1,3 +1,3 @@ // app/send.ts -/* __next_internal_action_entry_do_not_use__ {"ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; -export var foo = /*#__PURE__*/ createServerReference("ab21efdafbe611287bc25c0462b1e0510d13e48b", callServer, void 0, findSourceMapURL, "foo"); +/* __next_internal_action_entry_do_not_use__ {"7fab21efdafbe611287bc25c0462b1e0510d13e48b":"foo"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; +export var foo = /*#__PURE__*/ createServerReference("7fab21efdafbe611287bc25c0462b1e0510d13e48b", callServer, void 0, findSourceMapURL, "foo"); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/client/3/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/client/3/output.js index da69b38a030c3..6da7ba6824bec 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/client/3/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/client/3/output.js @@ -1,5 +1,5 @@ -/* __next_internal_action_entry_do_not_use__ {"a0c73dd6f5af839e3335c6b19262ecb86cca6af4":"sampleFunction2","bd336abe00c3c59da66acb696fc8e151d8e54ea4":"sampleFunction","d4f2e95bc745b6500b439c0847003511748c8ece":"sampleFunction3","f03b256ee88a51700367acee3082894e25e6e7d9":"sampleFunction4"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; -export var sampleFunction = /*#__PURE__*/ createServerReference("bd336abe00c3c59da66acb696fc8e151d8e54ea4", callServer, void 0, findSourceMapURL, "sampleFunction"); -export var sampleFunction2 = /*#__PURE__*/ createServerReference("a0c73dd6f5af839e3335c6b19262ecb86cca6af4", callServer, void 0, findSourceMapURL, "sampleFunction2"); -export var sampleFunction3 = /*#__PURE__*/ createServerReference("d4f2e95bc745b6500b439c0847003511748c8ece", callServer, void 0, findSourceMapURL, "sampleFunction3"); -export var sampleFunction4 = /*#__PURE__*/ createServerReference("f03b256ee88a51700367acee3082894e25e6e7d9", callServer, void 0, findSourceMapURL, "sampleFunction4"); +/* __next_internal_action_entry_do_not_use__ {"7fa0c73dd6f5af839e3335c6b19262ecb86cca6af4":"sampleFunction2","7fbd336abe00c3c59da66acb696fc8e151d8e54ea4":"sampleFunction","7fd4f2e95bc745b6500b439c0847003511748c8ece":"sampleFunction3","7ff03b256ee88a51700367acee3082894e25e6e7d9":"sampleFunction4"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; +export var sampleFunction = /*#__PURE__*/ createServerReference("7fbd336abe00c3c59da66acb696fc8e151d8e54ea4", callServer, void 0, findSourceMapURL, "sampleFunction"); +export var sampleFunction2 = /*#__PURE__*/ createServerReference("7fa0c73dd6f5af839e3335c6b19262ecb86cca6af4", callServer, void 0, findSourceMapURL, "sampleFunction2"); +export var sampleFunction3 = /*#__PURE__*/ createServerReference("7fd4f2e95bc745b6500b439c0847003511748c8ece", callServer, void 0, findSourceMapURL, "sampleFunction3"); +export var sampleFunction4 = /*#__PURE__*/ createServerReference("7ff03b256ee88a51700367acee3082894e25e6e7d9", callServer, void 0, findSourceMapURL, "sampleFunction4"); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/client/4/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/client/4/output.js index aad83b202d0da..bce4e0b29e293 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/client/4/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/client/4/output.js @@ -1,2 +1,2 @@ -/* __next_internal_action_entry_do_not_use__ {"ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; -export var bar = /*#__PURE__*/ createServerReference("ac840dcaf5e8197cb02b7f3a43c119b7a770b272", callServer, void 0, findSourceMapURL, "bar"); +/* __next_internal_action_entry_do_not_use__ {"7fac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; +export var bar = /*#__PURE__*/ createServerReference("7fac840dcaf5e8197cb02b7f3a43c119b7a770b272", callServer, void 0, findSourceMapURL, "bar"); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/client/5/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/client/5/output.js index 1fe78adcd8442..6f99ff70a9d7e 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/client/5/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/client/5/output.js @@ -1,2 +1,2 @@ -/* __next_internal_action_entry_do_not_use__ {"0090eaf4e1f08a2d94f6be401e54a2ded399b87c":"action0"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; -export var action0 = /*#__PURE__*/ createServerReference("0090eaf4e1f08a2d94f6be401e54a2ded399b87c", callServer, void 0, findSourceMapURL, "action0"); +/* __next_internal_action_entry_do_not_use__ {"7f0090eaf4e1f08a2d94f6be401e54a2ded399b87c":"action0"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; +export var action0 = /*#__PURE__*/ createServerReference("7f0090eaf4e1f08a2d94f6be401e54a2ded399b87c", callServer, void 0, findSourceMapURL, "action0"); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/client/6/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/client/6/output.js index c10b22c39eb79..d495141ce7749 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/client/6/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/client/6/output.js @@ -1,3 +1,3 @@ -/* __next_internal_action_entry_do_not_use__ {"ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo","ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; -export var foo = /*#__PURE__*/ createServerReference("ab21efdafbe611287bc25c0462b1e0510d13e48b", callServer, void 0, findSourceMapURL, "foo"); -export var bar = /*#__PURE__*/ createServerReference("ac840dcaf5e8197cb02b7f3a43c119b7a770b272", callServer, void 0, findSourceMapURL, "bar"); +/* __next_internal_action_entry_do_not_use__ {"80ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo","ffac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; +export var foo = /*#__PURE__*/ createServerReference("80ab21efdafbe611287bc25c0462b1e0510d13e48b", callServer, void 0, findSourceMapURL, "foo"); +export var bar = /*#__PURE__*/ createServerReference("ffac840dcaf5e8197cb02b7f3a43c119b7a770b272", callServer, void 0, findSourceMapURL, "bar"); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/client/7/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/client/7/output.js index 3d0b3a767238a..30647bb277b15 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/client/7/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/client/7/output.js @@ -1,2 +1,2 @@ -/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; -export default /*#__PURE__*/ createServerReference("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", callServer, void 0, findSourceMapURL, "default"); +/* __next_internal_action_entry_do_not_use__ {"00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; +export default /*#__PURE__*/ createServerReference("00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", callServer, void 0, findSourceMapURL, "default"); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/client/8/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/client/8/output.js index aad83b202d0da..2eda815b72dd6 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/client/8/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/client/8/output.js @@ -1,2 +1,2 @@ -/* __next_internal_action_entry_do_not_use__ {"ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; -export var bar = /*#__PURE__*/ createServerReference("ac840dcaf5e8197cb02b7f3a43c119b7a770b272", callServer, void 0, findSourceMapURL, "bar"); +/* __next_internal_action_entry_do_not_use__ {"80ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; +export var bar = /*#__PURE__*/ createServerReference("80ac840dcaf5e8197cb02b7f3a43c119b7a770b272", callServer, void 0, findSourceMapURL, "bar"); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/1/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/1/output.js index 13a5faac070a3..ac3dd5fe69bfb 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/1/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/1/output.js @@ -1,20 +1,20 @@ -/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","0090b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import deleteFromDb from 'db'; export const $$RSC_SERVER_ACTION_0 = async function deleteItem($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); await deleteFromDb($$ACTION_ARG_0); await deleteFromDb($$ACTION_ARG_1); }; export function Item({ id1, id2 }) { - var deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ + var deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ id1, id2 ])); return ; } export const $$RSC_SERVER_ACTION_1 = async function action($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("0090b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); console.log($$ACTION_ARG_0); console.log($$ACTION_ARG_1); }; @@ -23,7 +23,7 @@ export default function Home() { name: 'John', test: 'test' }; - const action = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [ + const action = registerServerReference($$RSC_SERVER_ACTION_1, "0090b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("0090b5db271335765a4b0eab01f044b381b5ebd5cd", [ info.name, info.test ])); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/10/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/10/output.js index 9f6837fc25e39..51d06ea1032a0 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/10/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/10/output.js @@ -1,8 +1,8 @@ -/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export default async function foo() {} import { ensureServerEntryExports } from "private-next-rsc-action-validate"; ensureServerEntryExports([ foo ]); -registerServerReference(foo, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); +registerServerReference(foo, "00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/11/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/11/output.js index eff55113987db..efbd7926c6041 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/11/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/11/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export default async function $$RSC_SERVER_ACTION_0() {} Object.defineProperty($$RSC_SERVER_ACTION_0, "name", { @@ -9,4 +9,4 @@ import { ensureServerEntryExports } from "private-next-rsc-action-validate"; ensureServerEntryExports([ $$RSC_SERVER_ACTION_0 ]); -registerServerReference($$RSC_SERVER_ACTION_0, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); +registerServerReference($$RSC_SERVER_ACTION_0, "00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/12/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/12/output.js index e26854b05431a..0d49affe971e2 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/12/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/12/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; async function foo() {} export default foo; @@ -6,4 +6,4 @@ import { ensureServerEntryExports } from "private-next-rsc-action-validate"; ensureServerEntryExports([ foo ]); -registerServerReference(foo, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); +registerServerReference(foo, "7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/13/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/13/output.js index 062de8df3b921..607bb18b65e2c 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/13/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/13/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar","c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"7fac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar","7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; const foo = async function() {}; export default foo; @@ -9,5 +9,5 @@ ensureServerEntryExports([ foo, bar ]); -registerServerReference(foo, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); -registerServerReference(bar, "ac840dcaf5e8197cb02b7f3a43c119b7a770b272", null); +registerServerReference(foo, "7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); +registerServerReference(bar, "7fac840dcaf5e8197cb02b7f3a43c119b7a770b272", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/14/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/14/output.js index d0e615e2a5f00..36bc1df43d2c5 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/14/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/14/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"00ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export async function foo() { async function bar() {} @@ -7,4 +7,4 @@ import { ensureServerEntryExports } from "private-next-rsc-action-validate"; ensureServerEntryExports([ foo ]); -registerServerReference(foo, "ab21efdafbe611287bc25c0462b1e0510d13e48b", null); +registerServerReference(foo, "00ab21efdafbe611287bc25c0462b1e0510d13e48b", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/15/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/15/output.js index 6591e24a1067b..46f10d2286844 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/15/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/15/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"60c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export default $$RSC_SERVER_ACTION_0 = async (a, b)=>{ console.log(a, b); @@ -12,4 +12,4 @@ import { ensureServerEntryExports } from "private-next-rsc-action-validate"; ensureServerEntryExports([ $$RSC_SERVER_ACTION_0 ]); -registerServerReference($$RSC_SERVER_ACTION_0, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); +registerServerReference($$RSC_SERVER_ACTION_0, "60c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/16/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/16/output.js index 9aface52ba7c9..b56b6299995e9 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/16/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/16/output.js @@ -1,36 +1,36 @@ -/* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","7f1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","7f90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import deleteFromDb from 'db'; const v1 = 'v1'; export const $$RSC_SERVER_ACTION_0 = async function deleteItem($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); await deleteFromDb($$ACTION_ARG_0); await deleteFromDb(v1); await deleteFromDb($$ACTION_ARG_1); }; export function Item({ id1, id2 }) { const v2 = id2; - const deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ + const deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ id1, v2 ])); return ; } export const $$RSC_SERVER_ACTION_1 = async function g($$ACTION_CLOSURE_BOUND, y, ...z) { - var [$$ACTION_ARG_0] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0] = await decryptActionBoundArgs("7f90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); return $$ACTION_ARG_0 + y + z[0]; }; const f = (x)=>{ - var g = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [ + var g = registerServerReference($$RSC_SERVER_ACTION_1, "7f90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("7f90b5db271335765a4b0eab01f044b381b5ebd5cd", [ x ])); }; export const $$RSC_SERVER_ACTION_2 = async function f($$ACTION_CLOSURE_BOUND, y, ...z) { - var [$$ACTION_ARG_0] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0] = await decryptActionBoundArgs("7f1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND); return $$ACTION_ARG_0 + y + z[0]; }; const g = (x)=>{ - f = registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [ + f = registerServerReference($$RSC_SERVER_ACTION_2, "7f1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("7f1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [ x ])); }; diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/17/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/17/output.js index 1d3d971d66dec..de20684b09f56 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/17/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/17/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo","ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"7fab21efdafbe611287bc25c0462b1e0510d13e48b":"foo","7fac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export const foo = async ()=>{}; const bar = async ()=>{}; @@ -8,5 +8,5 @@ ensureServerEntryExports([ foo, bar ]); -registerServerReference(foo, "ab21efdafbe611287bc25c0462b1e0510d13e48b", null); -registerServerReference(bar, "ac840dcaf5e8197cb02b7f3a43c119b7a770b272", null); +registerServerReference(foo, "7fab21efdafbe611287bc25c0462b1e0510d13e48b", null); +registerServerReference(bar, "7fac840dcaf5e8197cb02b7f3a43c119b7a770b272", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/18/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/18/output.js index 913245726e824..e54ef92a61beb 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/18/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/18/output.js @@ -1,15 +1,15 @@ -/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","0090b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import deleteFromDb from 'db'; const v1 = 'v1'; export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); await deleteFromDb($$ACTION_ARG_0); await deleteFromDb(v1); await deleteFromDb($$ACTION_ARG_1); }; export const $$RSC_SERVER_ACTION_1 = async function action($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("0090b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); await deleteFromDb($$ACTION_ARG_0); await deleteFromDb(v1); await deleteFromDb($$ACTION_ARG_1); @@ -17,13 +17,13 @@ export const $$RSC_SERVER_ACTION_1 = async function action($$ACTION_CLOSURE_BOUN export function Item({ id1, id2 }) { const v2 = id2; return <> - - ; } export const $$RSC_SERVER_ACTION_1 = async function() {}; // TODO: should use `action` as function name? -export const action = withValidate(registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null)); +export const action = withValidate(registerServerReference($$RSC_SERVER_ACTION_1, "0090b5db271335765a4b0eab01f044b381b5ebd5cd", null)); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/20/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/20/output.js index 7d761f618f36c..e44165fbac5f8 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/20/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/20/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; const [foo] = [ null @@ -8,4 +8,4 @@ import { ensureServerEntryExports } from "private-next-rsc-action-validate"; ensureServerEntryExports([ foo ]); -registerServerReference(foo, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); +registerServerReference(foo, "7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/21/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/21/output.js index b61bcc441e01e..41f1a9dd7ab18 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/21/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/21/output.js @@ -1,19 +1,19 @@ -/* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"001c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","0090b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","406a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { validator, another } from 'auth'; const x = 1; export const $$RSC_SERVER_ACTION_0 = async function($$ACTION_CLOSURE_BOUND, z) { - var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0] = await decryptActionBoundArgs("406a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); return x + $$ACTION_ARG_0 + z; }; export default function Page() { const y = 1; return ; } export const $$RSC_SERVER_ACTION_1 = async function() {}; -validator(registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null)); +validator(registerServerReference($$RSC_SERVER_ACTION_1, "0090b5db271335765a4b0eab01f044b381b5ebd5cd", null)); export const $$RSC_SERVER_ACTION_2 = async function() {}; -another(validator(registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null))); +another(validator(registerServerReference($$RSC_SERVER_ACTION_2, "001c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null))); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/22/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/22/output.js index 9e19e05cd2dd5..cc01d76437af7 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/22/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/22/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default","f14702b5a021dd117f7ec7a3c838f397c2046d3b":"action"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default","7ff14702b5a021dd117f7ec7a3c838f397c2046d3b":"action"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { validator } from 'auth'; export const action = validator(async ()=>{}); @@ -13,5 +13,5 @@ ensureServerEntryExports([ action, $$RSC_SERVER_ACTION_0 ]); -registerServerReference(action, "f14702b5a021dd117f7ec7a3c838f397c2046d3b", null); -registerServerReference($$RSC_SERVER_ACTION_0, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); +registerServerReference(action, "7ff14702b5a021dd117f7ec7a3c838f397c2046d3b", null); +registerServerReference($$RSC_SERVER_ACTION_0, "7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/23/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/23/output.js index 575bbdb565857..11263e3d3bbb0 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/23/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/23/output.js @@ -1,19 +1,19 @@ -/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"786a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","7890b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND, a, b, c, d) { - var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0] = await decryptActionBoundArgs("786a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); console.log(a, b, $$ACTION_ARG_0, c, d); }; export const $$RSC_SERVER_ACTION_1 = async function action2($$ACTION_CLOSURE_BOUND, a, b, c, d) { - var [$$ACTION_ARG_0] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0] = await decryptActionBoundArgs("7890b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); console.log(a, b, $$ACTION_ARG_0, c, d); }; export default function Page({ foo, x, y }) { - var action = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ + var action = registerServerReference($$RSC_SERVER_ACTION_0, "786a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("786a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ x ])); action.bind(null, foo[0], foo[1], foo.x, foo[y]); - const action2 = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [ + const action2 = registerServerReference($$RSC_SERVER_ACTION_1, "7890b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("7890b5db271335765a4b0eab01f044b381b5ebd5cd", [ x ])); action2.bind(null, foo[0], foo[1], foo.x, foo[y]); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/24/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/24/output.js index 4b703fc416352..53f1878c6018b 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/24/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/24/output.js @@ -1,11 +1,11 @@ -/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"786a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND, a, b, c, { d }) { - var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0] = await decryptActionBoundArgs("786a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); console.log(a, b, $$ACTION_ARG_0, d); }; export default function Page({ foo, x, y }) { - var action = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ + var action = registerServerReference($$RSC_SERVER_ACTION_0, "786a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("786a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ foo ])); } diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/25/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/25/output.js index 87f58b5cf8279..536bcd26abc7e 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/25/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/25/output.js @@ -1,8 +1,8 @@ -/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","0090b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import deleteFromDb from 'db'; export const $$RSC_SERVER_ACTION_0 = async function deleteItem($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); await deleteFromDb($$ACTION_ARG_0); await deleteFromDb($$ACTION_ARG_1); }; @@ -12,13 +12,13 @@ export function Item({ id1, id2 }) { id1++; return ; })(); - var deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ + var deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ id1, id2 ])); } export const $$RSC_SERVER_ACTION_1 = async function deleteItem($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("0090b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); await deleteFromDb($$ACTION_ARG_0); await deleteFromDb($$ACTION_ARG_1); }; @@ -31,7 +31,7 @@ export function Item2({ id1, id2 }) { id1++; temp.push(); return temp; - var deleteItem = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [ + var deleteItem = registerServerReference($$RSC_SERVER_ACTION_1, "0090b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("0090b5db271335765a4b0eab01f044b381b5ebd5cd", [ id1, id2 ])); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/26/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/26/output.js index bb421458f268b..91e265804cbb6 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/26/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/26/output.js @@ -1,8 +1,8 @@ -/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"406a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; const noop = (action)=>action; export const $$RSC_SERVER_ACTION_0 = async function(data) { console.log(data); }; // TODO: should use `log` as function name? -export const log = noop(registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null)); +export const log = noop(registerServerReference($$RSC_SERVER_ACTION_0, "406a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null)); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/27/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/27/output.js index ea97c9cd0c761..1c4ba8e67eab9 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/27/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/27/output.js @@ -1,26 +1,26 @@ // Rules here: // 1. Each exported function should still be exported, but as a reference `registerServerReference(...)`. // 2. Actual action functions should be renamed to `$$ACTION_...` and got exported. -/* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","9ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3","a9b2939c1f39073a6bed227fd20233064c8b7869":"$$RSC_SERVER_ACTION_4"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"001c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","0090b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","009ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3","00a9b2939c1f39073a6bed227fd20233064c8b7869":"$$RSC_SERVER_ACTION_4"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export const $$RSC_SERVER_ACTION_0 = async function foo() { console.log(1); }; -var foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); +var foo = registerServerReference($$RSC_SERVER_ACTION_0, "006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); export { foo }; export const $$RSC_SERVER_ACTION_1 = async function bar() { console.log(2); }; -export var bar = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null); +export var bar = registerServerReference($$RSC_SERVER_ACTION_1, "0090b5db271335765a4b0eab01f044b381b5ebd5cd", null); export const $$RSC_SERVER_ACTION_2 = async function baz() { console.log(3); }; -export default registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null); +export default registerServerReference($$RSC_SERVER_ACTION_2, "001c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null); export const $$RSC_SERVER_ACTION_3 = async function qux() { console.log(4); }; -export const qux = registerServerReference($$RSC_SERVER_ACTION_3, "9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null); +export const qux = registerServerReference($$RSC_SERVER_ACTION_3, "009ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null); export const $$RSC_SERVER_ACTION_4 = async function quuux() { console.log(5); }; -export const quux = registerServerReference($$RSC_SERVER_ACTION_4, "a9b2939c1f39073a6bed227fd20233064c8b7869", null); +export const quux = registerServerReference($$RSC_SERVER_ACTION_4, "00a9b2939c1f39073a6bed227fd20233064c8b7869", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/28/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/28/output.js index 33a37276e4d84..2cee737c199c5 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/28/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/28/output.js @@ -1,23 +1,23 @@ -/* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"401c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","406a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","4090b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; let a, f; export const $$RSC_SERVER_ACTION_0 = async function action2($$ACTION_CLOSURE_BOUND, e) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("406a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); console.log(a, $$ACTION_ARG_0, $$ACTION_ARG_1, e, $$ACTION_ARG_2, $$ACTION_ARG_3); }; export const $$RSC_SERVER_ACTION_1 = async function action3($$ACTION_CLOSURE_BOUND, e) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("4090b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); $$ACTION_ARG_0(e); console.log(a, $$ACTION_ARG_1, $$ACTION_ARG_2, e); }; export const $$RSC_SERVER_ACTION_2 = async function action1($$ACTION_CLOSURE_BOUND, d) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("401c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND); let f; console.log(...window, { window }); console.log(a, $$ACTION_ARG_0, action2); - var action2 = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ + var action2 = registerServerReference($$RSC_SERVER_ACTION_0, "406a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("406a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ $$ACTION_ARG_1, d, f, @@ -25,7 +25,7 @@ export const $$RSC_SERVER_ACTION_2 = async function action1($$ACTION_CLOSURE_BOU ])); return [ action2, - registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [ + registerServerReference($$RSC_SERVER_ACTION_1, "4090b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("4090b5db271335765a4b0eab01f044b381b5ebd5cd", [ action2, $$ACTION_ARG_1, d @@ -33,7 +33,7 @@ export const $$RSC_SERVER_ACTION_2 = async function action1($$ACTION_CLOSURE_BOU ]; }; function Comp(b, c, ...g) { - return registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [ + return registerServerReference($$RSC_SERVER_ACTION_2, "401c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("401c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [ b, c, g diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/29/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/29/output.js index 1859c8026a6e7..5dbd8edbc96f8 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/29/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/29/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"28baf972d345b86b747ad0df73d75a0088a42214":"dec","c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"7f28baf972d345b86b747ad0df73d75a0088a42214":"dec","7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export const dec = async (value)=>{ return value - 1; @@ -10,5 +10,5 @@ ensureServerEntryExports([ dec, dec ]); -registerServerReference(dec, "28baf972d345b86b747ad0df73d75a0088a42214", null); -registerServerReference(dec, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); +registerServerReference(dec, "7f28baf972d345b86b747ad0df73d75a0088a42214", null); +registerServerReference(dec, "7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/3/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/3/output.js index 443d04812d7e1..f6947f77ffac0 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/3/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/3/output.js @@ -1,5 +1,5 @@ // app/send.ts -/* __next_internal_action_entry_do_not_use__ {"e10665baac148856374b2789aceb970f66fec33e":"myAction"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"70e10665baac148856374b2789aceb970f66fec33e":"myAction"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export async function myAction(a, b, c) { console.log('a'); @@ -8,4 +8,4 @@ import { ensureServerEntryExports } from "private-next-rsc-action-validate"; ensureServerEntryExports([ myAction ]); -registerServerReference(myAction, "e10665baac148856374b2789aceb970f66fec33e", null); +registerServerReference(myAction, "70e10665baac148856374b2789aceb970f66fec33e", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/30/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/30/output.js index a8195c3ac66f2..9137c825df167 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/30/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/30/output.js @@ -1,23 +1,23 @@ -/* __next_internal_action_entry_do_not_use__ {"0090eaf4e1f08a2d94f6be401e54a2ded399b87c":"action0","1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"401c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","406a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","4090b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","7f0090eaf4e1f08a2d94f6be401e54a2ded399b87c":"action0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; let a, f; export const $$RSC_SERVER_ACTION_0 = async function action2($$ACTION_CLOSURE_BOUND, e) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("406a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); console.log(a, $$ACTION_ARG_0, $$ACTION_ARG_1, e, $$ACTION_ARG_2, $$ACTION_ARG_3); }; export const $$RSC_SERVER_ACTION_1 = async function action3($$ACTION_CLOSURE_BOUND, e) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("4090b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); $$ACTION_ARG_0(e); console.log(a, $$ACTION_ARG_1, $$ACTION_ARG_2, e); }; export const $$RSC_SERVER_ACTION_2 = async function action1($$ACTION_CLOSURE_BOUND, d) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("401c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND); let f; console.log(...window, { window }); console.log(a, $$ACTION_ARG_0, action2); - var action2 = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ + var action2 = registerServerReference($$RSC_SERVER_ACTION_0, "406a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("406a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ $$ACTION_ARG_1, d, f, @@ -25,7 +25,7 @@ export const $$RSC_SERVER_ACTION_2 = async function action1($$ACTION_CLOSURE_BOU ])); return [ action2, - registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [ + registerServerReference($$RSC_SERVER_ACTION_1, "4090b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("4090b5db271335765a4b0eab01f044b381b5ebd5cd", [ action2, $$ACTION_ARG_1, d @@ -33,7 +33,7 @@ export const $$RSC_SERVER_ACTION_2 = async function action1($$ACTION_CLOSURE_BOU ]; }; export async function action0(b, c, ...g) { - return registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [ + return registerServerReference($$RSC_SERVER_ACTION_2, "401c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("401c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [ b, c, g @@ -43,4 +43,4 @@ import { ensureServerEntryExports } from "private-next-rsc-action-validate"; ensureServerEntryExports([ action0 ]); -registerServerReference(action0, "0090eaf4e1f08a2d94f6be401e54a2ded399b87c", null); +registerServerReference(action0, "7f0090eaf4e1f08a2d94f6be401e54a2ded399b87c", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/31/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/31/output.js index e4c3902986354..0fd39627004aa 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/31/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/31/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"abf760c735ba66c4c26a2913864dd7e28fb88a91":"action2","f14702b5a021dd117f7ec7a3c838f397c2046d3b":"action"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"7fabf760c735ba66c4c26a2913864dd7e28fb88a91":"action2","7ff14702b5a021dd117f7ec7a3c838f397c2046d3b":"action"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export const action = { async f (x) { @@ -21,5 +21,5 @@ ensureServerEntryExports([ action, action2 ]); -registerServerReference(action, "f14702b5a021dd117f7ec7a3c838f397c2046d3b", null); -registerServerReference(action2, "abf760c735ba66c4c26a2913864dd7e28fb88a91", null); \ No newline at end of file +registerServerReference(action, "7ff14702b5a021dd117f7ec7a3c838f397c2046d3b", null); +registerServerReference(action2, "7fabf760c735ba66c4c26a2913864dd7e28fb88a91", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/32/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/32/output.js index 889b803240e27..ff157bbc4f32e 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/32/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/32/output.js @@ -1,7 +1,7 @@ -/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); console.log($$ACTION_ARG_0.at(1), $$ACTION_ARG_1, $$ACTION_ARG_1.current); console.log($$ACTION_ARG_2.push.call($$ACTION_ARG_2, 5)); }; @@ -21,7 +21,7 @@ export function Component() { current: 1 } }; - var action = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ + var action = registerServerReference($$RSC_SERVER_ACTION_0, "006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ data, baz.value, foo diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/33/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/33/output.js index 4743ed48dea1f..086e124ba08ae 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/33/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/33/output.js @@ -1,15 +1,15 @@ -/* __next_internal_action_entry_do_not_use__ {"3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; const v = 'world'; -export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788b846c0d2b7f74743", async function fn() { +export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "803128060c414d59f8552e4788b846c0d2b7f74743", async function fn() { return 'hello, ' + v; }); Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { "value": "fn", "writable": false }); -var fn = registerServerReference($$RSC_SERVER_CACHE_0, "3128060c414d59f8552e4788b846c0d2b7f74743", null); +var fn = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); export async function Component() { const data = await fn(); return
{data}
; diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/34/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/34/output.js index e33c2754dca1d..e334026349c47 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/34/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/34/output.js @@ -1,42 +1,42 @@ -/* __next_internal_action_entry_do_not_use__ {"12a8d21b6362b4cc8f5b15560525095bc48dba80":"$$RSC_SERVER_CACHE_3","3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0","69348c79fce073bae2f70f139565a2fda1c74c74":"$$RSC_SERVER_CACHE_2","951c375b4a6a6e89d67b743ec5808127cfde405d":"$$RSC_SERVER_CACHE_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"8012a8d21b6362b4cc8f5b15560525095bc48dba80":"$$RSC_SERVER_CACHE_3","803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0","8069348c79fce073bae2f70f139565a2fda1c74c74":"$$RSC_SERVER_CACHE_2","80951c375b4a6a6e89d67b743ec5808127cfde405d":"$$RSC_SERVER_CACHE_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; -export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788b846c0d2b7f74743", async function() { +export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "803128060c414d59f8552e4788b846c0d2b7f74743", async function() { return 'foo'; }); Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { "value": "foo", "writable": false }); -const foo = registerServerReference($$RSC_SERVER_CACHE_0, "3128060c414d59f8552e4788b846c0d2b7f74743", null); +const foo = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); export { bar }; -export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743ec5808127cfde405d", async function bar() { +export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "80951c375b4a6a6e89d67b743ec5808127cfde405d", async function bar() { return 'bar'; }); Object.defineProperty($$RSC_SERVER_CACHE_1, "name", { "value": "bar", "writable": false }); -var bar = registerServerReference($$RSC_SERVER_CACHE_1, "951c375b4a6a6e89d67b743ec5808127cfde405d", null); +var bar = registerServerReference($$RSC_SERVER_CACHE_1, "80951c375b4a6a6e89d67b743ec5808127cfde405d", null); // Should not be wrapped in $$cache__. const qux = async function qux() { return 'qux'; }; -export var $$RSC_SERVER_CACHE_2 = $$cache__("default", "69348c79fce073bae2f70f139565a2fda1c74c74", async function baz() { +export var $$RSC_SERVER_CACHE_2 = $$cache__("default", "8069348c79fce073bae2f70f139565a2fda1c74c74", async function baz() { return qux() + 'baz'; }); Object.defineProperty($$RSC_SERVER_CACHE_2, "name", { "value": "baz", "writable": false }); -const baz = registerServerReference($$RSC_SERVER_CACHE_2, "69348c79fce073bae2f70f139565a2fda1c74c74", null); -export var $$RSC_SERVER_CACHE_3 = $$cache__("default", "12a8d21b6362b4cc8f5b15560525095bc48dba80", async function() { +const baz = registerServerReference($$RSC_SERVER_CACHE_2, "8069348c79fce073bae2f70f139565a2fda1c74c74", null); +export var $$RSC_SERVER_CACHE_3 = $$cache__("default", "8012a8d21b6362b4cc8f5b15560525095bc48dba80", async function() { return 'quux'; }); Object.defineProperty($$RSC_SERVER_CACHE_3, "name", { "value": "quux", "writable": false }); -const quux = registerServerReference($$RSC_SERVER_CACHE_3, "12a8d21b6362b4cc8f5b15560525095bc48dba80", null); +const quux = registerServerReference($$RSC_SERVER_CACHE_3, "8012a8d21b6362b4cc8f5b15560525095bc48dba80", null); export { foo, baz }; export default quux; diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/35/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/35/output.js index c4eec6775c9a4..93a7191cab2e4 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/35/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/35/output.js @@ -1,11 +1,11 @@ -/* __next_internal_action_entry_do_not_use__ {"3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; -export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788b846c0d2b7f74743", async function() { +export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "803128060c414d59f8552e4788b846c0d2b7f74743", async function() { return 'data'; }); Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { "value": "my_fn", "writable": false }); -export const my_fn = registerServerReference($$RSC_SERVER_CACHE_0, "3128060c414d59f8552e4788b846c0d2b7f74743", null); +export const my_fn = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/36/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/36/output.js index 09f64812ebc68..1c60a0901a298 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/36/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/36/output.js @@ -1,35 +1,35 @@ -/* __next_internal_action_entry_do_not_use__ {"12a8d21b6362b4cc8f5b15560525095bc48dba80":"$$RSC_SERVER_CACHE_3","3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0","69348c79fce073bae2f70f139565a2fda1c74c74":"$$RSC_SERVER_CACHE_2","951c375b4a6a6e89d67b743ec5808127cfde405d":"$$RSC_SERVER_CACHE_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"8012a8d21b6362b4cc8f5b15560525095bc48dba80":"$$RSC_SERVER_CACHE_3","803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0","80951c375b4a6a6e89d67b743ec5808127cfde405d":"$$RSC_SERVER_CACHE_1","c069348c79fce073bae2f70f139565a2fda1c74c74":"$$RSC_SERVER_CACHE_2"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; -export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788b846c0d2b7f74743", async function foo() { +export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "803128060c414d59f8552e4788b846c0d2b7f74743", async function foo() { return 'data A'; }); Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { "value": "foo", "writable": false }); -export var foo = registerServerReference($$RSC_SERVER_CACHE_0, "3128060c414d59f8552e4788b846c0d2b7f74743", null); -export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743ec5808127cfde405d", async function bar() { +export var foo = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); +export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "80951c375b4a6a6e89d67b743ec5808127cfde405d", async function bar() { return 'data B'; }); Object.defineProperty($$RSC_SERVER_CACHE_1, "name", { "value": "bar", "writable": false }); -export var bar = registerServerReference($$RSC_SERVER_CACHE_1, "951c375b4a6a6e89d67b743ec5808127cfde405d", null); -export var $$RSC_SERVER_CACHE_2 = $$cache__("default", "69348c79fce073bae2f70f139565a2fda1c74c74", async function Cached({ children }) { +export var bar = registerServerReference($$RSC_SERVER_CACHE_1, "80951c375b4a6a6e89d67b743ec5808127cfde405d", null); +export var $$RSC_SERVER_CACHE_2 = $$cache__("default", "c069348c79fce073bae2f70f139565a2fda1c74c74", async function Cached({ children }) { return children; }); Object.defineProperty($$RSC_SERVER_CACHE_2, "name", { "value": "Cached", "writable": false }); -export default registerServerReference($$RSC_SERVER_CACHE_2, "69348c79fce073bae2f70f139565a2fda1c74c74", null); -export var $$RSC_SERVER_CACHE_3 = $$cache__("default", "12a8d21b6362b4cc8f5b15560525095bc48dba80", async function baz() { +export default registerServerReference($$RSC_SERVER_CACHE_2, "c069348c79fce073bae2f70f139565a2fda1c74c74", null); +export var $$RSC_SERVER_CACHE_3 = $$cache__("default", "8012a8d21b6362b4cc8f5b15560525095bc48dba80", async function baz() { return 'data C'; }); Object.defineProperty($$RSC_SERVER_CACHE_3, "name", { "value": "baz", "writable": false }); -export const baz = registerServerReference($$RSC_SERVER_CACHE_3, "12a8d21b6362b4cc8f5b15560525095bc48dba80", null); +export const baz = registerServerReference($$RSC_SERVER_CACHE_3, "8012a8d21b6362b4cc8f5b15560525095bc48dba80", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/37/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/37/output.js index ad6c82a7ab063..217f29d74b34d 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/37/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/37/output.js @@ -1,14 +1,14 @@ -/* __next_internal_action_entry_do_not_use__ {"3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; -export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788b846c0d2b7f74743", async function fn() { +export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "803128060c414d59f8552e4788b846c0d2b7f74743", async function fn() { return 'foo'; }); Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { "value": "fn", "writable": false }); -var fn = registerServerReference($$RSC_SERVER_CACHE_0, "3128060c414d59f8552e4788b846c0d2b7f74743", null); +var fn = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); async function Component() { const data = await fn(); return
{data}
; diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/38/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/38/output.js index 5a2a7ce14af65..cac59ff51f644 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/38/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/38/output.js @@ -1,11 +1,11 @@ -/* __next_internal_action_entry_do_not_use__ {"3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; -export var $$RSC_SERVER_CACHE_0 = $$cache__("x", "3128060c414d59f8552e4788b846c0d2b7f74743", async function foo() { +export var $$RSC_SERVER_CACHE_0 = $$cache__("x", "803128060c414d59f8552e4788b846c0d2b7f74743", async function foo() { return 'data'; }); Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { "value": "foo", "writable": false }); -export var foo = registerServerReference($$RSC_SERVER_CACHE_0, "3128060c414d59f8552e4788b846c0d2b7f74743", null); +export var foo = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/39/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/39/output.js index 944a9d0fbd2cf..e809fc3d8331d 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/39/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/39/output.js @@ -1,8 +1,8 @@ -/* __next_internal_action_entry_do_not_use__ {"3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; -export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788b846c0d2b7f74743", async function fn($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("3128060c414d59f8552e4788b846c0d2b7f74743", $$ACTION_CLOSURE_BOUND); +export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "803128060c414d59f8552e4788b846c0d2b7f74743", async function fn($$ACTION_CLOSURE_BOUND) { + var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("803128060c414d59f8552e4788b846c0d2b7f74743", $$ACTION_CLOSURE_BOUND); console.log($$ACTION_ARG_0); return { foo: $$ACTION_ARG_1 @@ -14,11 +14,11 @@ Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { }); async function Component({ foo }) { const a = 123; - var fn = $$RSC_SERVER_REF_1.bind(null, encryptActionBoundArgs("3128060c414d59f8552e4788b846c0d2b7f74743", [ + var fn = $$RSC_SERVER_REF_1.bind(null, encryptActionBoundArgs("803128060c414d59f8552e4788b846c0d2b7f74743", [ a, foo ])); const data = await fn(); return
{data}
; } -var $$RSC_SERVER_REF_1 = registerServerReference($$RSC_SERVER_CACHE_0, "3128060c414d59f8552e4788b846c0d2b7f74743", null); +var $$RSC_SERVER_REF_1 = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/4/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/4/output.js index 38de763054a7f..9d426b74da7c0 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/4/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/4/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"1ab723c80dcca470e0410b4b2a2fc2bf21f41476":"c","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","6e7bc104e4d6e7fda190c4a51be969cfd0be6d6d":"a","d1f7eb64271d7c601dfef7d4d7053de1c2ca4338":"b"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"001ab723c80dcca470e0410b4b2a2fc2bf21f41476":"c","006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","006e7bc104e4d6e7fda190c4a51be969cfd0be6d6d":"a","00d1f7eb64271d7c601dfef7d4d7053de1c2ca4338":"b"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export async function a() {} export async function b() {} @@ -6,7 +6,7 @@ export async function c() {} function d() {} export const $$RSC_SERVER_ACTION_0 = async function e() {}; function Foo() { - var e = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); + var e = registerServerReference($$RSC_SERVER_ACTION_0, "006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); } import { ensureServerEntryExports } from "private-next-rsc-action-validate"; ensureServerEntryExports([ @@ -14,6 +14,6 @@ ensureServerEntryExports([ b, c ]); -registerServerReference(a, "6e7bc104e4d6e7fda190c4a51be969cfd0be6d6d", null); -registerServerReference(b, "d1f7eb64271d7c601dfef7d4d7053de1c2ca4338", null); -registerServerReference(c, "1ab723c80dcca470e0410b4b2a2fc2bf21f41476", null); +registerServerReference(a, "006e7bc104e4d6e7fda190c4a51be969cfd0be6d6d", null); +registerServerReference(b, "00d1f7eb64271d7c601dfef7d4d7053de1c2ca4338", null); +registerServerReference(c, "001ab723c80dcca470e0410b4b2a2fc2bf21f41476", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/40/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/40/output.js index 44e54e3305788..2a1761af52fbc 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/40/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/40/output.js @@ -1,8 +1,8 @@ -/* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"401c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","c03128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; -export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788b846c0d2b7f74743", async function cache($$ACTION_CLOSURE_BOUND, e) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("3128060c414d59f8552e4788b846c0d2b7f74743", $$ACTION_CLOSURE_BOUND); +export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "c03128060c414d59f8552e4788b846c0d2b7f74743", async function cache($$ACTION_CLOSURE_BOUND, e) { + var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("c03128060c414d59f8552e4788b846c0d2b7f74743", $$ACTION_CLOSURE_BOUND); const f = $$ACTION_ARG_0 + e; return [ f, @@ -16,9 +16,9 @@ Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { "writable": false }); export const $$RSC_SERVER_ACTION_2 = async function action($$ACTION_CLOSURE_BOUND, c) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("401c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND); const d = $$ACTION_ARG_0 + $$ACTION_ARG_1 + c; - var cache = $$RSC_SERVER_REF_1.bind(null, encryptActionBoundArgs("3128060c414d59f8552e4788b846c0d2b7f74743", [ + var cache = $$RSC_SERVER_REF_1.bind(null, encryptActionBoundArgs("c03128060c414d59f8552e4788b846c0d2b7f74743", [ d, $$ACTION_ARG_0 ])); @@ -26,7 +26,7 @@ export const $$RSC_SERVER_ACTION_2 = async function action($$ACTION_CLOSURE_BOUN }; async function Component({ a }) { const b = 1; - var action = registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [ + var action = registerServerReference($$RSC_SERVER_ACTION_2, "401c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("401c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [ a, b ])); @@ -34,4 +34,4 @@ async function Component({ a }) { ; } -var $$RSC_SERVER_REF_1 = registerServerReference($$RSC_SERVER_CACHE_0, "3128060c414d59f8552e4788b846c0d2b7f74743", null); +var $$RSC_SERVER_REF_1 = registerServerReference($$RSC_SERVER_CACHE_0, "c03128060c414d59f8552e4788b846c0d2b7f74743", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/41/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/41/output.js index 5633a68e84828..94bef357b693a 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/41/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/41/output.js @@ -1,16 +1,16 @@ -/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","951c375b4a6a6e89d67b743ec5808127cfde405d":"$$RSC_SERVER_CACHE_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","c0951c375b4a6a6e89d67b743ec5808127cfde405d":"$$RSC_SERVER_CACHE_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; export const $$RSC_SERVER_ACTION_0 = async function fn($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); console.log($$ACTION_ARG_0); return { foo: $$ACTION_ARG_1 }; }; -export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743ec5808127cfde405d", async function Component({ foo }) { +export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "c0951c375b4a6a6e89d67b743ec5808127cfde405d", async function Component({ foo }) { const a = 123; - var fn = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ + var fn = registerServerReference($$RSC_SERVER_ACTION_0, "006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ a, foo ])); @@ -21,4 +21,4 @@ Object.defineProperty($$RSC_SERVER_CACHE_1, "name", { "value": "Component", "writable": false }); -export var Component = registerServerReference($$RSC_SERVER_CACHE_1, "951c375b4a6a6e89d67b743ec5808127cfde405d", null); +export var Component = registerServerReference($$RSC_SERVER_CACHE_1, "c0951c375b4a6a6e89d67b743ec5808127cfde405d", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/42/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/42/output.js index bf2adbbf270d9..11ca54947cece 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/42/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/42/output.js @@ -1,8 +1,8 @@ -/* __next_internal_action_entry_do_not_use__ {"3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; -export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788b846c0d2b7f74743", async function($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("3128060c414d59f8552e4788b846c0d2b7f74743", $$ACTION_CLOSURE_BOUND); +export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "803128060c414d59f8552e4788b846c0d2b7f74743", async function($$ACTION_CLOSURE_BOUND) { + var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("803128060c414d59f8552e4788b846c0d2b7f74743", $$ACTION_CLOSURE_BOUND); console.log($$ACTION_ARG_0); return { foo: $$ACTION_ARG_1 @@ -10,11 +10,11 @@ export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788 }); async function Component({ foo }) { const a = 123; - const fn = $$RSC_SERVER_REF_1.bind(null, encryptActionBoundArgs("3128060c414d59f8552e4788b846c0d2b7f74743", [ + const fn = $$RSC_SERVER_REF_1.bind(null, encryptActionBoundArgs("803128060c414d59f8552e4788b846c0d2b7f74743", [ a, foo ])); const data = await fn(); return
{data}
; } -var $$RSC_SERVER_REF_1 = registerServerReference($$RSC_SERVER_CACHE_0, "3128060c414d59f8552e4788b846c0d2b7f74743", null); +var $$RSC_SERVER_REF_1 = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/43/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/43/output.js index 2c138ee83b9e4..2b8ed9d10e340 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/43/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/43/output.js @@ -1,17 +1,17 @@ -/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","951c375b4a6a6e89d67b743ec5808127cfde405d":"$$RSC_SERVER_CACHE_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","e0951c375b4a6a6e89d67b743ec5808127cfde405d":"$$RSC_SERVER_CACHE_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; import { Foo } from './client'; const secret = 'my password is qwerty123'; export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0] = await decryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); console.log(secret, $$ACTION_ARG_0); }; -export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743ec5808127cfde405d", async function getCachedRandom(x, children) { +export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "e0951c375b4a6a6e89d67b743ec5808127cfde405d", async function getCachedRandom(x, children) { return { x, y: Math.random(), - z: , r: children @@ -21,4 +21,4 @@ Object.defineProperty($$RSC_SERVER_CACHE_1, "name", { "value": "getCachedRandom", "writable": false }); -var getCachedRandom = registerServerReference($$RSC_SERVER_CACHE_1, "951c375b4a6a6e89d67b743ec5808127cfde405d", null); +var getCachedRandom = registerServerReference($$RSC_SERVER_CACHE_1, "e0951c375b4a6a6e89d67b743ec5808127cfde405d", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/44/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/44/output.js index 74bafa75d6f26..c381f6670ab49 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/44/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/44/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","9ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3","a9b2939c1f39073a6bed227fd20233064c8b7869":"$$RSC_SERVER_ACTION_4"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"001c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","0090b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","009ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3","00a9b2939c1f39073a6bed227fd20233064c8b7869":"$$RSC_SERVER_ACTION_4"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { Form } from './form'; export const $$RSC_SERVER_ACTION_0 = async function foo() { @@ -17,13 +17,13 @@ export const $$RSC_SERVER_ACTION_4 = async function baz() { return 'named function expression'; }; export default function Page() { - const foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); - var bar = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null); + const foo = registerServerReference($$RSC_SERVER_ACTION_0, "006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); + var bar = registerServerReference($$RSC_SERVER_ACTION_1, "0090b5db271335765a4b0eab01f044b381b5ebd5cd", null); return <>
- - - + + + ; } diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/45/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/45/output.js index 5661cb7b69c30..1c75a5c34554d 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/45/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/45/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"803128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; // Expect no error here, this is allowed to be sync because it's not exported. @@ -7,11 +7,11 @@ function Foo() { console.log(v); return v; } -export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788b846c0d2b7f74743", async function bar() { +export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "803128060c414d59f8552e4788b846c0d2b7f74743", async function bar() { return ; }); Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { "value": "bar", "writable": false }); -export var bar = registerServerReference($$RSC_SERVER_CACHE_0, "3128060c414d59f8552e4788b846c0d2b7f74743", null); +export var bar = registerServerReference($$RSC_SERVER_CACHE_0, "803128060c414d59f8552e4788b846c0d2b7f74743", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/46/input.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/46/input.js new file mode 100644 index 0000000000000..1ee0ad17b6006 --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/46/input.js @@ -0,0 +1,37 @@ +// This is for testing the "information byte" of Server Action / Cache IDs. + +// Should be 1 110000 0, which is "e0" in hex. +async function f1(a, b) { + 'use cache' + return [a, b] +} + +// Should be 0 110000 0, which is "60" in hex. +async function f2(a, b) { + 'use server' + return [a, b] +} + +// Should be 1 111111 1, which is "ff" in hex. +async function f3(a, b, ...rest) { + 'use cache' + return [a, b, rest] +} + +// Should be 0 111110 0, which is "7c" in hex. +async function f4(a, b, c, d, e) { + 'use server' + return [a, b, c, d, e] +} + +// Should be 0 111111 0, which is "7e" in hex. +async function f4(a, b, c, d, e, f) { + 'use server' + return [a, b, c, d, e, f] +} + +// Should be 1 111111 1, which is "ff" in hex. +async function f5(a, b, c, d, e, f, g) { + 'use cache' + return [a, b, c, d, e, f, g] +} diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/46/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/46/output.js new file mode 100644 index 0000000000000..c2bde673e8829 --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/46/output.js @@ -0,0 +1,77 @@ +// This is for testing the "information byte" of Server Action / Cache IDs. +// Should be 1 110000 0, which is "e0" in hex. +/* __next_internal_action_entry_do_not_use__ {"6090b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","7c9ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3","7ea9b2939c1f39073a6bed227fd20233064c8b7869":"$$RSC_SERVER_ACTION_4","e03128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0","ff471a5eb0be1c31686dd4ba938a80328b80b1615d":"$$RSC_SERVER_CACHE_5","ff69348c79fce073bae2f70f139565a2fda1c74c74":"$$RSC_SERVER_CACHE_2"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; +import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; +export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "e03128060c414d59f8552e4788b846c0d2b7f74743", async function f1(a, b) { + return [ + a, + b + ]; +}); +Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { + "value": "f1", + "writable": false +}); +var f1 = registerServerReference($$RSC_SERVER_CACHE_0, "e03128060c414d59f8552e4788b846c0d2b7f74743", null); +export const // Should be 0 110000 0, which is "60" in hex. +$$RSC_SERVER_ACTION_1 = async function f2(a, b) { + return [ + a, + b + ]; +}; +var f2 = registerServerReference($$RSC_SERVER_ACTION_1, "6090b5db271335765a4b0eab01f044b381b5ebd5cd", null); +export var $$RSC_SERVER_CACHE_2 = $$cache__("default", "ff69348c79fce073bae2f70f139565a2fda1c74c74", // Should be 1 111111 1, which is "ff" in hex. +async function f3(a, b, ...rest) { + return [ + a, + b, + rest + ]; +}); +Object.defineProperty($$RSC_SERVER_CACHE_2, "name", { + "value": "f3", + "writable": false +}); +var f3 = registerServerReference($$RSC_SERVER_CACHE_2, "ff69348c79fce073bae2f70f139565a2fda1c74c74", null); +export const // Should be 0 111110 0, which is "7c" in hex. +$$RSC_SERVER_ACTION_3 = async function f4(a, b, c, d, e) { + return [ + a, + b, + c, + d, + e + ]; +}; +var f4 = registerServerReference($$RSC_SERVER_ACTION_3, "7c9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null); +export const // Should be 0 111111 0, which is "7e" in hex. +$$RSC_SERVER_ACTION_4 = async function f4(a, b, c, d, e, f) { + return [ + a, + b, + c, + d, + e, + f + ]; +}; +var f4 = registerServerReference($$RSC_SERVER_ACTION_4, "7ea9b2939c1f39073a6bed227fd20233064c8b7869", null); +export var $$RSC_SERVER_CACHE_5 = $$cache__("default", "ff471a5eb0be1c31686dd4ba938a80328b80b1615d", // Should be 1 111111 1, which is "ff" in hex. +async function f5(a, b, c, d, e, f, g) { + return [ + a, + b, + c, + d, + e, + f, + g + ]; +}); +Object.defineProperty($$RSC_SERVER_CACHE_5, "name", { + "value": "f5", + "writable": false +}); +var f5 = registerServerReference($$RSC_SERVER_CACHE_5, "ff471a5eb0be1c31686dd4ba938a80328b80b1615d", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/47/input.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/47/input.js new file mode 100644 index 0000000000000..8a45f34130a3d --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/47/input.js @@ -0,0 +1,23 @@ +import { redirect } from 'next/navigation' + +async function action(formData) { + 'use server' + redirect( + '/header?name=' + + formData.get('name') + + '&hidden-info=' + + formData.get('hidden-info') + ) +} + +export default function Form() { + return ( + + + + + + ) +} diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/47/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/47/output.js new file mode 100644 index 0000000000000..aca93544a6413 --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/47/output.js @@ -0,0 +1,16 @@ +/* __next_internal_action_entry_do_not_use__ {"406a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; +import { redirect } from 'next/navigation'; +export const $$RSC_SERVER_ACTION_0 = async function action(formData) { + redirect('/header?name=' + formData.get('name') + '&hidden-info=' + formData.get('hidden-info')); +}; +var action = registerServerReference($$RSC_SERVER_ACTION_0, "406a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); +export default function Form() { + return
+ + + +
; +} diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/48/input.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/48/input.js new file mode 100644 index 0000000000000..f2a39377871e4 --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/48/input.js @@ -0,0 +1,45 @@ +'use server' + +// Should be 0 111000 0, which is "70" in hex. +export async function action(a, b, c) { + return ( +
+ {a} + {b} + {c} +
+ ) +} + +// Should be 0 111111 1, which is "7f" in hex. +export default async function action2(a, b, ...c) { + return ( +
+ {a} + {b} + {c} +
+ ) +} + +// Should be 0 111111 1, which is "60" in hex. +export async function action3(a, b) { + 'use server' + return ( +
+ {a} + {b} +
+ ) +} + +// Should be 1 110000 0, which is "e0" in hex. +export async function cache(a, b) { + 'use cache' + return ( +
+ {a} + {b} +
+ ) +} diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/48/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/48/output.js new file mode 100644 index 0000000000000..fbb5634dfae0a --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/48/output.js @@ -0,0 +1,47 @@ +/* __next_internal_action_entry_do_not_use__ {"60079087479e4c103d815f273878c7d1b8e902cc39":"action3","70f14702b5a021dd117f7ec7a3c838f397c2046d3b":"action","7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default","e03128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; +import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; +// Should be 0 111000 0, which is "70" in hex. +export async function action(a, b, c) { + return
+ {a} + {b} + {c} +
; +} +// Should be 0 111111 1, which is "7f" in hex. +export default async function action2(a, b, ...c) { + return
+ {a} + {b} + {c} +
; +} +// Should be 0 111111 1, which is "60" in hex. +export async function action3(a, b) { + return
+ {a} + {b} +
; +} +export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "e03128060c414d59f8552e4788b846c0d2b7f74743", async function cache(a, b) { + return
+ {a} + {b} +
; +}); +Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { + "value": "cache", + "writable": false +}); +// Should be 1 110000 0, which is "e0" in hex. +export var cache = registerServerReference($$RSC_SERVER_CACHE_0, "e03128060c414d59f8552e4788b846c0d2b7f74743", null); +import { ensureServerEntryExports } from "private-next-rsc-action-validate"; +ensureServerEntryExports([ + action, + action2, + action3 +]); +registerServerReference(action, "70f14702b5a021dd117f7ec7a3c838f397c2046d3b", null); +registerServerReference(action2, "7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); +registerServerReference(action3, "60079087479e4c103d815f273878c7d1b8e902cc39", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/49/input.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/49/input.js new file mode 100644 index 0000000000000..2109d425783d1 --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/49/input.js @@ -0,0 +1,13 @@ +'use server' + +export default async (a, b, c) => { + 'use cache' + + return ( +
+ {a} + {b} + {c} +
+ ) +} diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/49/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/49/output.js new file mode 100644 index 0000000000000..241d76da05d22 --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/49/output.js @@ -0,0 +1,11 @@ +/* __next_internal_action_entry_do_not_use__ {"f03128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; +import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; +export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "f03128060c414d59f8552e4788b846c0d2b7f74743", async function(a, b, c) { + return
+ {a} + {b} + {c} +
; +}); +export default registerServerReference($$RSC_SERVER_CACHE_0, "f03128060c414d59f8552e4788b846c0d2b7f74743", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/5/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/5/output.js index 8ddf8ecc0ffa6..a7406c49f8658 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/5/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/5/output.js @@ -1,9 +1,9 @@ -/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import deleteFromDb from 'db'; const v1 = 'v1'; export const $$RSC_SERVER_ACTION_0 = async function deleteItem($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); await deleteFromDb($$ACTION_ARG_0); await deleteFromDb(v1); await deleteFromDb($$ACTION_ARG_1); @@ -14,7 +14,7 @@ export const $$RSC_SERVER_ACTION_0 = async function deleteItem($$ACTION_CLOSURE_ }; export function Item({ id1, id2, id3, id4 }) { const v2 = id2; - var deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ + var deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ id1, v2, id3, diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/50/input.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/50/input.js new file mode 100644 index 0000000000000..2d4a72ba13a61 --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/50/input.js @@ -0,0 +1,13 @@ +'use server' + +export default async function (a, b, c) { + 'use cache' + + return ( +
+ {a} + {b} + {c} +
+ ) +} diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/50/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/50/output.js new file mode 100644 index 0000000000000..2f8a608608490 --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/50/output.js @@ -0,0 +1,15 @@ +/* __next_internal_action_entry_do_not_use__ {"f03128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; +import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; +export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "f03128060c414d59f8552e4788b846c0d2b7f74743", async function(a, b, c) { + return
+ {a} + {b} + {c} +
; +}); +Object.defineProperty($$RSC_SERVER_CACHE_0, "name", { + "value": "default", + "writable": false +}); +export default registerServerReference($$RSC_SERVER_CACHE_0, "f03128060c414d59f8552e4788b846c0d2b7f74743", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/51/input.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/51/input.js new file mode 100644 index 0000000000000..63a74d7121b7b --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/51/input.js @@ -0,0 +1,35 @@ +'use cache' + +export default async function (a, b, c) { + 'use server' + + return ( +
+ {a} + {b} + {c} +
+ ) +} + +export async function foo(a, b) { + 'use server' + + return ( +
+ {a} + {b} +
+ ) +} + +export const bar = async (a, b) => { + 'use server' + + return ( +
+ {a} + {b} +
+ ) +} diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/51/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/51/output.js new file mode 100644 index 0000000000000..7406874b1a6ab --- /dev/null +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/51/output.js @@ -0,0 +1,29 @@ +/* __next_internal_action_entry_do_not_use__ {"601c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","609ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3","7090b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; +import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; +export const $$RSC_SERVER_ACTION_1 = async function $$RSC_SERVER_ACTION_0(a, b, c) { + return
+ {a} + {b} + {c} +
; +}; +export default registerServerReference($$RSC_SERVER_ACTION_1, "7090b5db271335765a4b0eab01f044b381b5ebd5cd", null); +Object.defineProperty($$RSC_SERVER_ACTION_0, "name", { + "value": "default", + "writable": false +}); +export const $$RSC_SERVER_ACTION_2 = async function foo(a, b) { + return
+ {a} + {b} +
; +}; +export var foo = registerServerReference($$RSC_SERVER_ACTION_2, "601c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null); +export const $$RSC_SERVER_ACTION_3 = async function bar(a, b) { + return
+ {a} + {b} +
; +}; +export const bar = registerServerReference($$RSC_SERVER_ACTION_3, "609ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null); diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/6/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/6/output.js index cb2983ede9ea5..499dd2c17ef3a 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/6/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/6/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import f, { f1, f2 } from 'foo'; const f3 = 1; @@ -13,7 +13,7 @@ function x() { const g201 = 1; } export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3, $$ACTION_ARG_4, $$ACTION_ARG_5] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3, $$ACTION_ARG_4, $$ACTION_ARG_5] = await decryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); const f17 = 1; if (true) { const f18 = 1; @@ -28,7 +28,7 @@ export function y(p, [p1, { p2 }], ...p3) { if (true) { const f8 = 1; } - var action = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ + var action = registerServerReference($$RSC_SERVER_ACTION_0, "006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ f2, f11, p, diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/7/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/7/output.js index 387dd861899c2..e691fe34bed92 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/7/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/7/output.js @@ -1,12 +1,12 @@ -/* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","9ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"001c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","006a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","0090b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","009ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import deleteFromDb from 'db'; export const $$RSC_SERVER_ACTION_0 = async function deleteItem1($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); await deleteFromDb($$ACTION_ARG_0.id, $$ACTION_ARG_0?.foo, $$ACTION_ARG_0.bar.baz, $$ACTION_ARG_0[$$ACTION_ARG_1, $$ACTION_ARG_2]); }; export function Item1(product, foo, bar) { - const a = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ + const a = registerServerReference($$RSC_SERVER_ACTION_0, "006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("006a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ product, foo, bar @@ -14,11 +14,11 @@ export function Item1(product, foo, bar) { return ; } export const $$RSC_SERVER_ACTION_1 = async function deleteItem2($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("0090b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); await deleteFromDb($$ACTION_ARG_0.id, $$ACTION_ARG_0?.foo, $$ACTION_ARG_0.bar.baz, $$ACTION_ARG_0[$$ACTION_ARG_1, $$ACTION_ARG_2]); }; export function Item2(product, foo, bar) { - var deleteItem2 = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [ + var deleteItem2 = registerServerReference($$RSC_SERVER_ACTION_1, "0090b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("0090b5db271335765a4b0eab01f044b381b5ebd5cd", [ product, foo, bar @@ -26,11 +26,11 @@ export function Item2(product, foo, bar) { return ; } export const $$RSC_SERVER_ACTION_2 = async function deleteItem3($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("001c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND); await deleteFromDb($$ACTION_ARG_0.id, $$ACTION_ARG_0?.foo, $$ACTION_ARG_0.bar.baz, $$ACTION_ARG_0[$$ACTION_ARG_1, $$ACTION_ARG_2]); }; export function Item3(product, foo, bar) { - const deleteItem3 = registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [ + const deleteItem3 = registerServerReference($$RSC_SERVER_ACTION_2, "001c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("001c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [ product, foo, bar @@ -38,11 +38,11 @@ export function Item3(product, foo, bar) { return ; } export const $$RSC_SERVER_ACTION_3 = async function deleteItem4($$ACTION_CLOSURE_BOUND) { - var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", $$ACTION_CLOSURE_BOUND); + var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("009ed0cc47abc4e1c64320cf42b74ae60b58c40f00", $$ACTION_CLOSURE_BOUND); await deleteFromDb($$ACTION_ARG_0.id, $$ACTION_ARG_0?.foo, $$ACTION_ARG_0.bar.baz, $$ACTION_ARG_0[$$ACTION_ARG_1, $$ACTION_ARG_2]); }; export function Item4(product, foo, bar) { - const deleteItem4 = registerServerReference($$RSC_SERVER_ACTION_3, "9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null).bind(null, encryptActionBoundArgs("9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", [ + const deleteItem4 = registerServerReference($$RSC_SERVER_ACTION_3, "009ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null).bind(null, encryptActionBoundArgs("009ed0cc47abc4e1c64320cf42b74ae60b58c40f00", [ product, foo, bar diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/8/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/8/output.js index d4f3bd1d0efb2..290f7f414d8b4 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/8/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/8/output.js @@ -1,11 +1,11 @@ -/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"706a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; export const $$RSC_SERVER_ACTION_0 = async function myAction(a, b, c) { // comment 'use strict'; console.log('a'); }; -var myAction = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); +var myAction = registerServerReference($$RSC_SERVER_ACTION_0, "706a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); export default function Page() { return ; } diff --git a/crates/next-custom-transforms/tests/fixture/server-actions/server/9/output.js b/crates/next-custom-transforms/tests/fixture/server-actions/server/9/output.js index b64224de832ca..d369550a96f8c 100644 --- a/crates/next-custom-transforms/tests/fixture/server-actions/server/9/output.js +++ b/crates/next-custom-transforms/tests/fixture/server-actions/server/9/output.js @@ -1,5 +1,5 @@ // app/send.ts -/* __next_internal_action_entry_do_not_use__ {"050e3854b72b19e3c7e3966a67535543a90bf7e0":"baz","ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo","c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; +/* __next_internal_action_entry_do_not_use__ {"7f050e3854b72b19e3c7e3966a67535543a90bf7e0":"baz","7fab21efdafbe611287bc25c0462b1e0510d13e48b":"foo","7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; async function foo() {} export { foo }; @@ -13,6 +13,6 @@ ensureServerEntryExports([ bar, qux ]); -registerServerReference(foo, "ab21efdafbe611287bc25c0462b1e0510d13e48b", null); -registerServerReference(bar, "050e3854b72b19e3c7e3966a67535543a90bf7e0", null); -registerServerReference(qux, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); +registerServerReference(foo, "7fab21efdafbe611287bc25c0462b1e0510d13e48b", null); +registerServerReference(bar, "7f050e3854b72b19e3c7e3966a67535543a90bf7e0", null); +registerServerReference(qux, "7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); diff --git a/packages/next/src/build/webpack/loaders/utils.ts b/packages/next/src/build/webpack/loaders/utils.ts index 4a8536ec86845..6a734518bce90 100644 --- a/packages/next/src/build/webpack/loaders/utils.ts +++ b/packages/next/src/build/webpack/loaders/utils.ts @@ -43,6 +43,7 @@ export function isCSSMod(mod: { ) } +// Gives { id: name } record of actions from the build info. export function getActionsFromBuildInfo(mod: { resource: string buildInfo?: any diff --git a/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts b/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts index 8348438b989f1..0dd244684d4b1 100644 --- a/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts +++ b/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts @@ -42,8 +42,6 @@ import { getModuleBuildInfo } from '../loaders/get-module-build-info' import { getAssumedSourceType } from '../loaders/next-flight-loader' import { isAppRouteRoute } from '../../../lib/is-app-route-route' -type ActionIdNamePair = [id: string, name: string] - interface Options { dev: boolean appDir: string @@ -65,6 +63,8 @@ type Actions = { } } +type ActionIdNamePair = [id: string, name: string] + export type ActionManifest = { // Assign a unique encryption key during production build. encryptionKey: string From bfdf52785869766179a29850a2431cef4e0e2367 Mon Sep 17 00:00:00 2001 From: elitalpa Date: Mon, 28 Oct 2024 07:00:38 +0100 Subject: [PATCH 5/6] fix: webpack build error on Windows (#71943) --- .../src/build/webpack/loaders/next-metadata-route-loader.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/next/src/build/webpack/loaders/next-metadata-route-loader.ts b/packages/next/src/build/webpack/loaders/next-metadata-route-loader.ts index a3b7153655585..b6dae3bbfabcf 100644 --- a/packages/next/src/build/webpack/loaders/next-metadata-route-loader.ts +++ b/packages/next/src/build/webpack/loaders/next-metadata-route-loader.ts @@ -76,8 +76,6 @@ async function getStaticAssetRouteCode( resourcePath: string, fileBaseName: string ) { - resourcePath = path.posix.normalize(resourcePath) - const cache = fileBaseName === 'favicon' ? 'public, max-age=0, must-revalidate' @@ -107,7 +105,7 @@ const buffer = Buffer.from(${JSON.stringify( if (${isTwitter || isOpenGraph}) { const fileSizeInMB = buffer.byteLength / 1024 / 1024 if (fileSizeInMB > ${fileSizeLimit}) { - throw new Error('File size for ${imgName} image "${resourcePath}" exceeds ${fileSizeLimit}MB. ' + + throw new Error('File size for ${imgName} image ${JSON.stringify(resourcePath)} exceeds ${fileSizeLimit}MB. ' + \`(Current: \${fileSizeInMB.toFixed(2)}MB)\n\` + 'Read more: https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image#image-files-jpg-png-gif' ) From 655b808c5b352350fe85c0fadc7b92ff251e675b Mon Sep 17 00:00:00 2001 From: "Sebastian \"Sebbie\" Silbermann" Date: Mon, 28 Oct 2024 10:23:03 +0100 Subject: [PATCH 6/6] Run with `--enable-source-maps` by default in `next dev` (#71820) We already create server source maps in dev by default, so we should make use of them. To opt-out, run `next dev --disable-source-maps` instead. Our internal `next-no-sourcemaps` script is now defunct. --- package.json | 4 +- packages/next/src/bin/next.ts | 5 + packages/next/src/cli/next-dev.ts | 7 + run-tests.js | 4 + .../middleware-errors/index.test.ts | 121 ++++++----- .../fixtures/default/.gitignore | 2 + .../app/rsc-error-log-ignore-listed/page.js | 11 + .../app/ssr-error-log-ignore-listed/page.js | 12 ++ .../default/app/ssr-error-log/page.js | 11 + .../fixtures/default/internal-pkg/index.js | 3 + .../default/internal-pkg/package.json | 10 + .../fixtures/default/package.json | 5 + .../server-source-maps.test.ts | 191 +++++++++++++++++- 13 files changed, 332 insertions(+), 54 deletions(-) create mode 100644 test/e2e/app-dir/server-source-maps/fixtures/default/.gitignore create mode 100644 test/e2e/app-dir/server-source-maps/fixtures/default/app/rsc-error-log-ignore-listed/page.js create mode 100644 test/e2e/app-dir/server-source-maps/fixtures/default/app/ssr-error-log-ignore-listed/page.js create mode 100644 test/e2e/app-dir/server-source-maps/fixtures/default/app/ssr-error-log/page.js create mode 100644 test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/index.js create mode 100644 test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/package.json create mode 100644 test/e2e/app-dir/server-source-maps/fixtures/default/package.json diff --git a/package.json b/package.json index 2aa471ddde59d..d4599a71909bd 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,8 @@ "prepublishOnly": "turbo run build", "lint-staged": "lint-staged", "next-with-deps": "./scripts/next-with-deps.sh", - "next": "cross-env NEXT_TELEMETRY_DISABLED=1 node --trace-deprecation --enable-source-maps packages/next/dist/bin/next", - "next-no-sourcemaps": "cross-env NEXT_TELEMETRY_DISABLED=1 node --trace-deprecation packages/next/dist/bin/next", + "next": "cross-env NEXT_TELEMETRY_DISABLED=1 NODE_OPTIONS=\"--trace-deprecation --enable-source-maps\" next", + "next-no-sourcemaps": "echo 'No longer supported. Use `pnpm next --disable-source-maps` instead'; exit 1;", "clean-trace-jaeger": "node scripts/rm.mjs test/integration/basic/.next && TRACE_TARGET=JAEGER pnpm next build test/integration/basic", "debug": "cross-env NEXT_TELEMETRY_DISABLED=1 node --inspect --trace-deprecation --enable-source-maps packages/next/dist/bin/next", "postinstall": "node scripts/git-configure.mjs && node scripts/install-native.mjs", diff --git a/packages/next/src/bin/next.ts b/packages/next/src/bin/next.ts index 56a864f4cc5fd..4019efaf7e811 100755 --- a/packages/next/src/bin/next.ts +++ b/packages/next/src/bin/next.ts @@ -172,6 +172,11 @@ program '-H, --hostname ', 'Specify a hostname on which to start the application (default: 0.0.0.0).' ) + .option( + '--disable-source-maps', + "Don't start the Dev server with `--enable-source-maps`.", + false + ) .option( '--experimental-https', 'Starts the server with HTTPS and generates a self-signed certificate.' diff --git a/packages/next/src/cli/next-dev.ts b/packages/next/src/cli/next-dev.ts index d4ac9d067a32c..af8f8a7e9f9ad 100644 --- a/packages/next/src/cli/next-dev.ts +++ b/packages/next/src/cli/next-dev.ts @@ -40,6 +40,7 @@ import { flushAllTraces, trace } from '../trace' import { traceId } from '../trace/shared' export type NextDevOptions = { + disableSourceMaps: boolean turbo?: boolean turbopack?: boolean port: number @@ -267,6 +268,12 @@ const nextDev = async ( delete nodeOptions['max_old_space_size'] } + if (options.disableSourceMaps) { + delete nodeOptions['enable-source-maps'] + } else { + nodeOptions['enable-source-maps'] = true + } + if (nodeDebugType) { const address = getParsedDebugAddress() address.port = address.port + 1 diff --git a/run-tests.js b/run-tests.js index 533c121796967..fe2c01ea840a9 100644 --- a/run-tests.js +++ b/run-tests.js @@ -480,6 +480,10 @@ ${ENDGROUP}`) // unset CI env so CI behavior is only explicitly // tested when enabled CI: '', + // But some tests need to fork based on machine? CI? behavior differences + // Only use read this in tests. + // For implementation forks, use `process.env.CI` instead + NEXT_TEST_CI: process.env.CI, ...(options.local ? {} diff --git a/test/development/middleware-errors/index.test.ts b/test/development/middleware-errors/index.test.ts index 511511945c472..545eceed4a428 100644 --- a/test/development/middleware-errors/index.test.ts +++ b/test/development/middleware-errors/index.test.ts @@ -3,6 +3,7 @@ import { assertNoRedbox, check, getRedboxSource, + retry, } from 'next-test-utils' import stripAnsi from 'strip-ansi' import { nextTestSetup } from 'e2e-utils' @@ -31,23 +32,22 @@ describe('middleware - development errors', () => { it('logs the error correctly', async () => { await next.fetch('/') - const output = stripAnsi(next.cliOutput) - await check(() => { - if (isTurbopack) { - expect(stripAnsi(next.cliOutput)).toMatch( - /middleware.js \(\d+:\d+\) @ __TURBOPACK__default__export__/ - ) - } else { - expect(stripAnsi(next.cliOutput)).toMatch( - /middleware.js \(\d+:\d+\) @ default/ - ) - } - - expect(stripAnsi(next.cliOutput)).toMatch(/boom/) - return 'success' - }, 'success') - expect(output).not.toContain( - 'webpack-internal:///(middleware)/./middleware.js' + + await retry(() => { + expect(stripAnsi(next.cliOutput)).toContain('boom') + }) + // TODO: assert on full, ignore-listed stack + expect(stripAnsi(next.cliOutput)).toContain( + isTurbopack + ? '\n ⨯ middleware.js (3:15) @ __TURBOPACK__default__export__' + + '\n ⨯ Error: boom' + + '\n at __TURBOPACK__default__export__ (./middleware.js:3:15)' + : '\n ⨯ middleware.js (3:15) @ default' + + '\n ⨯ boom' + + '\n 1 |' + + '\n 2 | export default function () {' + + "\n> 3 | throw new Error('boom')" + + '\n | ^' ) }) @@ -79,13 +79,20 @@ describe('middleware - development errors', () => { it('logs the error correctly', async () => { await next.fetch('/') - await check( - () => stripAnsi(next.cliOutput), - new RegExp(`unhandledRejection: Error: async boom!`, 'm') + + await retry(() => { + expect(stripAnsi(next.cliOutput)).toContain( + 'unhandledRejection: Error: async boom!' + ) + }) + // TODO: assert on full, ignore-listed stack + expect(stripAnsi(next.cliOutput)).toContain( + isTurbopack + ? 'unhandledRejection: Error: async boom!\n at throwError (' + : 'unhandledRejection: Error: async boom!' + + '\n at throwError (webpack-internal:///(middleware)/./middleware.js:8:11)' + + '\n at __WEBPACK_DEFAULT_EXPORT__ (webpack-internal:///(middleware)/./middleware.js:11:5)' ) - // expect(output).not.toContain( - // 'webpack-internal:///(middleware)/./middleware.js' - // ) }) it('does not render the error', async () => { @@ -112,17 +119,37 @@ describe('middleware - development errors', () => { it('logs the error correctly', async () => { await next.fetch('/') - // const output = stripAnsi(next.cliOutput) - await check(() => { - expect(stripAnsi(next.cliOutput)).toMatch( - /middleware.js \(\d+:\d+\) @ eval/ + + await retry(() => { + expect(stripAnsi(next.cliOutput)).toContain('Dynamic Code Evaluation') + }) + // TODO: assert on full, ignore-listed stack + if (isTurbopack) { + // Locally, prefixes the "test is not defined". + // In CI, it prefixes "Dynamic Code Evaluation". + expect(stripAnsi(next.cliOutput)).toContain( + '\n ⚠ middleware.js (3:22) @ __TURBOPACK__default__export__' + + '\n ⨯ middleware.js (4:9) @ eval' ) - expect(stripAnsi(next.cliOutput)).toMatch(/test is not defined/) - return 'success' - }, 'success') - // expect(output).not.toContain( - // 'webpack-internal:///(middleware)/./middleware.js' - // ) + } + expect(stripAnsi(next.cliOutput)).toContain( + isTurbopack + ? '\n ⨯ Error: test is not defined' + + '\n at eval (./middleware.js:4:9)' + + '\n at (./middleware.js:4:9' + : '\n ⨯ Error [ReferenceError]: test is not defined' + + '\n at eval (file://webpack-internal:///(middleware)/./middleware.js)' + + '\n at eval (webpack://_N_E/middleware.js?3bcb:4:8)' + ) + expect(stripAnsi(next.cliOutput)).toContain( + isTurbopack + ? "\n ⚠ Error: Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime" + + '\nLearn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation' + + '\n at __TURBOPACK__default__export__ (./middleware.js:3:22)' + : '\n ⚠ middleware.js (4:9) @ eval' + + "\n ⚠ Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime" + + '\nLearn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation' + ) }) it('renders the error correctly and recovers', async () => { @@ -150,22 +177,18 @@ describe('middleware - development errors', () => { it('logs the error correctly', async () => { await next.fetch('/') - const output = stripAnsi(next.cliOutput) - await check(() => { - if (isTurbopack) { - expect(stripAnsi(next.cliOutput)).toMatch( - /middleware.js \(\d+:\d+\) @ \[project\]\/middleware\.js \[middleware\] \(ecmascript\)/ - ) - } else { - expect(stripAnsi(next.cliOutput)).toMatch( - /middleware.js \(\d+:\d+\) @ / - ) - } - expect(stripAnsi(next.cliOutput)).toMatch(/booooom!/) - return 'success' - }, 'success') - expect(output).not.toContain( - 'webpack-internal:///(middleware)/./middleware.js' + + await retry(() => { + expect(stripAnsi(next.cliOutput)).toContain(`Error: booooom!`) + }) + // TODO: assert on full, ignore-listed stack + expect(stripAnsi(next.cliOutput)).toContain( + isTurbopack + ? '\n ⨯ middleware.js (3:13) @ [project]/middleware.js [middleware] (ecmascript)' + + '\n ⨯ Error: booooom!' + + '\n at ([project]/middleware.js [middleware] (ecmascript) (./middleware.js:3:13)' + : '\n ⨯ Error: booooom!' + + '\n at (webpack://_N_E/middleware.js' ) }) diff --git a/test/e2e/app-dir/server-source-maps/fixtures/default/.gitignore b/test/e2e/app-dir/server-source-maps/fixtures/default/.gitignore new file mode 100644 index 0000000000000..3701fcbec5a9d --- /dev/null +++ b/test/e2e/app-dir/server-source-maps/fixtures/default/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +pnpm-lock.yaml \ No newline at end of file diff --git a/test/e2e/app-dir/server-source-maps/fixtures/default/app/rsc-error-log-ignore-listed/page.js b/test/e2e/app-dir/server-source-maps/fixtures/default/app/rsc-error-log-ignore-listed/page.js new file mode 100644 index 0000000000000..411e279d10f72 --- /dev/null +++ b/test/e2e/app-dir/server-source-maps/fixtures/default/app/rsc-error-log-ignore-listed/page.js @@ -0,0 +1,11 @@ +import { run } from 'internal-pkg' + +function logError() { + const error = new Error('Boom') + console.error(error) +} + +export default function Page() { + run(() => logError()) + return null +} diff --git a/test/e2e/app-dir/server-source-maps/fixtures/default/app/ssr-error-log-ignore-listed/page.js b/test/e2e/app-dir/server-source-maps/fixtures/default/app/ssr-error-log-ignore-listed/page.js new file mode 100644 index 0000000000000..12927684927bf --- /dev/null +++ b/test/e2e/app-dir/server-source-maps/fixtures/default/app/ssr-error-log-ignore-listed/page.js @@ -0,0 +1,12 @@ +'use client' +import { run } from 'internal-pkg' + +function logError() { + const error = new Error('Boom') + console.error(error) +} + +export default function Page() { + run(() => logError()) + return null +} diff --git a/test/e2e/app-dir/server-source-maps/fixtures/default/app/ssr-error-log/page.js b/test/e2e/app-dir/server-source-maps/fixtures/default/app/ssr-error-log/page.js new file mode 100644 index 0000000000000..041613f088e3e --- /dev/null +++ b/test/e2e/app-dir/server-source-maps/fixtures/default/app/ssr-error-log/page.js @@ -0,0 +1,11 @@ +'use client' + +function logError() { + const error = new Error('Boom') + console.error(error) +} + +export default function Page() { + logError() + return null +} diff --git a/test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/index.js b/test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/index.js new file mode 100644 index 0000000000000..e9112647a2ba6 --- /dev/null +++ b/test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/index.js @@ -0,0 +1,3 @@ +export function run(fn) { + return fn() +} diff --git a/test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/package.json b/test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/package.json new file mode 100644 index 0000000000000..77043bd124e18 --- /dev/null +++ b/test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/package.json @@ -0,0 +1,10 @@ +{ + "name": "internal-pkg", + "private": true, + "type": "module", + "exports": { + ".": { + "default": "./index.js" + } + } +} diff --git a/test/e2e/app-dir/server-source-maps/fixtures/default/package.json b/test/e2e/app-dir/server-source-maps/fixtures/default/package.json new file mode 100644 index 0000000000000..77a3e0066f372 --- /dev/null +++ b/test/e2e/app-dir/server-source-maps/fixtures/default/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "internal-pkg": "file:./internal-pkg" + } +} diff --git a/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts b/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts index 4174e83860b43..93b66f9580211 100644 --- a/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts +++ b/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts @@ -1,8 +1,53 @@ +/* eslint-disable jest/no-standalone-expect */ import * as path from 'path' import { nextTestSetup } from 'e2e-utils' +import stripAnsi from 'strip-ansi' +import { retry } from 'next-test-utils' + +/** + * TODO: Remove this function once we log the file name on disk by adjusting `moduleFileNameTemplate`. + * in: webpack:///app/ssr-error-log-ignore-listed/page.js?1234:5:16 + * out: webpack:///app/ssr-error-log-ignore-listed/page.js?[search]:5:16 + */ +function normalizeWebpackLocation(frame: string) { + const webpackQueryStringtMatch = frame.match(/\?\w+:(\d+):(\d+)\)$/) + if (webpackQueryStringtMatch === null) { + return frame + } + + return frame.replace( + webpackQueryStringtMatch[0], + `?[search]:${webpackQueryStringtMatch[1]}:${webpackQueryStringtMatch[2]})` + ) +} + +function normalizeCliOutput(output: string) { + return stripAnsi(output) + .split('\n') + .map((line) => { + return ( + normalizeWebpackLocation(line) + .replaceAll( + path.join(__dirname, 'fixtures/default'), + '[fixture-root]' + ) + // in: webpack://[fixture-root]/node_modules/.pnpm/internal-pkg@file+internal-pkg/node_modules/internal-pkg/index.js?[search]:2:0 + // out: webpack://[fixture-root]/node_modules/[pnpm]/internal-pkg/index.js?[search]:2:0 + .replace(/\/.pnpm\/[^/]+\/node_modules/g, '/[pnpm]') + ) + }) + .join('\n') +} describe('app-dir - server source maps', () => { - const { skipped, next, isNextDev } = nextTestSetup({ + const dependencies = + // 'link:' is not suitable for this test since this makes internal-pkg + // not appear in node_modules. + { + 'internal-pkg': `file:${path.resolve(__dirname, 'fixtures/default/internal-pkg')}`, + } + const { skipped, next, isNextDev, isTurbopack } = nextTestSetup({ + dependencies, files: path.join(__dirname, 'fixtures/default'), // Deploy tests don't have access to runtime logs. // Manually verify that the runtime logs match. @@ -12,13 +57,153 @@ describe('app-dir - server source maps', () => { if (skipped) return it('logged errors have a sourcemapped stack with a codeframe', async () => { - // TODO: Write test once we run with `--enable-source-maps` when `experimental.serverSourceMaps` is set + await next.render('/rsc-error-log') + + if (isNextDev) { + await retry(() => { + expect(normalizeCliOutput(next.cliOutput)).toContain( + isTurbopack + ? '\nError: Boom' + + '\n at logError (turbopack://[project]/app/rsc-error-log/page.js:2:16)' + + '\n at Page (turbopack://[project]/app/rsc-error-log/page.js:7:2)' + + '\n 1 | function logError() {' + + "\n> 2 | const error = new Error('Boom')" + + '\n | ^' + + '\n 3 | console.error(error)' + + '\n 4 | }' + + '\n 5 |' + + '\n' + : '\nError: Boom' + + '\n at logError (webpack:///app/rsc-error-log/page.js?[search]:2:16)' + + // FIXME: Method name should be "Page" + '\n at logError (webpack:///app/rsc-error-log/page.js?[search]:7:2)' + + '\n 1 | function logError() {' + + "\n> 2 | const error = new Error('Boom')" + + '\n | ^' + + '\n 3 | console.error(error)' + + '\n 4 | }' + + '\n 5 |' + + '\n' + ) + }) + } else { + // TODO: Test `next build` with `--enable-source-maps`. + } }) it('logged errors have a sourcemapped `cause`', async () => { - // TODO: Write test once we run with `--enable-source-maps` when `experimental.serverSourceMaps` is set + await next.render('/rsc-error-log-cause') + + if (isNextDev) { + await retry(() => { + expect(normalizeCliOutput(next.cliOutput)).toContain( + isTurbopack + ? '\nError: Boom' + + '\n at logError (turbopack://[project]/app/rsc-error-log-cause/page.js:2:16)' + + '\n at Page (turbopack://[project]/app/rsc-error-log-cause/page.js:8:2)' + + '\n 1 | function logError(cause) {' + + "\n> 2 | const error = new Error('Boom', { cause })" + + '\n | ^' + + '\n 3 | console.error(error)' + + '\n 4 | }' + + '\n 5 | {' + + '\n [cause]: Error: Boom' + + '\n at Page (turbopack://[project]/app/rsc-error-log-cause/page.js:7:16)' + + '\n 5 |' + + '\n 6 | export default function Page() {' + + "\n > 7 | const error = new Error('Boom')" + + '\n | ^' + + '\n 8 | logError(error)' + + '\n 9 | return null' + + '\n 10 | }' + + '\n' + : '\nError: Boom' + + '\n at logError (webpack:///app/rsc-error-log-cause/page.js?[search]:2:16)' + + // FIXME: Method name should be "Page" + '\n at logError (webpack:///app/rsc-error-log-cause/page.js?[search]:8:2)' + + '\n 1 | function logError(cause) {' + + "\n> 2 | const error = new Error('Boom', { cause })" + + '\n | ^' + + '\n 3 | console.error(error)' + + '\n 4 | }' + + '\n 5 | {' + + '\n [cause]: Error: Boom' + + '\n at Page (webpack:///app/rsc-error-log-cause/page.js?[search]:7:16)' + + '\n 5 |' + + '\n 6 | export default function Page() {' + + "\n > 7 | const error = new Error('Boom')" + + '\n | ^' + + '\n 8 | logError(error)' + + '\n 9 | return null' + + '\n 10 | }' + + '\n' + ) + }) + } else { + // TODO: Test `next build` with `--enable-source-maps`. + } }) + // FIXME: Turbopack resolver bug + // FIXME: Turbopack build? bugs taint the whole dev server + ;(isTurbopack ? it.skip : it)( + 'stack frames are not ignore-listed in ssr', + async () => { + await next.render('/ssr-error-log-ignore-listed') + + if (isNextDev) { + await retry(() => { + expect(normalizeCliOutput(next.cliOutput)).toContain( + isTurbopack + ? // FIXME: Turbopack resolver bug + "Module not found: Can't resolve 'internal-pkg'" + : '\nError: Boom' + + '\n at logError (webpack:///app/ssr-error-log-ignore-listed/page.js?[search]:5:16)' + + // FIXME: Method name should be "Page" + '\n at logError (webpack:///app/ssr-error-log-ignore-listed/page.js?[search]:10:12)' + + (process.env.NEXT_TEST_CI + ? '\n at run (webpack:///node_modules/[pnpm]/internal-pkg/index.js?[search]:2:0)' + : '\n at run (webpack://[fixture-root]/node_modules/[pnpm]/internal-pkg/index.js?[search]:2:0)') + + '\n at Page (webpack:///app/ssr-error-log-ignore-listed/page.js?[search]:10:6)' + + '\n 3 |' + ) + }) + } else { + // TODO: Test `next build` with `--enable-source-maps`. + } + } + ) + + // FIXME: Turbopack resolver bug + // FIXME: Turbopack build? bugs taint the whole dev server + ;(isTurbopack ? it.skip : it)( + 'stack frames are not ignore-listed in rsc', + async () => { + await next.render('/rsc-error-log-ignore-listed') + + if (isNextDev) { + await retry(() => { + expect(normalizeCliOutput(next.cliOutput)).toContain( + isTurbopack + ? // FIXME: Turbopack resolver bug + "Module not found: Can't resolve 'internal-pkg'" + : '\nError: Boom' + + '\n at logError (webpack:///app/rsc-error-log-ignore-listed/page.js?[search]:4:16)' + + // FIXME: Method name should be "Page" + '\n at logError (webpack:///app/rsc-error-log-ignore-listed/page.js?[search]:9:12)' + + (process.env.NEXT_TEST_CI + ? '\n at run (webpack:///node_modules/[pnpm]/internal-pkg/index.js?[search]:2:0)' + : '\n at run (webpack://[fixture-root]/node_modules/[pnpm]/internal-pkg/index.js?[search]:2:0)') + + '\n at Page (webpack:///app/rsc-error-log-ignore-listed/page.js?[search]:9:6)' + + '\n 2 |' + ) + }) + } else { + // TODO: Test `next build` with `--enable-source-maps`. + } + } + ) + it('logged errors preserve their name', async () => { await next.render('/rsc-error-log-custom-name')