Skip to content

Commit 99ed5bc

Browse files
committed
Turbopack: Remove automatic serde derives from #[turbo_tasks::value] macro
1 parent b68b533 commit 99ed5bc

File tree

42 files changed

+88
-490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+88
-490
lines changed

Cargo.lock

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

crates/next-core/src/app_structure.rs

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use anyhow::{Context, Result, bail};
44
use bincode::{Decode, Encode};
55
use indexmap::map::{Entry, OccupiedEntry};
66
use rustc_hash::FxHashMap;
7-
use serde::{Deserialize, Serialize};
87
use tracing::Instrument;
98
use turbo_rcstr::{RcStr, rcstr};
109
use turbo_tasks::{
@@ -38,31 +37,18 @@ fn normalize_underscore(string: &str) -> String {
3837
#[turbo_tasks::value]
3938
#[derive(Default, Debug, Clone)]
4039
pub struct AppDirModules {
41-
#[serde(skip_serializing_if = "Option::is_none")]
4240
pub page: Option<FileSystemPath>,
43-
#[serde(skip_serializing_if = "Option::is_none")]
4441
pub layout: Option<FileSystemPath>,
45-
#[serde(skip_serializing_if = "Option::is_none")]
4642
pub error: Option<FileSystemPath>,
47-
#[serde(skip_serializing_if = "Option::is_none")]
4843
pub global_error: Option<FileSystemPath>,
49-
#[serde(skip_serializing_if = "Option::is_none")]
5044
pub global_not_found: Option<FileSystemPath>,
51-
#[serde(skip_serializing_if = "Option::is_none")]
5245
pub loading: Option<FileSystemPath>,
53-
#[serde(skip_serializing_if = "Option::is_none")]
5446
pub template: Option<FileSystemPath>,
55-
#[serde(skip_serializing_if = "Option::is_none")]
5647
pub forbidden: Option<FileSystemPath>,
57-
#[serde(skip_serializing_if = "Option::is_none")]
5848
pub unauthorized: Option<FileSystemPath>,
59-
#[serde(skip_serializing_if = "Option::is_none")]
6049
pub not_found: Option<FileSystemPath>,
61-
#[serde(skip_serializing_if = "Option::is_none")]
6250
pub default: Option<FileSystemPath>,
63-
#[serde(skip_serializing_if = "Option::is_none")]
6451
pub route: Option<FileSystemPath>,
65-
#[serde(skip_serializing_if = "Metadata::is_empty", default)]
6652
pub metadata: Metadata,
6753
}
6854

@@ -87,9 +73,7 @@ impl AppDirModules {
8773
}
8874

8975
/// A single metadata file plus an optional "alt" text file.
90-
#[derive(
91-
Clone, Debug, Serialize, Deserialize, PartialEq, Eq, TraceRawVcs, NonLocalValue, Encode, Decode,
92-
)]
76+
#[derive(Clone, Debug, PartialEq, Eq, TraceRawVcs, NonLocalValue, Encode, Decode)]
9377
pub enum MetadataWithAltItem {
9478
Static {
9579
path: FileSystemPath,
@@ -102,18 +86,7 @@ pub enum MetadataWithAltItem {
10286

10387
/// A single metadata file.
10488
#[derive(
105-
Clone,
106-
Debug,
107-
Hash,
108-
Serialize,
109-
Deserialize,
110-
PartialEq,
111-
Eq,
112-
TaskInput,
113-
TraceRawVcs,
114-
NonLocalValue,
115-
Encode,
116-
Decode,
89+
Clone, Debug, Hash, PartialEq, Eq, TaskInput, TraceRawVcs, NonLocalValue, Encode, Decode,
11790
)]
11891
pub enum MetadataItem {
11992
Static { path: FileSystemPath },
@@ -159,29 +132,12 @@ impl From<MetadataWithAltItem> for MetadataItem {
159132
}
160133

161134
/// Metadata file that can be placed in any segment of the app directory.
162-
#[derive(
163-
Default,
164-
Clone,
165-
Debug,
166-
Serialize,
167-
Deserialize,
168-
PartialEq,
169-
Eq,
170-
TraceRawVcs,
171-
NonLocalValue,
172-
Encode,
173-
Decode,
174-
)]
135+
#[derive(Default, Clone, Debug, PartialEq, Eq, TraceRawVcs, NonLocalValue, Encode, Decode)]
175136
pub struct Metadata {
176-
#[serde(skip_serializing_if = "Vec::is_empty", default)]
177137
pub icon: Vec<MetadataWithAltItem>,
178-
#[serde(skip_serializing_if = "Vec::is_empty", default)]
179138
pub apple: Vec<MetadataWithAltItem>,
180-
#[serde(skip_serializing_if = "Vec::is_empty", default)]
181139
pub twitter: Vec<MetadataWithAltItem>,
182-
#[serde(skip_serializing_if = "Vec::is_empty", default)]
183140
pub open_graph: Vec<MetadataWithAltItem>,
184-
#[serde(skip_serializing_if = "Option::is_none")]
185141
pub sitemap: Option<MetadataItem>,
186142
// The page indicates where the metadata is defined and captured.
187143
// The steps for capturing metadata (get_directory_tree) and constructing
@@ -190,7 +146,6 @@ pub struct Metadata {
190146
// the actual path incorrectly with fillMetadataSegment.
191147
//
192148
// This is only being used for the static metadata files.
193-
#[serde(skip_serializing_if = "Option::is_none")]
194149
pub base_page: Option<AppPage>,
195150
}
196151

@@ -216,11 +171,8 @@ impl Metadata {
216171
#[turbo_tasks::value]
217172
#[derive(Default, Clone, Debug)]
218173
pub struct GlobalMetadata {
219-
#[serde(skip_serializing_if = "Option::is_none")]
220174
pub favicon: Option<MetadataItem>,
221-
#[serde(skip_serializing_if = "Option::is_none")]
222175
pub robots: Option<MetadataItem>,
223-
#[serde(skip_serializing_if = "Option::is_none")]
224176
pub manifest: Option<MetadataItem>,
225177
}
226178

@@ -534,8 +486,6 @@ impl ValueDefault for FileSystemPathVec {
534486
PartialEq,
535487
Eq,
536488
Hash,
537-
Serialize,
538-
Deserialize,
539489
TraceRawVcs,
540490
ValueDebugFormat,
541491
Debug,

crates/next-core/src/next_app/app_page_entry.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ use turbopack_core::{
1515
};
1616
use turbopack_ecmascript::runtime_functions::{TURBOPACK_LOAD, TURBOPACK_REQUIRE};
1717

18-
use super::app_entry::AppEntry;
1918
use crate::{
2019
app_page_loader_tree::{AppPageLoaderTreeModule, GLOBAL_ERROR},
2120
app_structure::AppPageLoaderTree,
22-
next_app::{AppPage, AppPath},
21+
next_app::{AppPage, AppPath, app_entry::AppEntry},
2322
next_config::NextConfig,
2423
next_edge::entry::wrap_edge_entry,
2524
next_server_component::NextServerComponentTransition,

crates/next-core/src/next_config.rs

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl Default for CacheKinds {
7676
}
7777

7878
#[turbo_tasks::value(eq = "manual")]
79-
#[derive(Clone, Debug, Default, PartialEq)]
79+
#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
8080
#[serde(default, rename_all = "camelCase")]
8181
pub struct NextConfig {
8282
// IMPORTANT: all fields should be private and access should be wrapped within a turbo-tasks
@@ -859,16 +859,7 @@ pub enum ModuleIds {
859859
pub struct OptionModuleIds(pub Option<ModuleIds>);
860860

861861
#[derive(
862-
Clone,
863-
Debug,
864-
PartialEq,
865-
Serialize,
866-
Deserialize,
867-
TraceRawVcs,
868-
NonLocalValue,
869-
OperationValue,
870-
Encode,
871-
Decode,
862+
Clone, Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue, OperationValue, Encode, Decode,
872863
)]
873864
#[serde(untagged)]
874865
pub enum MdxRsOptions {
@@ -933,7 +924,6 @@ pub struct OptionalReactCompilerOptions(Option<ResolvedVc<ReactCompilerOptions>>
933924
Debug,
934925
Default,
935926
PartialEq,
936-
Serialize,
937927
Deserialize,
938928
TraceRawVcs,
939929
ValueDebugFormat,
@@ -1275,16 +1265,7 @@ pub enum MiddlewarePrefetchType {
12751265
}
12761266

12771267
#[derive(
1278-
Clone,
1279-
Debug,
1280-
PartialEq,
1281-
Serialize,
1282-
Deserialize,
1283-
TraceRawVcs,
1284-
NonLocalValue,
1285-
OperationValue,
1286-
Encode,
1287-
Decode,
1268+
Clone, Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue, OperationValue, Encode, Decode,
12881269
)]
12891270
#[serde(untagged)]
12901271
pub enum EmotionTransformOptionsOrBoolean {
@@ -1302,16 +1283,7 @@ impl EmotionTransformOptionsOrBoolean {
13021283
}
13031284

13041285
#[derive(
1305-
Clone,
1306-
Debug,
1307-
PartialEq,
1308-
Serialize,
1309-
Deserialize,
1310-
TraceRawVcs,
1311-
NonLocalValue,
1312-
OperationValue,
1313-
Encode,
1314-
Decode,
1286+
Clone, Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue, OperationValue, Encode, Decode,
13151287
)]
13161288
#[serde(untagged)]
13171289
pub enum StyledComponentsTransformOptionsOrBoolean {
@@ -1329,7 +1301,7 @@ impl StyledComponentsTransformOptionsOrBoolean {
13291301
}
13301302

13311303
#[turbo_tasks::value(eq = "manual")]
1332-
#[derive(Clone, Debug, PartialEq, Default, OperationValue)]
1304+
#[derive(Clone, Debug, PartialEq, Default, OperationValue, Deserialize)]
13331305
#[serde(rename_all = "camelCase")]
13341306
pub struct CompilerConfig {
13351307
pub react_remove_properties: Option<ReactRemoveProperties>,
@@ -1340,16 +1312,7 @@ pub struct CompilerConfig {
13401312
}
13411313

13421314
#[derive(
1343-
Clone,
1344-
Debug,
1345-
PartialEq,
1346-
Serialize,
1347-
Deserialize,
1348-
TraceRawVcs,
1349-
NonLocalValue,
1350-
OperationValue,
1351-
Encode,
1352-
Decode,
1315+
Clone, Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue, OperationValue, Encode, Decode,
13531316
)]
13541317
#[serde(untagged, rename_all = "camelCase")]
13551318
pub enum ReactRemoveProperties {
@@ -1367,16 +1330,7 @@ impl ReactRemoveProperties {
13671330
}
13681331

13691332
#[derive(
1370-
Clone,
1371-
Debug,
1372-
PartialEq,
1373-
Serialize,
1374-
Deserialize,
1375-
TraceRawVcs,
1376-
NonLocalValue,
1377-
OperationValue,
1378-
Encode,
1379-
Decode,
1333+
Clone, Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue, OperationValue, Encode, Decode,
13801334
)]
13811335
#[serde(untagged)]
13821336
pub enum RemoveConsoleConfig {

crates/next-core/src/next_font/google/mod.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,25 @@ use turbopack_node::{
3737
execution_context::ExecutionContext,
3838
};
3939

40-
use self::{
41-
font_fallback::get_font_fallback,
42-
options::{FontDataEntry, FontWeights, NextFontGoogleOptions, options_from_request},
43-
stylesheet::build_stylesheet,
44-
util::{get_font_axes, get_stylesheet_url},
45-
};
46-
use super::{
47-
font_fallback::FontFallback,
48-
util::{
49-
FontCssProperties, FontFamilyType, can_use_next_font, get_request_hash, get_request_id,
50-
get_scoped_font_family,
51-
},
52-
};
5340
use crate::{
54-
embed_js::next_js_file_path, mode::NextMode, next_app::metadata::split_extension,
55-
next_font::issue::NextFontIssue, util::load_next_js_json_file,
41+
embed_js::next_js_file_path,
42+
mode::NextMode,
43+
next_app::metadata::split_extension,
44+
next_font::{
45+
font_fallback::FontFallback,
46+
google::{
47+
font_fallback::get_font_fallback,
48+
options::{FontDataEntry, FontWeights, NextFontGoogleOptions, options_from_request},
49+
stylesheet::build_stylesheet,
50+
util::{get_font_axes, get_stylesheet_url},
51+
},
52+
issue::NextFontIssue,
53+
util::{
54+
FontCssProperties, FontFamilyType, can_use_next_font, get_request_hash, get_request_id,
55+
get_scoped_font_family,
56+
},
57+
},
58+
util::load_next_js_json_file,
5659
};
5760

5861
pub mod font_fallback;
@@ -74,6 +77,7 @@ pub const USER_AGENT_FOR_GOOGLE_FONTS: &str = "Mozilla/5.0 (Macintosh; Intel Mac
7477
pub const GOOGLE_FONTS_INTERNAL_PREFIX: &str = "@vercel/turbopack-next/internal/font/google/font";
7578

7679
#[turbo_tasks::value(transparent)]
80+
#[derive(Deserialize)]
7781
struct FontData(#[bincode(with = "turbo_bincode::indexmap")] FxIndexMap<RcStr, FontDataEntry>);
7882

7983
#[turbo_tasks::value(shared)]

crates/next-core/src/next_shared/transforms/relay.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ use turbo_tasks_fs::FileSystemPath;
44
use turbopack::module_options::ModuleRule;
55
use turbopack_ecmascript_plugins::transform::relay::RelayTransformer;
66

7-
use super::get_ecma_transform_rule;
8-
use crate::{next_config::NextConfig, next_shared::transforms::EcmascriptTransformStage};
7+
use crate::{
8+
next_config::NextConfig,
9+
next_shared::transforms::{EcmascriptTransformStage, get_ecma_transform_rule},
10+
};
911

1012
/// Returns a transform rule for the relay graphql transform.
1113
pub async fn get_relay_transform_rule(

0 commit comments

Comments
 (0)