Skip to content

Commit c713be6

Browse files
committed
WIP: Migrate TaskInput serialization to bincode
1 parent 3a3f0d7 commit c713be6

File tree

37 files changed

+597
-499
lines changed

37 files changed

+597
-499
lines changed

Cargo.lock

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/next-api/src/operation.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ fn pick_route(entrypoints: OperationVc<Entrypoints>, key: RcStr, route: &Route)
123123
ValueDebugFormat,
124124
NonLocalValue,
125125
OperationValue,
126+
Encode,
127+
Decode,
126128
)]
127129
enum EndpointSelector {
128130
RoutePageHtml(RcStr),
@@ -150,7 +152,7 @@ async fn pick_endpoint(
150152
op: OperationVc<Entrypoints>,
151153
selector: EndpointSelector,
152154
) -> Result<Vc<OptionEndpoint>> {
153-
let endpoints = op.connect().strongly_consistent().await?;
155+
let endpoints = op.read_strongly_consistent().await?;
154156
let endpoint = match selector {
155157
EndpointSelector::InstrumentationNodeJs => {
156158
endpoints.instrumentation.as_ref().map(|i| i.node_js)

crates/next-api/src/pages.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,18 @@ enum PageEndpointType {
612612
}
613613

614614
#[derive(
615-
Copy, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug, TaskInput, TraceRawVcs,
615+
Copy,
616+
Clone,
617+
Serialize,
618+
Deserialize,
619+
PartialEq,
620+
Eq,
621+
Hash,
622+
Debug,
623+
TaskInput,
624+
TraceRawVcs,
625+
Encode,
626+
Decode,
616627
)]
617628
enum SsrChunkType {
618629
Page,
@@ -621,7 +632,18 @@ enum SsrChunkType {
621632
}
622633

623634
#[derive(
624-
Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, TaskInput, TraceRawVcs,
635+
Copy,
636+
Clone,
637+
Debug,
638+
PartialEq,
639+
Eq,
640+
Hash,
641+
Serialize,
642+
Deserialize,
643+
TaskInput,
644+
TraceRawVcs,
645+
Encode,
646+
Decode,
625647
)]
626648
enum EmitManifests {
627649
/// Don't emit any manifests

crates/next-api/src/project.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,6 @@ pub struct ProjectOptions {
209209
pub current_node_js_version: RcStr,
210210
}
211211

212-
#[derive(
213-
Debug, Serialize, Deserialize, Clone, TaskInput, PartialEq, Eq, Hash, TraceRawVcs, NonLocalValue,
214-
)]
215-
#[serde(rename_all = "camelCase")]
216212
pub struct PartialProjectOptions {
217213
/// A root path from which all files must be nested under. Trying to access
218214
/// a file outside this root will fail. Think of this as a chroot.

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::collections::BTreeSet;
22

33
use anyhow::Result;
4+
use bincode::{Decode, Encode};
45
use serde::{Deserialize, Serialize};
56
use turbo_rcstr::{RcStr, rcstr};
67
use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs};
@@ -34,11 +35,13 @@ use turbopack_node::{
3435
transforms::postcss::{PostCssConfigLocation, PostCssTransformOptions},
3536
};
3637

37-
use super::transforms::get_next_client_transforms_rules;
3838
use crate::{
3939
mode::NextMode,
4040
next_build::get_postcss_package_mapping,
41-
next_client::runtime_entry::{RuntimeEntries, RuntimeEntry},
41+
next_client::{
42+
runtime_entry::{RuntimeEntries, RuntimeEntry},
43+
transforms::get_next_client_transforms_rules,
44+
},
4245
next_config::NextConfig,
4346
next_font::local::NextFontLocalResolvePlugin,
4447
next_import_map::{
@@ -407,7 +410,19 @@ pub async fn get_client_module_options_context(
407410
Ok(module_options_context)
408411
}
409412

410-
#[derive(Clone, Debug, PartialEq, Eq, Hash, TaskInput, TraceRawVcs, Serialize, Deserialize)]
413+
#[derive(
414+
Clone,
415+
Debug,
416+
PartialEq,
417+
Eq,
418+
Hash,
419+
TaskInput,
420+
TraceRawVcs,
421+
Serialize,
422+
Deserialize,
423+
Encode,
424+
Decode,
425+
)]
411426
pub struct ClientChunkingContextOptions {
412427
pub mode: Vc<NextMode>,
413428
pub root_path: FileSystemPath,

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use anyhow::Result;
2+
use bincode::{Decode, Encode};
23
use serde::{Deserialize, Serialize};
34
use turbo_rcstr::{RcStr, rcstr};
45
use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs};
@@ -195,7 +196,19 @@ pub async fn get_edge_resolve_options_context(
195196
.cell())
196197
}
197198

198-
#[derive(Clone, Debug, PartialEq, Eq, Hash, TaskInput, TraceRawVcs, Serialize, Deserialize)]
199+
#[derive(
200+
Clone,
201+
Debug,
202+
PartialEq,
203+
Eq,
204+
Hash,
205+
TaskInput,
206+
TraceRawVcs,
207+
Serialize,
208+
Deserialize,
209+
Encode,
210+
Decode,
211+
)]
199212
pub struct EdgeChunkingContextOptions {
200213
pub mode: Vc<NextMode>,
201214
pub root_path: FileSystemPath,

crates/next-core/src/next_root_params/mod.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use either::Either;
55
use indoc::formatdoc;
66
use itertools::Itertools;
77
use turbo_rcstr::RcStr;
8-
use turbo_tasks::{ResolvedVc, Vc};
8+
use turbo_tasks::{EitherTaskInput, ResolvedVc, Vc};
99
use turbo_tasks_fs::{FileContent, FileSystemPath};
1010
use turbopack_core::{
1111
asset::AssetContent,
@@ -36,17 +36,21 @@ pub async fn insert_next_root_params_mapping(
3636
) -> Result<()> {
3737
import_map.insert_exact_alias(
3838
"next/root-params",
39-
get_next_root_params_mapping(is_root_params_enabled, ty, collected_root_params)
40-
.to_resolved()
41-
.await?,
39+
get_next_root_params_mapping(
40+
is_root_params_enabled,
41+
EitherTaskInput(ty),
42+
collected_root_params,
43+
)
44+
.to_resolved()
45+
.await?,
4246
);
4347
Ok(())
4448
}
4549

4650
#[turbo_tasks::function]
4751
async fn get_next_root_params_mapping(
4852
is_root_params_enabled: Vc<bool>,
49-
ty: Either<ServerContextType, ClientContextType>,
53+
ty: EitherTaskInput<ServerContextType, ClientContextType>,
5054
collected_root_params: Option<Vc<CollectedRootParams>>,
5155
) -> Result<Vc<ImportMapping>> {
5256
// This mapping goes into the global resolve options, so we want to avoid invalidating it if
@@ -77,12 +81,12 @@ impl NextRootParamsMapper {
7781
#[turbo_tasks::function]
7882
pub fn new(
7983
is_root_params_enabled: ResolvedVc<bool>,
80-
context_type: Either<ServerContextType, ClientContextType>,
84+
context_type: EitherTaskInput<ServerContextType, ClientContextType>,
8185
collected_root_params: Option<ResolvedVc<CollectedRootParams>>,
8286
) -> Vc<Self> {
8387
NextRootParamsMapper {
8488
is_root_params_enabled,
85-
context_type,
89+
context_type: context_type.0,
8690
collected_root_params,
8791
}
8892
.cell()

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::collections::BTreeSet;
22

33
use anyhow::{Result, bail};
4+
use bincode::{Decode, Encode};
45
use serde::{Deserialize, Serialize};
56
use turbo_rcstr::{RcStr, rcstr};
67
use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs};
@@ -38,18 +39,17 @@ use turbopack_node::{
3839
};
3940
use turbopack_nodejs::NodeJsChunkingContext;
4041

41-
use super::{
42-
resolve::ExternalCjsModulesResolvePlugin,
43-
transforms::{get_next_server_internal_transforms_rules, get_next_server_transforms_rules},
44-
};
4542
use crate::{
4643
app_structure::CollectedRootParams,
4744
mode::NextMode,
4845
next_build::get_postcss_package_mapping,
4946
next_config::NextConfig,
5047
next_font::local::NextFontLocalResolvePlugin,
5148
next_import_map::{get_next_edge_and_server_fallback_import_map, get_next_server_import_map},
52-
next_server::resolve::ExternalPredicate,
49+
next_server::{
50+
resolve::{ExternalCjsModulesResolvePlugin, ExternalPredicate},
51+
transforms::{get_next_server_internal_transforms_rules, get_next_server_transforms_rules},
52+
},
5353
next_shared::{
5454
resolve::{
5555
ModuleFeatureReportResolvePlugin, NextExternalResolvePlugin,
@@ -981,7 +981,19 @@ pub async fn get_server_module_options_context(
981981
Ok(module_options_context)
982982
}
983983

984-
#[derive(Clone, Debug, PartialEq, Eq, Hash, TaskInput, TraceRawVcs, Serialize, Deserialize)]
984+
#[derive(
985+
Clone,
986+
Debug,
987+
PartialEq,
988+
Eq,
989+
Hash,
990+
TaskInput,
991+
TraceRawVcs,
992+
Serialize,
993+
Deserialize,
994+
Encode,
995+
Decode,
996+
)]
985997
pub struct ServerChunkingContextOptions {
986998
pub mode: Vc<NextMode>,
987999
pub root_path: FileSystemPath,

crates/next-core/src/util.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,18 @@ pub fn defines(define_env: &FxIndexMap<RcStr, Option<RcStr>>) -> CompileTimeDefi
6161
}
6262

6363
#[derive(
64-
Debug, Clone, Copy, PartialEq, Eq, Hash, TaskInput, Serialize, Deserialize, TraceRawVcs,
64+
Debug,
65+
Clone,
66+
Copy,
67+
PartialEq,
68+
Eq,
69+
Hash,
70+
TaskInput,
71+
Serialize,
72+
Deserialize,
73+
TraceRawVcs,
74+
Encode,
75+
Decode,
6576
)]
6677
pub enum PathType {
6778
PagesPage,

turbopack/crates/turbo-bincode/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ ringmap = { workspace = true }
1919
serde = { workspace = true }
2020
serde_json = { workspace = true }
2121
smallvec = { workspace = true }
22+
unty = { workspace = true }

0 commit comments

Comments
 (0)