Skip to content

Commit

Permalink
perf(turbopack): Use ResolvedVc for next-api, part 2 (#73235)
Browse files Browse the repository at this point in the history
### What?

Use `ResolvedVc<T>` instead of `Vc<T>` for struct fields in `next-api`, but split into multiple PRs.

### Why?

To reduce scope of changes of each PRs so I can debug HMR failures.

### How?
  • Loading branch information
kdy1 authored Nov 27, 2024
1 parent a168d74 commit ad8a47a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
19 changes: 8 additions & 11 deletions crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ pub fn app_entry_point_to_route(
AppEndpoint {
ty: AppEndpointType::Page {
ty: AppPageEndpointType::Html,
loader_tree: *loader_tree,
loader_tree,
},
app_project,
page: page.clone(),
Expand All @@ -689,7 +689,7 @@ pub fn app_entry_point_to_route(
AppEndpoint {
ty: AppEndpointType::Page {
ty: AppPageEndpointType::Rsc,
loader_tree: *loader_tree,
loader_tree,
},
app_project,
page,
Expand All @@ -707,10 +707,7 @@ pub fn app_entry_point_to_route(
original_name: page.to_string(),
endpoint: Vc::upcast(
AppEndpoint {
ty: AppEndpointType::Route {
path: *path,
root_layouts: *root_layouts,
},
ty: AppEndpointType::Route { path, root_layouts },
app_project,
page,
}
Expand Down Expand Up @@ -755,11 +752,11 @@ enum AppPageEndpointType {
enum AppEndpointType {
Page {
ty: AppPageEndpointType,
loader_tree: Vc<AppPageLoaderTree>,
loader_tree: ResolvedVc<AppPageLoaderTree>,
},
Route {
path: Vc<FileSystemPath>,
root_layouts: Vc<FileSystemPathVec>,
path: ResolvedVc<FileSystemPath>,
root_layouts: ResolvedVc<FileSystemPathVec>,
},
Metadata {
metadata: MetadataItem,
Expand Down Expand Up @@ -843,9 +840,9 @@ impl AppEndpoint {

let next_config = self.await?.app_project.project().next_config();
let app_entry = match this.ty {
AppEndpointType::Page { loader_tree, .. } => self.app_page_entry(loader_tree),
AppEndpointType::Page { loader_tree, .. } => self.app_page_entry(*loader_tree),
AppEndpointType::Route { path, root_layouts } => {
self.app_route_entry(path, root_layouts, next_config)
self.app_route_entry(*path, *root_layouts, next_config)
}
AppEndpointType::Metadata { metadata } => {
self.app_metadata_entry(metadata, next_config)
Expand Down
10 changes: 6 additions & 4 deletions crates/next-api/src/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct InstrumentationEndpoint {
is_edge: bool,

app_dir: Option<ResolvedVc<FileSystemPath>>,
ecmascript_client_reference_transition_name: Option<Vc<RcStr>>,
ecmascript_client_reference_transition_name: Option<ResolvedVc<RcStr>>,
}

#[turbo_tasks::value_impl]
Expand All @@ -53,7 +53,7 @@ impl InstrumentationEndpoint {
source: ResolvedVc<Box<dyn Source>>,
is_edge: bool,
app_dir: Option<ResolvedVc<FileSystemPath>>,
ecmascript_client_reference_transition_name: Option<Vc<RcStr>>,
ecmascript_client_reference_transition_name: Option<ResolvedVc<RcStr>>,
) -> Vc<Self> {
Self {
project,
Expand Down Expand Up @@ -113,7 +113,8 @@ impl InstrumentationEndpoint {
Value::new(ServerContextType::Instrumentation {
app_dir: this.app_dir,
ecmascript_client_reference_transition_name: this
.ecmascript_client_reference_transition_name,
.ecmascript_client_reference_transition_name
.map(|v| *v),
}),
this.project.next_mode(),
)
Expand Down Expand Up @@ -165,7 +166,8 @@ impl InstrumentationEndpoint {
Value::new(ServerContextType::Instrumentation {
app_dir: this.app_dir,
ecmascript_client_reference_transition_name: this
.ecmascript_client_reference_transition_name,
.ecmascript_client_reference_transition_name
.map(|v| *v),
}),
this.project.next_mode(),
)
Expand Down

0 comments on commit ad8a47a

Please sign in to comment.