Skip to content

Commit 7f743ae

Browse files
committed
Remove RuntimeEntries this is a complicated and expensive way to pass around an empty vec
1 parent cc00206 commit 7f743ae

File tree

5 files changed

+13
-165
lines changed

5 files changed

+13
-165
lines changed

crates/next-api/src/app.rs

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use next_core::{
1212
get_app_page_entry, get_app_route_entry, metadata::route::get_app_metadata_route_entry,
1313
},
1414
next_client::{
15-
ClientContextType, RuntimeEntries, get_client_module_options_context,
16-
get_client_resolve_options_context, get_client_runtime_entries,
15+
ClientContextType, get_client_module_options_context, get_client_resolve_options_context,
16+
get_client_runtime_entries,
1717
},
1818
next_client_reference::{
1919
ClientReferenceGraphResult, NextCssClientReferenceTransition,
@@ -29,7 +29,6 @@ use next_core::{
2929
},
3030
next_server::{
3131
ServerContextType, get_server_module_options_context, get_server_resolve_options_context,
32-
get_server_runtime_entries,
3332
},
3433
next_server_utility::{NEXT_SERVER_UTILITY_MERGE_TAG, NextServerUtilityTransition},
3534
parse_segment_config_from_source,
@@ -778,26 +777,6 @@ impl AppProject {
778777
))
779778
}
780779

781-
#[turbo_tasks::function]
782-
async fn runtime_entries(self: Vc<Self>) -> Result<Vc<RuntimeEntries>> {
783-
Ok(get_server_runtime_entries(
784-
self.rsc_ty().owned().await?,
785-
self.project().next_mode(),
786-
))
787-
}
788-
789-
#[turbo_tasks::function]
790-
fn rsc_runtime_entries(self: Vc<Self>) -> Vc<EvaluatableAssets> {
791-
self.runtime_entries()
792-
.resolve_entries(Vc::upcast(self.rsc_module_context()))
793-
}
794-
795-
#[turbo_tasks::function]
796-
fn edge_rsc_runtime_entries(self: Vc<Self>) -> Vc<EvaluatableAssets> {
797-
self.runtime_entries()
798-
.resolve_entries(Vc::upcast(self.edge_rsc_module_context()))
799-
}
800-
801780
#[turbo_tasks::function]
802781
fn client_env(self: Vc<Self>) -> Vc<Box<dyn ProcessEnv>> {
803782
Vc::upcast(CustomProcessEnv::new(
@@ -1780,17 +1759,11 @@ impl AppEndpoint {
17801759
)
17811760
.await?;
17821761

1783-
let edge_rsc_runtime_entries = this.app_project.edge_rsc_runtime_entries().await?;
1784-
let evaluatable_assets = edge_rsc_runtime_entries
1785-
.iter()
1786-
.map(|m| ResolvedVc::upcast(*m))
1787-
.chain(std::iter::once(app_entry.rsc_entry));
1788-
17891762
assets.concatenate(
17901763
chunking_context
17911764
.evaluated_chunk_group_assets(
17921765
app_entry.rsc_entry.ident(),
1793-
ChunkGroup::Entry(evaluatable_assets.collect()),
1766+
ChunkGroup::Entry(vec![app_entry.rsc_entry]),
17941767
module_graph,
17951768
availability_info,
17961769
)
@@ -1799,13 +1772,11 @@ impl AppEndpoint {
17991772
)
18001773
}
18011774
NextRuntime::NodeJs => {
1802-
let mut evaluatable_assets = this.app_project.rsc_runtime_entries().owned().await?;
1803-
18041775
let Some(rsc_entry) = ResolvedVc::try_downcast(app_entry.rsc_entry) else {
18051776
bail!("rsc_entry must be evaluatable");
18061777
};
18071778

1808-
evaluatable_assets.push(rsc_entry);
1779+
let evaluatable_assets = Vc::cell(vec![rsc_entry]);
18091780

18101781
async {
18111782
let mut current_chunks = OutputAssets::empty();
@@ -1909,7 +1880,7 @@ impl AppEndpoint {
19091880
"app{original_name}.js",
19101881
original_name = app_entry.original_name
19111882
))?,
1912-
Vc::cell(evaluatable_assets),
1883+
evaluatable_assets,
19131884
module_graph,
19141885
current_chunks,
19151886
current_availability_info,

crates/next-api/src/instrumentation.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use next_core::{
33
all_assets_from_entries,
44
next_edge::entry::wrap_edge_entry,
55
next_manifests::{InstrumentationDefinition, MiddlewaresManifestV2},
6-
next_server::{ServerContextType, get_server_runtime_entries},
76
};
87
use tracing::Instrument;
98
use turbo_rcstr::{RcStr, rcstr};
@@ -104,26 +103,10 @@ impl InstrumentationEndpoint {
104103

105104
let module_graph = this.project.module_graph(*module);
106105

107-
let evaluatable_assets = get_server_runtime_entries(
108-
ServerContextType::Instrumentation {
109-
app_dir: this.app_dir.clone(),
110-
ecmascript_client_reference_transition_name: this
111-
.ecmascript_client_reference_transition_name
112-
.clone(),
113-
},
114-
this.project.next_mode(),
115-
)
116-
.resolve_entries(*this.asset_context)
117-
.await?
118-
.iter()
119-
.map(|m| ResolvedVc::upcast(*m))
120-
.chain(std::iter::once(module))
121-
.collect();
122-
123106
let edge_chunking_context = this.project.edge_chunking_context(false);
124107
let edge_files: Vc<OutputAssets> = edge_chunking_context.evaluated_chunk_group_assets(
125108
module.ident(),
126-
ChunkGroup::Entry(evaluatable_assets),
109+
ChunkGroup::Entry(vec![module]),
127110
module_graph,
128111
AvailabilityInfo::Root,
129112
);
@@ -150,17 +133,7 @@ impl InstrumentationEndpoint {
150133
.node_root()
151134
.await?
152135
.join("server/instrumentation.js")?,
153-
get_server_runtime_entries(
154-
ServerContextType::Instrumentation {
155-
app_dir: this.app_dir.clone(),
156-
ecmascript_client_reference_transition_name: this
157-
.ecmascript_client_reference_transition_name
158-
.clone(),
159-
},
160-
this.project.next_mode(),
161-
)
162-
.resolve_entries(*this.asset_context)
163-
.with_entry(*module),
136+
Vc::cell(vec![module]),
164137
module_graph,
165138
OutputAssets::empty(),
166139
AvailabilityInfo::Root,

crates/next-api/src/middleware.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use next_core::{
66
middleware::get_middleware_module,
77
next_edge::entry::wrap_edge_entry,
88
next_manifests::{EdgeFunctionDefinition, MiddlewareMatcher, MiddlewaresManifestV2, Regions},
9-
next_server::{ServerContextType, get_server_runtime_entries},
109
parse_segment_config_from_source,
1110
segment_config::ParseSegmentMode,
1211
util::{MiddlewareMatcherKind, NextRuntime},
@@ -111,26 +110,10 @@ impl MiddlewareEndpoint {
111110

112111
let module_graph = this.project.module_graph(*module);
113112

114-
let evaluatable_assets = get_server_runtime_entries(
115-
ServerContextType::Middleware {
116-
app_dir: this.app_dir.clone(),
117-
ecmascript_client_reference_transition_name: this
118-
.ecmascript_client_reference_transition_name
119-
.clone(),
120-
},
121-
this.project.next_mode(),
122-
)
123-
.resolve_entries(*this.asset_context)
124-
.await?
125-
.iter()
126-
.map(|m| ResolvedVc::upcast(*m))
127-
.chain(std::iter::once(module))
128-
.collect();
129-
130113
let edge_chunking_context = this.project.edge_chunking_context(false);
131114
let edge_files = edge_chunking_context.evaluated_chunk_group_assets(
132115
module.ident(),
133-
ChunkGroup::Entry(evaluatable_assets),
116+
ChunkGroup::Entry(vec![module]),
134117
module_graph,
135118
AvailabilityInfo::Root,
136119
);
@@ -156,17 +139,7 @@ impl MiddlewareEndpoint {
156139
.node_root()
157140
.await?
158141
.join("server/middleware.js")?,
159-
get_server_runtime_entries(
160-
ServerContextType::Middleware {
161-
app_dir: this.app_dir.clone(),
162-
ecmascript_client_reference_transition_name: this
163-
.ecmascript_client_reference_transition_name
164-
.clone(),
165-
},
166-
this.project.next_mode(),
167-
)
168-
.resolve_entries(*this.asset_context)
169-
.with_entry(*module),
142+
Vc::cell(vec![module]),
170143
module_graph,
171144
OutputAssets::empty(),
172145
AvailabilityInfo::Root,

crates/next-api/src/pages.rs

Lines changed: 4 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use next_core::{
66
hmr_entry::HmrEntryModule,
77
mode::NextMode,
88
next_client::{
9-
ClientContextType, RuntimeEntries, get_client_module_options_context,
10-
get_client_resolve_options_context, get_client_runtime_entries,
9+
ClientContextType, get_client_module_options_context, get_client_resolve_options_context,
10+
get_client_runtime_entries,
1111
},
1212
next_dynamic::NextDynamicTransition,
1313
next_edge::route_regex::get_named_middleware_regex,
@@ -18,7 +18,6 @@ use next_core::{
1818
next_pages::create_page_ssr_entry_module,
1919
next_server::{
2020
ServerContextType, get_server_module_options_context, get_server_resolve_options_context,
21-
get_server_runtime_entries,
2221
},
2322
pages_structure::{
2423
PagesDirectoryStructure, PagesStructure, PagesStructureItem, find_pages_structure,
@@ -599,50 +598,6 @@ impl PagesProject {
599598
Ok(client_runtime_entries.resolve_entries(Vc::upcast(self.client_module_context())))
600599
}
601600

602-
#[turbo_tasks::function]
603-
async fn runtime_entries(self: Vc<Self>) -> Result<Vc<RuntimeEntries>> {
604-
Ok(get_server_runtime_entries(
605-
ServerContextType::Pages {
606-
pages_dir: self.pages_dir().owned().await?,
607-
},
608-
self.project().next_mode(),
609-
))
610-
}
611-
612-
#[turbo_tasks::function]
613-
async fn data_runtime_entries(self: Vc<Self>) -> Result<Vc<RuntimeEntries>> {
614-
Ok(get_server_runtime_entries(
615-
ServerContextType::PagesData {
616-
pages_dir: self.pages_dir().owned().await?,
617-
},
618-
self.project().next_mode(),
619-
))
620-
}
621-
622-
#[turbo_tasks::function]
623-
fn ssr_runtime_entries(self: Vc<Self>) -> Vc<EvaluatableAssets> {
624-
let ssr_runtime_entries = self.runtime_entries();
625-
ssr_runtime_entries.resolve_entries(Vc::upcast(self.ssr_module_context()))
626-
}
627-
628-
#[turbo_tasks::function]
629-
fn ssr_data_runtime_entries(self: Vc<Self>) -> Vc<EvaluatableAssets> {
630-
let ssr_data_runtime_entries = self.data_runtime_entries();
631-
ssr_data_runtime_entries.resolve_entries(Vc::upcast(self.ssr_module_context()))
632-
}
633-
634-
#[turbo_tasks::function]
635-
fn edge_ssr_runtime_entries(self: Vc<Self>) -> Vc<EvaluatableAssets> {
636-
let ssr_runtime_entries = self.runtime_entries();
637-
ssr_runtime_entries.resolve_entries(Vc::upcast(self.edge_ssr_module_context()))
638-
}
639-
640-
#[turbo_tasks::function]
641-
fn edge_ssr_data_runtime_entries(self: Vc<Self>) -> Vc<EvaluatableAssets> {
642-
let ssr_data_runtime_entries = self.data_runtime_entries();
643-
ssr_data_runtime_entries.resolve_entries(Vc::upcast(self.edge_ssr_module_context()))
644-
}
645-
646601
#[turbo_tasks::function]
647602
pub async fn client_main_module(self: Vc<Self>) -> Result<Vc<Box<dyn Module>>> {
648603
let client_module_context = Vc::upcast(self.client_module_context());
@@ -1008,8 +963,6 @@ impl PageEndpoint {
1008963
node_path: FileSystemPath,
1009964
node_chunking_context: Vc<NodeJsChunkingContext>,
1010965
edge_chunking_context: Vc<Box<dyn ChunkingContext>>,
1011-
runtime_entries: Vc<EvaluatableAssets>,
1012-
edge_runtime_entries: Vc<EvaluatableAssets>,
1013966
) -> Result<Vc<SsrChunk>> {
1014967
async move {
1015968
let this = self.await?;
@@ -1126,15 +1079,9 @@ impl PageEndpoint {
11261079
.context("could not process page loader entry module")?;
11271080
let is_edge = matches!(runtime, NextRuntime::Edge);
11281081
if is_edge {
1129-
let edge_runtime_entries = edge_runtime_entries.await?;
1130-
let evaluatable_assets = edge_runtime_entries
1131-
.iter()
1132-
.map(|m| ResolvedVc::upcast(*m))
1133-
.chain(std::iter::once(ResolvedVc::upcast(ssr_module_evaluatable)));
1134-
11351082
let edge_files = edge_chunking_context.evaluated_chunk_group_assets(
11361083
ssr_module.ident(),
1137-
ChunkGroup::Entry(evaluatable_assets.collect()),
1084+
ChunkGroup::Entry(vec![ResolvedVc::upcast(ssr_module_evaluatable)]),
11381085
ssr_module_graph,
11391086
current_availability_info,
11401087
);
@@ -1155,7 +1102,7 @@ impl PageEndpoint {
11551102
let ssr_entry_chunk = node_chunking_context
11561103
.entry_chunk_group_asset(
11571104
ssr_entry_chunk_path,
1158-
runtime_entries.with_entry(*ssr_module_evaluatable),
1105+
EvaluatableAssets::empty().with_entry(*ssr_module_evaluatable),
11591106
ssr_module_graph,
11601107
current_chunks,
11611108
current_availability_info,
@@ -1224,8 +1171,6 @@ impl PageEndpoint {
12241171
.join("server")?,
12251172
project.server_chunking_context(true),
12261173
project.edge_chunking_context(true),
1227-
this.pages_project.ssr_runtime_entries(),
1228-
this.pages_project.edge_ssr_runtime_entries(),
12291174
))
12301175
}
12311176

@@ -1242,8 +1187,6 @@ impl PageEndpoint {
12421187
.join("server/data")?,
12431188
this.pages_project.project().server_chunking_context(true),
12441189
this.pages_project.project().edge_chunking_context(true),
1245-
this.pages_project.ssr_data_runtime_entries(),
1246-
this.pages_project.edge_ssr_data_runtime_entries(),
12471190
))
12481191
}
12491192

@@ -1260,8 +1203,6 @@ impl PageEndpoint {
12601203
.join("server")?,
12611204
this.pages_project.project().server_chunking_context(false),
12621205
this.pages_project.project().edge_chunking_context(false),
1263-
this.pages_project.ssr_runtime_entries(),
1264-
this.pages_project.edge_ssr_runtime_entries(),
12651206
))
12661207
}
12671208

crates/next-core/src/next_server/context.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use crate::{
4646
app_structure::CollectedRootParams,
4747
mode::NextMode,
4848
next_build::get_postcss_package_mapping,
49-
next_client::RuntimeEntries,
5049
next_config::NextConfig,
5150
next_font::local::NextFontLocalResolvePlugin,
5251
next_import_map::{get_next_edge_and_server_fallback_import_map, get_next_server_import_map},
@@ -1009,15 +1008,6 @@ pub async fn get_server_module_options_context(
10091008
Ok(module_options_context)
10101009
}
10111010

1012-
#[turbo_tasks::function]
1013-
pub fn get_server_runtime_entries(
1014-
_ty: ServerContextType,
1015-
_mode: Vc<NextMode>,
1016-
) -> Vc<RuntimeEntries> {
1017-
let runtime_entries = vec![];
1018-
Vc::cell(runtime_entries)
1019-
}
1020-
10211011
#[derive(Clone, Debug, PartialEq, Eq, Hash, TaskInput, TraceRawVcs, Serialize, Deserialize)]
10221012
pub struct ServerChunkingContextOptions {
10231013
pub mode: Vc<NextMode>,

0 commit comments

Comments
 (0)