Unverified Commit ae0603c4 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

Turbopack: bincode: Remove automatic serde derives from `#[turbo_tasks::value]` macro (#86634)

Removing the automatic `serde` derives from `#[turbo_tasks::value]` should remove most of the macro expansion. I'll follow up with removing all the manual derives.

This also removes `Serialize` from `NextConfig`, leaving only `Deserialize`. The `Serialization` derive is no longer needed after some of @mischnic's fixes to edge templates.

Because this is trivially-eliminated dead code, there should be no user-facing benefit from removing this code, but there should be some improvements to our own workflows.

## Build Time: `cargo build -p next-swc-napi`

This gives a ~2% improvement to cold cargo build times with the debug profile.

```
$ hyperfine -w 1 -r 10 -p 'git co 3bb0bcbf && cargo clean' -p 'git co bgw/rm-value-serde && cargo clean' 'cargo build -p next-swc-napi' 'cargo build -p next-swc-napi'
Benchmark 1: cargo build -p next-swc-napi
  Time (mean ± σ):     226.424 s ±  2.819 s    [User: 1943.869 s, System: 85.058 s]
  Range (min … max):   222.736 s … 232.369 s    10 runs

Benchmark 2: cargo build -p next-swc-napi
  Time (mean ± σ):     220.957 s ±  6.535 s    [User: 1940.188 s, System: 87.074 s]
  Range (min … max):   213.891 s … 231.464 s    10 runs

Summary
  cargo build -p next-swc-napi ran
    1.02 ± 0.03 times faster than cargo build -p next-swc-napi
```

This is in addition to the ~2% improvement observed in https://github.com/vercel/next.js/pull/86631

**Percentage improvements to incremental build times are likely greater than shown here**, as cold builds include all of our dependencies, which are not touched by this PR.
parent b26b2b71
...@@ -9879,7 +9879,6 @@ dependencies = [ ...@@ -9879,7 +9879,6 @@ dependencies = [
"regex", "regex",
"rustc-hash 2.1.1", "rustc-hash 2.1.1",
"serde", "serde",
"serde_with",
"turbo-bincode", "turbo-bincode",
"turbo-rcstr", "turbo-rcstr",
"turbo-tasks", "turbo-tasks",
...@@ -9907,6 +9906,7 @@ dependencies = [ ...@@ -9907,6 +9906,7 @@ dependencies = [
"anyhow", "anyhow",
"markdown", "markdown",
"mdxjs", "mdxjs",
"serde",
"turbo-rcstr", "turbo-rcstr",
"turbo-tasks", "turbo-tasks",
"turbo-tasks-fs", "turbo-tasks-fs",
......
...@@ -34,7 +34,6 @@ use next_core::{ ...@@ -34,7 +34,6 @@ use next_core::{
segment_config::{NextSegmentConfig, ParseSegmentMode}, segment_config::{NextSegmentConfig, ParseSegmentMode},
util::{NextRuntime, app_function_name, module_styles_rule_condition, styles_rule_condition}, util::{NextRuntime, app_function_name, module_styles_rule_condition, styles_rule_condition},
}; };
use serde::{Deserialize, Serialize};
use tracing::Instrument; use tracing::Instrument;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ use turbo_tasks::{
...@@ -1069,27 +1068,13 @@ pub fn app_entry_point_to_route( ...@@ -1069,27 +1068,13 @@ pub fn app_entry_point_to_route(
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
struct OutputAssetsWithAvailability((ResolvedVc<OutputAssets>, AvailabilityInfo)); struct OutputAssetsWithAvailability((ResolvedVc<OutputAssets>, AvailabilityInfo));
#[derive( #[derive(Copy, Clone, PartialEq, Eq, Debug, TraceRawVcs, NonLocalValue, Encode, Decode)]
Copy,
Clone,
Serialize,
Deserialize,
PartialEq,
Eq,
Debug,
TraceRawVcs,
NonLocalValue,
Encode,
Decode,
)]
enum AppPageEndpointType { enum AppPageEndpointType {
Html, Html,
Rsc, Rsc,
} }
#[derive( #[derive(Clone, PartialEq, Eq, Debug, TraceRawVcs, NonLocalValue, Encode, Decode)]
Clone, Serialize, Deserialize, PartialEq, Eq, Debug, TraceRawVcs, NonLocalValue, Encode, Decode,
)]
enum AppEndpointType { enum AppEndpointType {
Page { Page {
ty: AppPageEndpointType, ty: AppPageEndpointType,
......
...@@ -2,7 +2,6 @@ use anyhow::{Result, bail}; ...@@ -2,7 +2,6 @@ use anyhow::{Result, bail};
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use next_core::emit_assets; use next_core::emit_assets;
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
use serde::{Deserialize, Serialize};
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{ use turbo_tasks::{
FxIndexSet, NonLocalValue, OperationValue, OperationVc, ResolvedVc, State, TryFlatJoinIterExt, FxIndexSet, NonLocalValue, OperationValue, OperationVc, ResolvedVc, State, TryFlatJoinIterExt,
...@@ -17,17 +16,7 @@ use turbopack_core::{ ...@@ -17,17 +16,7 @@ use turbopack_core::{
}; };
#[derive( #[derive(
Clone, Clone, TraceRawVcs, PartialEq, Eq, ValueDebugFormat, Debug, NonLocalValue, Encode, Decode,
TraceRawVcs,
PartialEq,
Eq,
ValueDebugFormat,
Serialize,
Deserialize,
Debug,
NonLocalValue,
Encode,
Decode,
)] )]
struct MapEntry { struct MapEntry {
assets_operation: OperationVc<ExpandedOutputAssets>, assets_operation: OperationVc<ExpandedOutputAssets>,
...@@ -42,17 +31,7 @@ unsafe impl OperationValue for MapEntry {} ...@@ -42,17 +31,7 @@ unsafe impl OperationValue for MapEntry {}
struct OptionMapEntry(Option<MapEntry>); struct OptionMapEntry(Option<MapEntry>);
#[derive( #[derive(
Clone, Clone, TraceRawVcs, PartialEq, Eq, ValueDebugFormat, Debug, NonLocalValue, Encode, Decode,
TraceRawVcs,
PartialEq,
Eq,
ValueDebugFormat,
Serialize,
Deserialize,
Debug,
NonLocalValue,
Encode,
Decode,
)] )]
pub struct PathToOutputOperation( pub struct PathToOutputOperation(
/// We need to use an operation for outputs as it's stored for later usage and we want to /// We need to use an operation for outputs as it's stored for later usage and we want to
...@@ -71,8 +50,6 @@ pub struct PathToOutputOperation( ...@@ -71,8 +50,6 @@ pub struct PathToOutputOperation(
PartialEq, PartialEq,
Eq, Eq,
ValueDebugFormat, ValueDebugFormat,
Serialize,
Deserialize,
Debug, Debug,
NonLocalValue, NonLocalValue,
Encode, Encode,
......
...@@ -4,7 +4,6 @@ use anyhow::{Context, Result, bail}; ...@@ -4,7 +4,6 @@ use anyhow::{Context, Result, bail};
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use indexmap::map::{Entry, OccupiedEntry}; use indexmap::map::{Entry, OccupiedEntry};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};
use tracing::Instrument; use tracing::Instrument;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ use turbo_tasks::{
...@@ -38,31 +37,18 @@ fn normalize_underscore(string: &str) -> String { ...@@ -38,31 +37,18 @@ fn normalize_underscore(string: &str) -> String {
#[turbo_tasks::value] #[turbo_tasks::value]
#[derive(Default, Debug, Clone)] #[derive(Default, Debug, Clone)]
pub struct AppDirModules { pub struct AppDirModules {
#[serde(skip_serializing_if = "Option::is_none")]
pub page: Option<FileSystemPath>, pub page: Option<FileSystemPath>,
#[serde(skip_serializing_if = "Option::is_none")]
pub layout: Option<FileSystemPath>, pub layout: Option<FileSystemPath>,
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<FileSystemPath>, pub error: Option<FileSystemPath>,
#[serde(skip_serializing_if = "Option::is_none")]
pub global_error: Option<FileSystemPath>, pub global_error: Option<FileSystemPath>,
#[serde(skip_serializing_if = "Option::is_none")]
pub global_not_found: Option<FileSystemPath>, pub global_not_found: Option<FileSystemPath>,
#[serde(skip_serializing_if = "Option::is_none")]
pub loading: Option<FileSystemPath>, pub loading: Option<FileSystemPath>,
#[serde(skip_serializing_if = "Option::is_none")]
pub template: Option<FileSystemPath>, pub template: Option<FileSystemPath>,
#[serde(skip_serializing_if = "Option::is_none")]
pub forbidden: Option<FileSystemPath>, pub forbidden: Option<FileSystemPath>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unauthorized: Option<FileSystemPath>, pub unauthorized: Option<FileSystemPath>,
#[serde(skip_serializing_if = "Option::is_none")]
pub not_found: Option<FileSystemPath>, pub not_found: Option<FileSystemPath>,
#[serde(skip_serializing_if = "Option::is_none")]
pub default: Option<FileSystemPath>, pub default: Option<FileSystemPath>,
#[serde(skip_serializing_if = "Option::is_none")]
pub route: Option<FileSystemPath>, pub route: Option<FileSystemPath>,
#[serde(skip_serializing_if = "Metadata::is_empty", default)]
pub metadata: Metadata, pub metadata: Metadata,
} }
...@@ -87,9 +73,7 @@ impl AppDirModules { ...@@ -87,9 +73,7 @@ impl AppDirModules {
} }
/// A single metadata file plus an optional "alt" text file. /// A single metadata file plus an optional "alt" text file.
#[derive( #[derive(Clone, Debug, PartialEq, Eq, TraceRawVcs, NonLocalValue, Encode, Decode)]
Clone, Debug, Serialize, Deserialize, PartialEq, Eq, TraceRawVcs, NonLocalValue, Encode, Decode,
)]
pub enum MetadataWithAltItem { pub enum MetadataWithAltItem {
Static { Static {
path: FileSystemPath, path: FileSystemPath,
...@@ -102,18 +86,7 @@ pub enum MetadataWithAltItem { ...@@ -102,18 +86,7 @@ pub enum MetadataWithAltItem {
/// A single metadata file. /// A single metadata file.
#[derive( #[derive(
Clone, Clone, Debug, Hash, PartialEq, Eq, TaskInput, TraceRawVcs, NonLocalValue, Encode, Decode,
Debug,
Hash,
Serialize,
Deserialize,
PartialEq,
Eq,
TaskInput,
TraceRawVcs,
NonLocalValue,
Encode,
Decode,
)] )]
pub enum MetadataItem { pub enum MetadataItem {
Static { path: FileSystemPath }, Static { path: FileSystemPath },
...@@ -159,29 +132,12 @@ impl From<MetadataWithAltItem> for MetadataItem { ...@@ -159,29 +132,12 @@ impl From<MetadataWithAltItem> for MetadataItem {
} }
/// Metadata file that can be placed in any segment of the app directory. /// Metadata file that can be placed in any segment of the app directory.
#[derive( #[derive(Default, Clone, Debug, PartialEq, Eq, TraceRawVcs, NonLocalValue, Encode, Decode)]
Default,
Clone,
Debug,
Serialize,
Deserialize,
PartialEq,
Eq,
TraceRawVcs,
NonLocalValue,
Encode,
Decode,
)]
pub struct Metadata { pub struct Metadata {
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub icon: Vec<MetadataWithAltItem>, pub icon: Vec<MetadataWithAltItem>,
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub apple: Vec<MetadataWithAltItem>, pub apple: Vec<MetadataWithAltItem>,
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub twitter: Vec<MetadataWithAltItem>, pub twitter: Vec<MetadataWithAltItem>,
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub open_graph: Vec<MetadataWithAltItem>, pub open_graph: Vec<MetadataWithAltItem>,
#[serde(skip_serializing_if = "Option::is_none")]
pub sitemap: Option<MetadataItem>, pub sitemap: Option<MetadataItem>,
// The page indicates where the metadata is defined and captured. // The page indicates where the metadata is defined and captured.
// The steps for capturing metadata (get_directory_tree) and constructing // The steps for capturing metadata (get_directory_tree) and constructing
...@@ -190,7 +146,6 @@ pub struct Metadata { ...@@ -190,7 +146,6 @@ pub struct Metadata {
// the actual path incorrectly with fillMetadataSegment. // the actual path incorrectly with fillMetadataSegment.
// //
// This is only being used for the static metadata files. // This is only being used for the static metadata files.
#[serde(skip_serializing_if = "Option::is_none")]
pub base_page: Option<AppPage>, pub base_page: Option<AppPage>,
} }
...@@ -216,11 +171,8 @@ impl Metadata { ...@@ -216,11 +171,8 @@ impl Metadata {
#[turbo_tasks::value] #[turbo_tasks::value]
#[derive(Default, Clone, Debug)] #[derive(Default, Clone, Debug)]
pub struct GlobalMetadata { pub struct GlobalMetadata {
#[serde(skip_serializing_if = "Option::is_none")]
pub favicon: Option<MetadataItem>, pub favicon: Option<MetadataItem>,
#[serde(skip_serializing_if = "Option::is_none")]
pub robots: Option<MetadataItem>, pub robots: Option<MetadataItem>,
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest: Option<MetadataItem>, pub manifest: Option<MetadataItem>,
} }
...@@ -534,8 +486,6 @@ impl ValueDefault for FileSystemPathVec { ...@@ -534,8 +486,6 @@ impl ValueDefault for FileSystemPathVec {
PartialEq, PartialEq,
Eq, Eq,
Hash, Hash,
Serialize,
Deserialize,
TraceRawVcs, TraceRawVcs,
ValueDebugFormat, ValueDebugFormat,
Debug, Debug,
......
...@@ -15,11 +15,10 @@ use turbopack_core::{ ...@@ -15,11 +15,10 @@ use turbopack_core::{
}; };
use turbopack_ecmascript::runtime_functions::{TURBOPACK_LOAD, TURBOPACK_REQUIRE}; use turbopack_ecmascript::runtime_functions::{TURBOPACK_LOAD, TURBOPACK_REQUIRE};
use super::app_entry::AppEntry;
use crate::{ use crate::{
app_page_loader_tree::{AppPageLoaderTreeModule, GLOBAL_ERROR}, app_page_loader_tree::{AppPageLoaderTreeModule, GLOBAL_ERROR},
app_structure::AppPageLoaderTree, app_structure::AppPageLoaderTree,
next_app::{AppPage, AppPath}, next_app::{AppPage, AppPath, app_entry::AppEntry},
next_config::NextConfig, next_config::NextConfig,
next_edge::entry::wrap_edge_entry, next_edge::entry::wrap_edge_entry,
next_server_component::NextServerComponentTransition, next_server_component::NextServerComponentTransition,
......
...@@ -2,7 +2,6 @@ use std::collections::BTreeSet; ...@@ -2,7 +2,6 @@ use std::collections::BTreeSet;
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs}; use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
...@@ -409,19 +408,7 @@ pub async fn get_client_module_options_context( ...@@ -409,19 +408,7 @@ pub async fn get_client_module_options_context(
Ok(module_options_context) Ok(module_options_context)
} }
#[derive( #[derive(Clone, Debug, PartialEq, Eq, Hash, TaskInput, TraceRawVcs, Encode, Decode)]
Clone,
Debug,
PartialEq,
Eq,
Hash,
TaskInput,
TraceRawVcs,
Serialize,
Deserialize,
Encode,
Decode,
)]
pub struct ClientChunkingContextOptions { pub struct ClientChunkingContextOptions {
pub mode: Vc<NextMode>, pub mode: Vc<NextMode>,
pub root_path: FileSystemPath, pub root_path: FileSystemPath,
......
...@@ -38,17 +38,6 @@ use crate::{ ...@@ -38,17 +38,6 @@ use crate::{
}, },
}; };
#[turbo_tasks::value]
struct NextConfigAndCustomRoutes {
config: ResolvedVc<NextConfig>,
custom_routes: ResolvedVc<CustomRoutes>,
}
#[turbo_tasks::value]
struct CustomRoutes {
rewrites: ResolvedVc<Rewrites>,
}
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
pub struct ModularizeImports( pub struct ModularizeImports(
#[bincode(with = "turbo_bincode::indexmap")] FxIndexMap<String, ModularizeImportPackageConfig>, #[bincode(with = "turbo_bincode::indexmap")] FxIndexMap<String, ModularizeImportPackageConfig>,
...@@ -76,7 +65,7 @@ impl Default for CacheKinds { ...@@ -76,7 +65,7 @@ impl Default for CacheKinds {
} }
#[turbo_tasks::value(eq = "manual")] #[turbo_tasks::value(eq = "manual")]
#[derive(Clone, Debug, Default, PartialEq)] #[derive(Clone, Debug, Default, PartialEq, Deserialize)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
pub struct NextConfig { pub struct NextConfig {
// IMPORTANT: all fields should be private and access should be wrapped within a turbo-tasks // IMPORTANT: all fields should be private and access should be wrapped within a turbo-tasks
...@@ -493,26 +482,17 @@ pub struct Redirect { ...@@ -493,26 +482,17 @@ pub struct Redirect {
pub status: RedirectStatus, pub status: RedirectStatus,
} }
#[derive( #[derive(Clone, Debug)]
Clone, Debug, PartialEq, Serialize, Deserialize, TraceRawVcs, NonLocalValue, Encode, Decode,
)]
#[serde(rename_all = "camelCase")]
pub struct Rewrite { pub struct Rewrite {
pub source: String, pub source: String,
pub destination: String, pub destination: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub base_path: Option<bool>, pub base_path: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub locale: Option<bool>, pub locale: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub has: Option<Vec<RouteHas>>, pub has: Option<Vec<RouteHas>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub missing: Option<Vec<RouteHas>>, pub missing: Option<Vec<RouteHas>>,
} }
#[turbo_tasks::value(eq = "manual")] #[derive(Clone, Debug)]
#[derive(Clone, Debug, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct Rewrites { pub struct Rewrites {
pub before_files: Vec<Rewrite>, pub before_files: Vec<Rewrite>,
pub after_files: Vec<Rewrite>, pub after_files: Vec<Rewrite>,
...@@ -539,7 +519,7 @@ pub struct TypeScriptConfig { ...@@ -539,7 +519,7 @@ pub struct TypeScriptConfig {
} }
#[turbo_tasks::value(eq = "manual", operation)] #[turbo_tasks::value(eq = "manual", operation)]
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ImageConfig { pub struct ImageConfig {
pub device_sizes: Vec<u16>, pub device_sizes: Vec<u16>,
...@@ -676,7 +656,6 @@ pub enum RemotePatternProtocol { ...@@ -676,7 +656,6 @@ pub enum RemotePatternProtocol {
Debug, Debug,
Default, Default,
PartialEq, PartialEq,
Serialize,
Deserialize, Deserialize,
TraceRawVcs, TraceRawVcs,
NonLocalValue, NonLocalValue,
...@@ -806,7 +785,7 @@ pub struct RuleConfigItem { ...@@ -806,7 +785,7 @@ pub struct RuleConfigItem {
pub condition: Option<ConfigConditionItem>, pub condition: Option<ConfigConditionItem>,
} }
#[derive(Clone, Debug, PartialEq, Eq, Serialize, TraceRawVcs, NonLocalValue, OperationValue)] #[derive(Clone, Debug, PartialEq, Eq, TraceRawVcs, Serialize, NonLocalValue, OperationValue)]
#[serde(transparent)] #[serde(transparent)]
pub struct RuleConfigCollection(Vec<RuleConfigCollectionItem>); pub struct RuleConfigCollection(Vec<RuleConfigCollectionItem>);
...@@ -845,7 +824,7 @@ pub enum LoaderItem { ...@@ -845,7 +824,7 @@ pub enum LoaderItem {
} }
#[turbo_tasks::value(operation)] #[turbo_tasks::value(operation)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub enum ModuleIds { pub enum ModuleIds {
Named, Named,
...@@ -856,16 +835,7 @@ pub enum ModuleIds { ...@@ -856,16 +835,7 @@ pub enum ModuleIds {
pub struct OptionModuleIds(pub Option<ModuleIds>); pub struct OptionModuleIds(pub Option<ModuleIds>);
#[derive( #[derive(
Clone, Clone, Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue, OperationValue, Encode, Decode,
Debug,
PartialEq,
Serialize,
Deserialize,
TraceRawVcs,
NonLocalValue,
OperationValue,
Encode,
Decode,
)] )]
#[serde(untagged)] #[serde(untagged)]
pub enum MdxRsOptions { pub enum MdxRsOptions {
...@@ -874,7 +844,7 @@ pub enum MdxRsOptions { ...@@ -874,7 +844,7 @@ pub enum MdxRsOptions {
} }
#[turbo_tasks::value(shared, operation)] #[turbo_tasks::value(shared, operation)]
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub enum ReactCompilerCompilationMode { pub enum ReactCompilerCompilationMode {
#[default] #[default]
...@@ -884,7 +854,7 @@ pub enum ReactCompilerCompilationMode { ...@@ -884,7 +854,7 @@ pub enum ReactCompilerCompilationMode {
} }
#[turbo_tasks::value(shared, operation)] #[turbo_tasks::value(shared, operation)]
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum ReactCompilerPanicThreshold { pub enum ReactCompilerPanicThreshold {
#[default] #[default]
...@@ -893,9 +863,10 @@ pub enum ReactCompilerPanicThreshold { ...@@ -893,9 +863,10 @@ pub enum ReactCompilerPanicThreshold {
AllErrors, AllErrors,
} }
/// Subset of react compiler options /// Subset of react compiler options, we pass these options through to the webpack loader, so it
/// must be serializable
#[turbo_tasks::value(shared, operation)] #[turbo_tasks::value(shared, operation)]
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ReactCompilerOptions { pub struct ReactCompilerOptions {
#[serde(default)] #[serde(default)]
...@@ -930,7 +901,6 @@ pub struct OptionalReactCompilerOptions(Option<ResolvedVc<ReactCompilerOptions>> ...@@ -930,7 +901,6 @@ pub struct OptionalReactCompilerOptions(Option<ResolvedVc<ReactCompilerOptions>>
Debug, Debug,
Default, Default,
PartialEq, PartialEq,
Serialize,
Deserialize, Deserialize,
TraceRawVcs, TraceRawVcs,
ValueDebugFormat, ValueDebugFormat,
...@@ -1274,16 +1244,7 @@ pub enum MiddlewarePrefetchType { ...@@ -1274,16 +1244,7 @@ pub enum MiddlewarePrefetchType {
} }
#[derive( #[derive(
Clone, Clone, Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue, OperationValue, Encode, Decode,
Debug,
PartialEq,
Serialize,
Deserialize,
TraceRawVcs,
NonLocalValue,
OperationValue,
Encode,
Decode,
)] )]
#[serde(untagged)] #[serde(untagged)]
pub enum EmotionTransformOptionsOrBoolean { pub enum EmotionTransformOptionsOrBoolean {
...@@ -1301,16 +1262,7 @@ impl EmotionTransformOptionsOrBoolean { ...@@ -1301,16 +1262,7 @@ impl EmotionTransformOptionsOrBoolean {
} }
#[derive( #[derive(
Clone, Clone, Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue, OperationValue, Encode, Decode,
Debug,
PartialEq,
Serialize,
Deserialize,
TraceRawVcs,
NonLocalValue,
OperationValue,
Encode,
Decode,
)] )]
#[serde(untagged)] #[serde(untagged)]
pub enum StyledComponentsTransformOptionsOrBoolean { pub enum StyledComponentsTransformOptionsOrBoolean {
...@@ -1328,7 +1280,7 @@ impl StyledComponentsTransformOptionsOrBoolean { ...@@ -1328,7 +1280,7 @@ impl StyledComponentsTransformOptionsOrBoolean {
} }
#[turbo_tasks::value(eq = "manual")] #[turbo_tasks::value(eq = "manual")]
#[derive(Clone, Debug, PartialEq, Default, OperationValue)] #[derive(Clone, Debug, PartialEq, Default, OperationValue, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct CompilerConfig { pub struct CompilerConfig {
pub react_remove_properties: Option<ReactRemoveProperties>, pub react_remove_properties: Option<ReactRemoveProperties>,
...@@ -1339,16 +1291,7 @@ pub struct CompilerConfig { ...@@ -1339,16 +1291,7 @@ pub struct CompilerConfig {
} }
#[derive( #[derive(
Clone, Clone, Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue, OperationValue, Encode, Decode,
Debug,
PartialEq,
Serialize,
Deserialize,
TraceRawVcs,
NonLocalValue,
OperationValue,
Encode,
Decode,
)] )]
#[serde(untagged, rename_all = "camelCase")] #[serde(untagged, rename_all = "camelCase")]
pub enum ReactRemoveProperties { pub enum ReactRemoveProperties {
...@@ -1366,16 +1309,7 @@ impl ReactRemoveProperties { ...@@ -1366,16 +1309,7 @@ impl ReactRemoveProperties {
} }
#[derive( #[derive(
Clone, Clone, Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue, OperationValue, Encode, Decode,
Debug,
PartialEq,
Serialize,
Deserialize,
TraceRawVcs,
NonLocalValue,
OperationValue,
Encode,
Decode,
)] )]
#[serde(untagged)] #[serde(untagged)]
pub enum RemoveConsoleConfig { pub enum RemoveConsoleConfig {
......
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs}; use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
...@@ -197,19 +196,7 @@ pub async fn get_edge_resolve_options_context( ...@@ -197,19 +196,7 @@ pub async fn get_edge_resolve_options_context(
.cell()) .cell())
} }
#[derive( #[derive(Clone, Debug, PartialEq, Eq, Hash, TaskInput, TraceRawVcs, Encode, Decode)]
Clone,
Debug,
PartialEq,
Eq,
Hash,
TaskInput,
TraceRawVcs,
Serialize,
Deserialize,
Encode,
Decode,
)]
pub struct EdgeChunkingContextOptions { pub struct EdgeChunkingContextOptions {
pub mode: Vc<NextMode>, pub mode: Vc<NextMode>,
pub root_path: FileSystemPath, pub root_path: FileSystemPath,
......
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize}; use serde::Deserialize;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{NonLocalValue, ResolvedVc, Vc, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, ResolvedVc, Vc, trace::TraceRawVcs};
...@@ -80,7 +80,7 @@ impl FontFallbacks { ...@@ -80,7 +80,7 @@ impl FontFallbacks {
/// An adjustment to be made to a fallback font to approximate the geometry of /// An adjustment to be made to a fallback font to approximate the geometry of
/// the main webfont. Rendered as e.g. `ascent-override: 56.8%;` in the /// the main webfont. Rendered as e.g. `ascent-override: 56.8%;` in the
/// stylesheet /// stylesheet
#[derive(Debug, PartialEq, Serialize, Deserialize, TraceRawVcs, NonLocalValue, Encode, Decode)] #[derive(Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue, Encode, Decode)]
pub(crate) struct FontAdjustment { pub(crate) struct FontAdjustment {
pub ascent: f64, pub ascent: f64,
pub descent: f64, pub descent: f64,
......
...@@ -2,7 +2,7 @@ use anyhow::{Context, Result}; ...@@ -2,7 +2,7 @@ use anyhow::{Context, Result};
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use serde::{Deserialize, Serialize}; use serde::Deserialize;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{FxIndexMap, NonLocalValue, Vc, trace::TraceRawVcs}; use turbo_tasks::{FxIndexMap, NonLocalValue, Vc, trace::TraceRawVcs};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
...@@ -22,9 +22,7 @@ use crate::{ ...@@ -22,9 +22,7 @@ use crate::{
}; };
/// An entry in the Google fonts metrics map /// An entry in the Google fonts metrics map
#[derive( #[derive(Deserialize, Debug, PartialEq, Eq, TraceRawVcs, NonLocalValue, Encode, Decode)]
Deserialize, Serialize, Debug, PartialEq, Eq, TraceRawVcs, NonLocalValue, Encode, Decode,
)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub(super) struct FontMetricsMapEntry { pub(super) struct FontMetricsMapEntry {
category: RcStr, category: RcStr,
...@@ -35,13 +33,13 @@ pub(super) struct FontMetricsMapEntry { ...@@ -35,13 +33,13 @@ pub(super) struct FontMetricsMapEntry {
x_width_avg: u64, x_width_avg: u64,
} }
#[derive(Debug)] #[derive(Debug, Deserialize)]
#[turbo_tasks::value] #[turbo_tasks::value]
pub(super) struct FontMetricsMap( pub(super) struct FontMetricsMap(
#[bincode(with = "turbo_bincode::indexmap")] pub FxIndexMap<RcStr, FontMetricsMapEntry>, #[bincode(with = "turbo_bincode::indexmap")] pub FxIndexMap<RcStr, FontMetricsMapEntry>,
); );
#[derive(Debug, PartialEq, Serialize, Deserialize, TraceRawVcs, NonLocalValue)] #[derive(Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue)]
struct Fallback { struct Fallback {
pub font_family: RcStr, pub font_family: RcStr,
pub adjustment: Option<FontAdjustment>, pub adjustment: Option<FontAdjustment>,
......
...@@ -37,22 +37,25 @@ use turbopack_node::{ ...@@ -37,22 +37,25 @@ use turbopack_node::{
execution_context::ExecutionContext, execution_context::ExecutionContext,
}; };
use self::{
font_fallback::get_font_fallback,
options::{FontDataEntry, FontWeights, NextFontGoogleOptions, options_from_request},
stylesheet::build_stylesheet,
util::{get_font_axes, get_stylesheet_url},
};
use super::{
font_fallback::FontFallback,
util::{
FontCssProperties, FontFamilyType, can_use_next_font, get_request_hash, get_request_id,
get_scoped_font_family,
},
};
use crate::{ use crate::{
embed_js::next_js_file_path, mode::NextMode, next_app::metadata::split_extension, embed_js::next_js_file_path,
next_font::issue::NextFontIssue, util::load_next_js_json_file, mode::NextMode,
next_app::metadata::split_extension,
next_font::{
font_fallback::FontFallback,
google::{
font_fallback::get_font_fallback,
options::{FontDataEntry, FontWeights, NextFontGoogleOptions, options_from_request},
stylesheet::build_stylesheet,
util::{get_font_axes, get_stylesheet_url},
},
issue::NextFontIssue,
util::{
FontCssProperties, FontFamilyType, can_use_next_font, get_request_hash, get_request_id,
get_scoped_font_family,
},
},
util::load_next_js_json_file,
}; };
pub mod font_fallback; pub mod font_fallback;
...@@ -74,6 +77,7 @@ pub const USER_AGENT_FOR_GOOGLE_FONTS: &str = "Mozilla/5.0 (Macintosh; Intel Mac ...@@ -74,6 +77,7 @@ pub const USER_AGENT_FOR_GOOGLE_FONTS: &str = "Mozilla/5.0 (Macintosh; Intel Mac
pub const GOOGLE_FONTS_INTERNAL_PREFIX: &str = "@vercel/turbopack-next/internal/font/google/font"; pub const GOOGLE_FONTS_INTERNAL_PREFIX: &str = "@vercel/turbopack-next/internal/font/google/font";
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
#[derive(Deserialize)]
struct FontData(#[bincode(with = "turbo_bincode::indexmap")] FxIndexMap<RcStr, FontDataEntry>); struct FontData(#[bincode(with = "turbo_bincode::indexmap")] FxIndexMap<RcStr, FontDataEntry>);
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
......
...@@ -2,7 +2,6 @@ use std::collections::BTreeSet; ...@@ -2,7 +2,6 @@ use std::collections::BTreeSet;
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs}; use turbo_tasks::{ResolvedVc, TaskInput, Vc, trace::TraceRawVcs};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
...@@ -982,19 +981,7 @@ pub async fn get_server_module_options_context( ...@@ -982,19 +981,7 @@ pub async fn get_server_module_options_context(
Ok(module_options_context) Ok(module_options_context)
} }
#[derive( #[derive(Clone, Debug, PartialEq, Eq, Hash, TaskInput, TraceRawVcs, Encode, Decode)]
Clone,
Debug,
PartialEq,
Eq,
Hash,
TaskInput,
TraceRawVcs,
Serialize,
Deserialize,
Encode,
Decode,
)]
pub struct ServerChunkingContextOptions { pub struct ServerChunkingContextOptions {
pub mode: Vc<NextMode>, pub mode: Vc<NextMode>,
pub root_path: FileSystemPath, pub root_path: FileSystemPath,
......
...@@ -4,8 +4,10 @@ use turbo_tasks_fs::FileSystemPath; ...@@ -4,8 +4,10 @@ use turbo_tasks_fs::FileSystemPath;
use turbopack::module_options::ModuleRule; use turbopack::module_options::ModuleRule;
use turbopack_ecmascript_plugins::transform::relay::RelayTransformer; use turbopack_ecmascript_plugins::transform::relay::RelayTransformer;
use super::get_ecma_transform_rule; use crate::{
use crate::{next_config::NextConfig, next_shared::transforms::EcmascriptTransformStage}; next_config::NextConfig,
next_shared::transforms::{EcmascriptTransformStage, get_ecma_transform_rule},
};
/// Returns a transform rule for the relay graphql transform. /// Returns a transform rule for the relay graphql transform.
pub async fn get_relay_transform_rule( pub async fn get_relay_transform_rule(
......
...@@ -6,12 +6,11 @@ use std::{ ...@@ -6,12 +6,11 @@ use std::{
use concurrent_queue::ConcurrentQueue; use concurrent_queue::ConcurrentQueue;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize, de::Visitor};
use turbo_tasks::{Invalidator, ReadRef}; use turbo_tasks::{Invalidator, ReadRef};
use crate::{FileContent, LinkContent}; use crate::{FileContent, LinkContent};
#[derive(Serialize, Deserialize, PartialEq, Eq)] #[derive(PartialEq, Eq)]
pub enum WriteContent { pub enum WriteContent {
File(ReadRef<FileContent>), File(ReadRef<FileContent>),
Link(ReadRef<LinkContent>), Link(ReadRef<LinkContent>),
...@@ -64,49 +63,3 @@ impl InvalidatorMap { ...@@ -64,49 +63,3 @@ impl InvalidatorMap {
}); });
} }
} }
impl Serialize for InvalidatorMap {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
// TODO: This stores absolute `PathBuf`s, which are machine-specific. This should
// normalize/denormalize paths relative to the disk filesystem root.
//
// Potential optimization: We invalidate all fs reads immediately upon resuming from a
// persisted cache, but we don't invalidate the fs writes. Those read invalidations trigger
// re-inserts into the `InvalidatorMap`. If we knew that certain invalidators were only
// needed for reads, we could potentially avoid serializing those paths entirely.
let inner: &LockedInvalidatorMap = &self.lock().unwrap();
serializer.serialize_newtype_struct("InvalidatorMap", inner)
}
}
impl<'de> Deserialize<'de> for InvalidatorMap {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
struct V;
impl<'de> Visitor<'de> for V {
type Value = InvalidatorMap;
fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "an InvalidatorMap")
}
fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where
D: serde::Deserializer<'de>,
{
Ok(InvalidatorMap {
queue: ConcurrentQueue::unbounded(),
map: Mutex::new(Deserialize::deserialize(deserializer)?),
})
}
}
deserializer.deserialize_newtype_struct("InvalidatorMap", V)
}
}
...@@ -2042,61 +2042,12 @@ impl File { ...@@ -2042,61 +2042,12 @@ impl File {
} }
} }
mod mime_option_serde {
use std::{fmt, str::FromStr};
use mime::Mime;
use serde::{Deserializer, Serializer, de};
pub fn serialize<S>(mime: &Option<Mime>, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
if let Some(mime) = mime {
serializer.serialize_str(mime.as_ref())
} else {
serializer.serialize_str("")
}
}
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Mime>, D::Error>
where
D: Deserializer<'de>,
{
struct Visitor;
impl de::Visitor<'_> for Visitor {
type Value = Option<Mime>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("a valid MIME type or empty string")
}
fn visit_str<E>(self, value: &str) -> Result<Option<Mime>, E>
where
E: de::Error,
{
if value.is_empty() {
Ok(None)
} else {
Mime::from_str(value)
.map(Some)
.map_err(|e| E::custom(format!("{e}")))
}
}
}
deserializer.deserialize_str(Visitor)
}
}
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]
pub struct FileMeta { pub struct FileMeta {
// Size of the file // Size of the file
// len: u64, // len: u64,
permissions: Permissions, permissions: Permissions,
#[serde(with = "mime_option_serde")]
#[bincode(with = "turbo_bincode::mime_option")] #[bincode(with = "turbo_bincode::mime_option")]
#[turbo_tasks(trace_ignore)] #[turbo_tasks(trace_ignore)]
content_type: Option<Mime>, content_type: Option<Mime>,
...@@ -2387,19 +2338,7 @@ pub enum RawDirectoryEntry { ...@@ -2387,19 +2338,7 @@ pub enum RawDirectoryEntry {
Other, Other,
} }
#[derive( #[derive(Hash, Clone, Debug, PartialEq, Eq, TraceRawVcs, NonLocalValue, Encode, Decode)]
Hash,
Clone,
Debug,
PartialEq,
Eq,
TraceRawVcs,
Serialize,
Deserialize,
NonLocalValue,
Encode,
Decode,
)]
pub enum DirectoryEntry { pub enum DirectoryEntry {
File(FileSystemPath), File(FileSystemPath),
Directory(FileSystemPath), Directory(FileSystemPath),
......
...@@ -16,7 +16,7 @@ error[E0277]: the trait bound `Vc<i32>: NonLocalValue` is not satisfied ...@@ -16,7 +16,7 @@ error[E0277]: the trait bound `Vc<i32>: NonLocalValue` is not satisfied
and $N others and $N others
= note: required for `[Vc<i32>; 4]` to implement `NonLocalValue` = note: required for `[Vc<i32>; 4]` to implement `NonLocalValue`
= note: 2 redundant requirements hidden = note: 2 redundant requirements hidden
= note: required for `std::option::Option<Box<[Vc<i32>; 4]>>` to implement `NonLocalValue` = note: required for `Option<Box<[Vc<i32>; 4]>>` to implement `NonLocalValue`
note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue` note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_non_local_value/fail_contains_vc_inside_generic.rs:5:10 --> tests/derive_non_local_value/fail_contains_vc_inside_generic.rs:5:10
| |
......
...@@ -6,7 +6,7 @@ use quote::{ToTokens, quote, quote_spanned}; ...@@ -6,7 +6,7 @@ use quote::{ToTokens, quote, quote_spanned};
use regex::Regex; use regex::Regex;
use syn::{ use syn::{
Error, Expr, ExprLit, Fields, FieldsUnnamed, Generics, Item, ItemEnum, ItemStruct, Lit, LitStr, Error, Expr, ExprLit, Fields, FieldsUnnamed, Generics, Item, ItemEnum, ItemStruct, Lit, LitStr,
Meta, MetaNameValue, Result, Token, Meta, MetaNameValue, Token,
parse::{Parse, ParseStream}, parse::{Parse, ParseStream},
parse_macro_input, parse_quote, parse_macro_input, parse_quote,
spanned::Spanned, spanned::Spanned,
...@@ -20,7 +20,7 @@ enum CellMode { ...@@ -20,7 +20,7 @@ enum CellMode {
} }
impl Parse for CellMode { impl Parse for CellMode {
fn parse(input: ParseStream) -> Result<Self> { fn parse(input: ParseStream) -> syn::Result<Self> {
let ident = input.parse::<LitStr>()?; let ident = input.parse::<LitStr>()?;
Self::try_from(ident) Self::try_from(ident)
} }
...@@ -29,7 +29,7 @@ impl Parse for CellMode { ...@@ -29,7 +29,7 @@ impl Parse for CellMode {
impl TryFrom<LitStr> for CellMode { impl TryFrom<LitStr> for CellMode {
type Error = Error; type Error = Error;
fn try_from(lit: LitStr) -> std::result::Result<Self, Self::Error> { fn try_from(lit: LitStr) -> Result<Self, Self::Error> {
match lit.value().as_str() { match lit.value().as_str() {
"compare" => Ok(CellMode::Compare), "compare" => Ok(CellMode::Compare),
"new" => Ok(CellMode::New), "new" => Ok(CellMode::New),
...@@ -45,7 +45,7 @@ enum SerializationMode { ...@@ -45,7 +45,7 @@ enum SerializationMode {
} }
impl Parse for SerializationMode { impl Parse for SerializationMode {
fn parse(input: ParseStream) -> Result<Self> { fn parse(input: ParseStream) -> syn::Result<Self> {
let ident = input.parse::<LitStr>()?; let ident = input.parse::<LitStr>()?;
Self::try_from(ident) Self::try_from(ident)
} }
...@@ -54,7 +54,7 @@ impl Parse for SerializationMode { ...@@ -54,7 +54,7 @@ impl Parse for SerializationMode {
impl TryFrom<LitStr> for SerializationMode { impl TryFrom<LitStr> for SerializationMode {
type Error = Error; type Error = Error;
fn try_from(lit: LitStr) -> std::result::Result<Self, Self::Error> { fn try_from(lit: LitStr) -> Result<Self, Self::Error> {
match lit.value().as_str() { match lit.value().as_str() {
"none" => Ok(SerializationMode::None), "none" => Ok(SerializationMode::None),
"auto" => Ok(SerializationMode::Auto), "auto" => Ok(SerializationMode::Auto),
...@@ -78,7 +78,7 @@ struct ValueArguments { ...@@ -78,7 +78,7 @@ struct ValueArguments {
} }
impl Parse for ValueArguments { impl Parse for ValueArguments {
fn parse(input: ParseStream) -> Result<Self> { fn parse(input: ParseStream) -> syn::Result<Self> {
let mut result = ValueArguments { let mut result = ValueArguments {
serialization_mode: SerializationMode::Auto, serialization_mode: SerializationMode::Auto,
shared: false, shared: false,
...@@ -300,19 +300,11 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -300,19 +300,11 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
SerializationMode::Auto => { SerializationMode::Auto => {
struct_attributes.push(quote! { struct_attributes.push(quote! {
#[derive( #[derive(
turbo_tasks::macro_helpers::serde::Serialize,
turbo_tasks::macro_helpers::serde::Deserialize,
turbo_tasks::macro_helpers::bincode::Encode, turbo_tasks::macro_helpers::bincode::Encode,
turbo_tasks::macro_helpers::bincode::Decode, turbo_tasks::macro_helpers::bincode::Decode,
)] )]
#[serde(crate = "turbo_tasks::macro_helpers::serde")]
#[bincode(crate = "turbo_tasks::macro_helpers::bincode")] #[bincode(crate = "turbo_tasks::macro_helpers::bincode")]
}); });
if transparent {
struct_attributes.push(quote! {
#[serde(transparent)]
});
}
} }
SerializationMode::None | SerializationMode::Custom => {} SerializationMode::None | SerializationMode::Custom => {}
}; };
......
...@@ -4,7 +4,6 @@ pub use async_trait::async_trait; ...@@ -4,7 +4,6 @@ pub use async_trait::async_trait;
pub use bincode; pub use bincode;
pub use once_cell::sync::{Lazy, OnceCell}; pub use once_cell::sync::{Lazy, OnceCell};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
pub use serde;
pub use shrink_to_fit; pub use shrink_to_fit;
pub use tracing; pub use tracing;
......
...@@ -50,7 +50,7 @@ pub enum MangleType { ...@@ -50,7 +50,7 @@ pub enum MangleType {
} }
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Debug, TaskInput, Clone, Copy, Hash, DeterministicHash)] #[derive(Debug, TaskInput, Clone, Copy, Hash, DeterministicHash, Deserialize)]
pub enum MinifyType { pub enum MinifyType {
// TODO instead of adding a new property here, // TODO instead of adding a new property here,
// refactor that to Minify(MinifyOptions) to allow defaults on MinifyOptions // refactor that to Minify(MinifyOptions) to allow defaults on MinifyOptions
...@@ -257,7 +257,7 @@ pub struct ChunkingConfig { ...@@ -257,7 +257,7 @@ pub struct ChunkingConfig {
pub struct ChunkingConfigs(FxHashMap<ResolvedVc<Box<dyn ChunkType>>, ChunkingConfig>); pub struct ChunkingConfigs(FxHashMap<ResolvedVc<Box<dyn ChunkType>>, ChunkingConfig>);
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Debug, Clone, Copy, Hash, TaskInput, Default)] #[derive(Debug, Clone, Copy, Hash, TaskInput, Default, Deserialize)]
pub enum SourceMapSourceType { pub enum SourceMapSourceType {
AbsoluteFileUri, AbsoluteFileUri,
RelativeUri, RelativeUri,
......
...@@ -52,7 +52,7 @@ use crate::{ ...@@ -52,7 +52,7 @@ use crate::{
/// A module id, which can be a number or string /// A module id, which can be a number or string
#[turbo_tasks::value(shared, operation)] #[turbo_tasks::value(shared, operation)]
#[derive(Debug, Clone, Hash, Ord, PartialOrd, DeterministicHash)] #[derive(Debug, Clone, Hash, Ord, PartialOrd, DeterministicHash, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum ModuleId { pub enum ModuleId {
Number(u64), Number(u64),
......
...@@ -295,19 +295,7 @@ pub struct FreeVarReferences( ...@@ -295,19 +295,7 @@ pub struct FreeVarReferences(
pub FxIndexMap<Vec<DefinableNameSegment>, FreeVarReference>, pub FxIndexMap<Vec<DefinableNameSegment>, FreeVarReference>,
); );
#[derive( #[derive(Debug, Default, Clone, PartialEq, Eq, TraceRawVcs, NonLocalValue, Encode, Decode)]
Debug,
Default,
Clone,
PartialEq,
Eq,
Serialize,
Deserialize,
TraceRawVcs,
NonLocalValue,
Encode,
Decode,
)]
pub struct FreeVarReferenceVcs( pub struct FreeVarReferenceVcs(
#[bincode(with = "turbo_bincode::indexmap")] #[bincode(with = "turbo_bincode::indexmap")]
pub FxIndexMap<Vec<DefinableNameSegment>, ResolvedVc<FreeVarReference>>, pub FxIndexMap<Vec<DefinableNameSegment>, ResolvedVc<FreeVarReference>>,
......
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
use turbo_tasks::{NonLocalValue, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, trace::TraceRawVcs};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
#[derive( #[derive(Debug, Clone, TraceRawVcs, PartialEq, Eq, NonLocalValue, Encode, Decode)]
Debug, Clone, Serialize, Deserialize, TraceRawVcs, PartialEq, Eq, NonLocalValue, Encode, Decode,
)]
pub enum ContextCondition { pub enum ContextCondition {
All(Vec<ContextCondition>), All(Vec<ContextCondition>),
Any(Vec<ContextCondition>), Any(Vec<ContextCondition>),
......
...@@ -30,7 +30,9 @@ use crate::{ ...@@ -30,7 +30,9 @@ use crate::{
}; };
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(PartialOrd, Ord, Copy, Clone, Hash, Debug, DeterministicHash, TaskInput)] #[derive(
PartialOrd, Ord, Copy, Clone, Hash, Debug, DeterministicHash, TaskInput, Serialize, Deserialize,
)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub enum IssueSeverity { pub enum IssueSeverity {
Bug, Bug,
...@@ -80,7 +82,7 @@ impl Display for IssueSeverity { ...@@ -80,7 +82,7 @@ impl Display for IssueSeverity {
/// Represents a section of structured styled text. This can be interpreted and /// Represents a section of structured styled text. This can be interpreted and
/// rendered by various UIs as appropriate, e.g. HTML for display on the web, /// rendered by various UIs as appropriate, e.g. HTML for display on the web,
/// ANSI sequences in TTYs. /// ANSI sequences in TTYs.
#[derive(Clone, Debug, PartialOrd, Ord, DeterministicHash)] #[derive(Clone, Debug, PartialOrd, Ord, DeterministicHash, Serialize)]
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
pub enum StyledString { pub enum StyledString {
/// Multiple [StyledString]s concatenated into a single line. Each item is /// Multiple [StyledString]s concatenated into a single line. Each item is
...@@ -632,7 +634,7 @@ async fn into_plain_trace(traces: Vec<Vec<ReadRef<AssetIdent>>>) -> Result<Vec<P ...@@ -632,7 +634,7 @@ async fn into_plain_trace(traces: Vec<Vec<ReadRef<AssetIdent>>>) -> Result<Vec<P
} }
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Clone, Debug, PartialOrd, Ord, DeterministicHash)] #[derive(Clone, Debug, PartialOrd, Ord, DeterministicHash, Serialize)]
pub enum IssueStage { pub enum IssueStage {
Config, Config,
AppStructure, AppStructure,
......
...@@ -2,7 +2,6 @@ use std::collections::HashSet; ...@@ -2,7 +2,6 @@ use std::collections::HashSet;
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{ use turbo_tasks::{
FxIndexSet, NonLocalValue, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, ValueToString, Vc, FxIndexSet, NonLocalValue, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, ValueToString, Vc,
...@@ -294,18 +293,7 @@ pub async fn primary_referenced_modules(module: Vc<Box<dyn Module>>) -> Result<V ...@@ -294,18 +293,7 @@ pub async fn primary_referenced_modules(module: Vc<Box<dyn Module>>) -> Result<V
Ok(Vc::cell(modules)) Ok(Vc::cell(modules))
} }
#[derive( #[derive(Clone, Eq, PartialEq, ValueDebugFormat, TraceRawVcs, NonLocalValue, Encode, Decode)]
Clone,
Serialize,
Deserialize,
Eq,
PartialEq,
ValueDebugFormat,
TraceRawVcs,
NonLocalValue,
Encode,
Decode,
)]
pub struct ResolvedReference { pub struct ResolvedReference {
pub chunking_type: ChunkingType, pub chunking_type: ChunkingType,
pub binding_usage: BindingUsage, pub binding_usage: BindingUsage,
......
...@@ -103,7 +103,7 @@ impl ModuleResolveResultItem { ...@@ -103,7 +103,7 @@ impl ModuleResolveResultItem {
} }
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Clone, Debug, Hash, Default)] #[derive(Clone, Debug, Hash, Default, Serialize, Deserialize)]
pub struct BindingUsage { pub struct BindingUsage {
pub import: ImportUsage, pub import: ImportUsage,
pub export: ExportUsage, pub export: ExportUsage,
...@@ -118,7 +118,7 @@ impl BindingUsage { ...@@ -118,7 +118,7 @@ impl BindingUsage {
} }
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Debug, Clone, Default, Hash)] #[derive(Debug, Clone, Default, Hash, Serialize, Deserialize)]
pub enum ImportUsage { pub enum ImportUsage {
/// This import is used by some side effect in the module (and can't be tree shaken). /// This import is used by some side effect in the module (and can't be tree shaken).
#[default] #[default]
...@@ -132,7 +132,7 @@ pub enum ImportUsage { ...@@ -132,7 +132,7 @@ pub enum ImportUsage {
} }
#[turbo_tasks::value] #[turbo_tasks::value]
#[derive(Debug, Clone, Default, Hash)] #[derive(Debug, Clone, Default, Hash, Serialize, Deserialize)]
pub enum ExportUsage { pub enum ExportUsage {
Named(RcStr), Named(RcStr),
/// This means the whole content of the module is used. /// This means the whole content of the module is used.
...@@ -1291,9 +1291,7 @@ pub async fn find_context_file_or_package_key( ...@@ -1291,9 +1291,7 @@ pub async fn find_context_file_or_package_key(
Ok(find_context_file(lookup_path.parent(), names, false)) Ok(find_context_file(lookup_path.parent(), names, false))
} }
#[derive( #[derive(Clone, PartialEq, Eq, TraceRawVcs, Debug, NonLocalValue, Encode, Decode)]
Clone, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, Debug, NonLocalValue, Encode, Decode,
)]
enum FindPackageItem { enum FindPackageItem {
PackageDirectory { name: RcStr, dir: FileSystemPath }, PackageDirectory { name: RcStr, dir: FileSystemPath },
PackageFile { name: RcStr, file: FileSystemPath }, PackageFile { name: RcStr, file: FileSystemPath },
......
...@@ -10,13 +10,13 @@ use turbo_tasks::{ ...@@ -10,13 +10,13 @@ use turbo_tasks::{
}; };
use turbo_tasks_fs::{FileSystemPath, glob::Glob}; use turbo_tasks_fs::{FileSystemPath, glob::Glob};
use super::{ use crate::resolve::{
AliasPattern, ExternalType, ResolveResult, ResolveResultItem, AliasPattern, ExternalTraced, ExternalType, ResolveResult, ResolveResultItem,
alias_map::{AliasMap, AliasTemplate}, alias_map::{AliasMap, AliasTemplate},
parse::Request,
pattern::Pattern, pattern::Pattern,
plugin::BeforeResolvePlugin, plugin::{AfterResolvePlugin, BeforeResolvePlugin},
}; };
use crate::resolve::{ExternalTraced, parse::Request, plugin::AfterResolvePlugin};
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Hash, Debug)] #[derive(Hash, Debug)]
...@@ -28,18 +28,7 @@ pub struct ExcludedExtensions(#[bincode(with = "turbo_bincode::indexset")] pub F ...@@ -28,18 +28,7 @@ pub struct ExcludedExtensions(#[bincode(with = "turbo_bincode::indexset")] pub F
/// A location where to resolve modules. /// A location where to resolve modules.
#[derive( #[derive(
TraceRawVcs, TraceRawVcs, Hash, PartialEq, Eq, Clone, Debug, ValueDebugFormat, NonLocalValue, Encode, Decode,
Hash,
PartialEq,
Eq,
Clone,
Debug,
Serialize,
Deserialize,
ValueDebugFormat,
NonLocalValue,
Encode,
Decode,
)] )]
pub enum ResolveModules { pub enum ResolveModules {
/// when inside of path, use the list of directories to /// when inside of path, use the list of directories to
......
...@@ -8,7 +8,6 @@ use anyhow::{Result, bail}; ...@@ -8,7 +8,6 @@ use anyhow::{Result, bail};
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use regex::Regex; use regex::Regex;
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
use serde::{Deserialize, Serialize};
use tracing::Instrument; use tracing::Instrument;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ use turbo_tasks::{
...@@ -1493,17 +1492,7 @@ impl ValueToString for Pattern { ...@@ -1493,17 +1492,7 @@ impl ValueToString for Pattern {
} }
#[derive( #[derive(
Debug, Debug, PartialEq, Eq, Clone, TraceRawVcs, ValueDebugFormat, NonLocalValue, Encode, Decode,
PartialEq,
Eq,
Clone,
TraceRawVcs,
Serialize,
Deserialize,
ValueDebugFormat,
NonLocalValue,
Encode,
Decode,
)] )]
pub enum PatternMatch { pub enum PatternMatch {
File(RcStr, FileSystemPath), File(RcStr, FileSystemPath),
......
...@@ -61,7 +61,7 @@ pub enum SubpathValue { ...@@ -61,7 +61,7 @@ pub enum SubpathValue {
/// A `SubpathValue` that was applied to a pattern. See `SubpathValue` for /// A `SubpathValue` that was applied to a pattern. See `SubpathValue` for
/// more details on the variants. /// more details on the variants.
#[derive(Clone, PartialEq, Eq, Hash, Debug, Serialize, Deserialize)] #[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub enum ReplacedSubpathValue { pub enum ReplacedSubpathValue {
Alternatives(Vec<ReplacedSubpathValue>), Alternatives(Vec<ReplacedSubpathValue>),
Conditional(Vec<(RcStr, ReplacedSubpathValue)>), Conditional(Vec<(RcStr, ReplacedSubpathValue)>),
......
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ use turbo_tasks::{
FxIndexSet, NonLocalValue, ResolvedVc, ValueToString, Vc, debug::ValueDebugFormat, FxIndexSet, NonLocalValue, ResolvedVc, ValueToString, Vc, debug::ValueDebugFormat,
...@@ -17,17 +16,7 @@ use crate::{ ...@@ -17,17 +16,7 @@ use crate::{
source_map::{GenerateSourceMap, SourceMap}, source_map::{GenerateSourceMap, SourceMap},
}; };
#[derive( #[derive(PartialEq, Eq, NonLocalValue, TraceRawVcs, ValueDebugFormat, Encode, Decode)]
PartialEq,
Eq,
Serialize,
Deserialize,
NonLocalValue,
TraceRawVcs,
ValueDebugFormat,
Encode,
Decode,
)]
enum PathType { enum PathType {
Fixed { Fixed {
path: FileSystemPath, path: FileSystemPath,
......
...@@ -29,7 +29,6 @@ use turbopack_ecmascript::{CustomTransformer, TransformContext}; ...@@ -29,7 +29,6 @@ use turbopack_ecmascript::{CustomTransformer, TransformContext};
Eq, Eq,
Debug, Debug,
TraceRawVcs, TraceRawVcs,
Serialize,
Deserialize, Deserialize,
NonLocalValue, NonLocalValue,
OperationValue, OperationValue,
...@@ -75,7 +74,7 @@ impl From<&EmotionItemSpecifier> for swc_emotion::ItemSpecifier { ...@@ -75,7 +74,7 @@ impl From<&EmotionItemSpecifier> for swc_emotion::ItemSpecifier {
pub type EmotionImportMapValue = IndexMap<RcStr, EmotionImportItemConfig, FxBuildHasher>; pub type EmotionImportMapValue = IndexMap<RcStr, EmotionImportItemConfig, FxBuildHasher>;
#[turbo_tasks::value(shared, operation)] #[turbo_tasks::value(shared, operation)]
#[derive(Default, Clone, Debug)] #[derive(Default, Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct EmotionTransformConfig { pub struct EmotionTransformConfig {
pub sourcemap: Option<bool>, pub sourcemap: Option<bool>,
......
...@@ -3,7 +3,7 @@ use std::{path::PathBuf, sync::Arc}; ...@@ -3,7 +3,7 @@ use std::{path::PathBuf, sync::Arc};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use async_trait::async_trait; use async_trait::async_trait;
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize}; use serde::Deserialize;
use swc_core::{common::FileName, ecma::ast::Program}; use swc_core::{common::FileName, ecma::ast::Program};
use swc_relay::RelayLanguageConfig; use swc_relay::RelayLanguageConfig;
use turbo_tasks::{NonLocalValue, OperationValue, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, OperationValue, trace::TraceRawVcs};
...@@ -11,16 +11,7 @@ use turbo_tasks_fs::FileSystemPath; ...@@ -11,16 +11,7 @@ use turbo_tasks_fs::FileSystemPath;
use turbopack_ecmascript::{CustomTransformer, TransformContext}; use turbopack_ecmascript::{CustomTransformer, TransformContext};
#[derive( #[derive(
Clone, Clone, Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue, OperationValue, Encode, Decode,
Debug,
PartialEq,
Serialize,
Deserialize,
TraceRawVcs,
NonLocalValue,
OperationValue,
Encode,
Decode,
)] )]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct RelayConfig { pub struct RelayConfig {
...@@ -30,16 +21,7 @@ pub struct RelayConfig { ...@@ -30,16 +21,7 @@ pub struct RelayConfig {
} }
#[derive( #[derive(
Clone, Clone, Debug, PartialEq, Deserialize, TraceRawVcs, NonLocalValue, OperationValue, Encode, Decode,
Debug,
PartialEq,
Serialize,
Deserialize,
TraceRawVcs,
NonLocalValue,
OperationValue,
Encode,
Decode,
)] )]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
pub enum RelayLanguage { pub enum RelayLanguage {
......
use anyhow::Result; use anyhow::Result;
use async_trait::async_trait; use async_trait::async_trait;
use serde::Deserialize;
use swc_core::{atoms::Wtf8Atom, common::comments::NoopComments, ecma::ast::Program}; use swc_core::{atoms::Wtf8Atom, common::comments::NoopComments, ecma::ast::Program};
use turbo_tasks::{ValueDefault, Vc}; use turbo_tasks::{ValueDefault, Vc};
use turbopack_ecmascript::{CustomTransformer, TransformContext}; use turbopack_ecmascript::{CustomTransformer, TransformContext};
#[turbo_tasks::value(shared, operation)] #[turbo_tasks::value(shared, operation)]
#[derive(Clone, Debug)] #[derive(Clone, Debug, Deserialize)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
pub struct StyledComponentsTransformConfig { pub struct StyledComponentsTransformConfig {
pub display_name: bool, pub display_name: bool,
......
use serde::Deserialize;
use turbo_tasks::TaskInput; use turbo_tasks::TaskInput;
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Debug, Clone, Copy, Hash, TaskInput)] #[derive(Debug, Clone, Copy, Hash, TaskInput, Deserialize)]
pub enum RuntimeType { pub enum RuntimeType {
Development, Development,
Production, Production,
......
...@@ -35,8 +35,6 @@ use crate::{ ...@@ -35,8 +35,6 @@ use crate::{
PartialEq, PartialEq,
Eq, Eq,
Hash, Hash,
Serialize,
Deserialize,
TraceRawVcs, TraceRawVcs,
TaskInput, TaskInput,
NonLocalValue, NonLocalValue,
......
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
use swc_core::{ use swc_core::{
base::SwcComments, base::SwcComments,
ecma::{ ecma::{
...@@ -175,17 +174,7 @@ impl_modify!(visit_mut_switch_case, SwitchCase); ...@@ -175,17 +174,7 @@ impl_modify!(visit_mut_switch_case, SwitchCase);
impl_modify!(visit_mut_program, Program); impl_modify!(visit_mut_program, Program);
#[derive( #[derive(
PartialEq, PartialEq, Eq, TraceRawVcs, ValueDebugFormat, NonLocalValue, Hash, Debug, Encode, Decode,
Eq,
Serialize,
Deserialize,
TraceRawVcs,
ValueDebugFormat,
NonLocalValue,
Hash,
Debug,
Encode,
Decode,
)] )]
pub enum CodeGen { pub enum CodeGen {
// AMD occurs very rarely and makes the enum much bigger // AMD occurs very rarely and makes the enum much bigger
......
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
use swc_core::{ use swc_core::{
common::{DUMMY_SP, FileName, SourceMap, sync::Lrc}, common::{DUMMY_SP, FileName, SourceMap, sync::Lrc},
ecma::{ ecma::{
...@@ -20,18 +19,7 @@ use crate::{ ...@@ -20,18 +19,7 @@ use crate::{
}; };
#[derive( #[derive(
Clone, Clone, Debug, PartialEq, Eq, Hash, TraceRawVcs, ValueDebugFormat, NonLocalValue, Encode, Decode,
Debug,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize,
TraceRawVcs,
ValueDebugFormat,
NonLocalValue,
Encode,
Decode,
)] )]
pub struct ConstantValueCodeGen { pub struct ConstantValueCodeGen {
value: CompileTimeDefineValue, value: CompileTimeDefineValue,
......
...@@ -28,17 +28,7 @@ use crate::{ ...@@ -28,17 +28,7 @@ use crate::{
/// ///
/// This singleton behavior must be enforced by the caller! /// This singleton behavior must be enforced by the caller!
#[derive( #[derive(
PartialEq, PartialEq, Eq, TraceRawVcs, ValueDebugFormat, NonLocalValue, Debug, Hash, Encode, Decode,
Eq,
Serialize,
Deserialize,
TraceRawVcs,
ValueDebugFormat,
NonLocalValue,
Debug,
Hash,
Encode,
Decode,
)] )]
pub struct ImportMetaBinding { pub struct ImportMetaBinding {
path: FileSystemPath, path: FileSystemPath,
......
...@@ -38,17 +38,7 @@ use crate::{ ...@@ -38,17 +38,7 @@ use crate::{
utils::module_id_to_lit, utils::module_id_to_lit,
}; };
#[derive( #[derive(PartialEq, Eq, ValueDebugFormat, TraceRawVcs, NonLocalValue, Encode, Decode)]
PartialEq,
Eq,
ValueDebugFormat,
TraceRawVcs,
Serialize,
Deserialize,
NonLocalValue,
Encode,
Decode,
)]
pub(crate) enum SinglePatternMapping { pub(crate) enum SinglePatternMapping {
/// Invalid request. /// Invalid request.
Invalid, Invalid,
......
...@@ -33,9 +33,7 @@ pub enum EcmascriptInputTransform { ...@@ -33,9 +33,7 @@ pub enum EcmascriptInputTransform {
Plugin(ResolvedVc<TransformPlugin>), Plugin(ResolvedVc<TransformPlugin>),
PresetEnv(ResolvedVc<Environment>), PresetEnv(ResolvedVc<Environment>),
React { React {
#[serde(default)]
development: bool, development: bool,
#[serde(default)]
refresh: bool, refresh: bool,
// swc.jsc.transform.react.importSource // swc.jsc.transform.react.importSource
import_source: ResolvedVc<Option<RcStr>>, import_source: ResolvedVc<Option<RcStr>>,
...@@ -45,17 +43,12 @@ pub enum EcmascriptInputTransform { ...@@ -45,17 +43,12 @@ pub enum EcmascriptInputTransform {
// These options are subset of swc_core::ecma::transforms::typescript::Config, but // These options are subset of swc_core::ecma::transforms::typescript::Config, but
// it doesn't derive `Copy` so repeating values in here // it doesn't derive `Copy` so repeating values in here
TypeScript { TypeScript {
#[serde(default)]
use_define_for_class_fields: bool, use_define_for_class_fields: bool,
}, },
Decorators { Decorators {
#[serde(default)]
is_legacy: bool, is_legacy: bool,
#[serde(default)]
is_ecma: bool, is_ecma: bool,
#[serde(default)]
emit_decorators_metadata: bool, emit_decorators_metadata: bool,
#[serde(default)]
use_define_for_class_fields: bool, use_define_for_class_fields: bool,
}, },
} }
......
...@@ -35,7 +35,6 @@ once_cell = { workspace = true } ...@@ -35,7 +35,6 @@ once_cell = { workspace = true }
regex = { workspace = true } regex = { workspace = true }
rustc-hash = { workspace = true } rustc-hash = { workspace = true }
serde = { workspace = true } serde = { workspace = true }
serde_with = { workspace = true }
turbo-bincode = { workspace = true } turbo-bincode = { workspace = true }
turbo-rcstr = { workspace = true } turbo-rcstr = { workspace = true }
turbo-tasks = { workspace = true } turbo-tasks = { workspace = true }
......
...@@ -17,7 +17,6 @@ use image::{ ...@@ -17,7 +17,6 @@ use image::{
}; };
use mime::Mime; use mime::Mime;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_with::{DisplayFromStr, serde_as};
use turbo_rcstr::rcstr; use turbo_rcstr::rcstr;
use turbo_tasks::{NonLocalValue, ResolvedVc, Vc, debug::ValueDebugFormat, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, ResolvedVc, Vc, debug::ValueDebugFormat, trace::TraceRawVcs};
use turbo_tasks_fs::{File, FileContent, FileSystemPath}; use turbo_tasks_fs::{File, FileContent, FileSystemPath};
...@@ -64,7 +63,6 @@ impl BlurPlaceholder { ...@@ -64,7 +63,6 @@ impl BlurPlaceholder {
/// Gathered meta information about an image. /// Gathered meta information about an image.
#[allow(clippy::manual_non_exhaustive)] #[allow(clippy::manual_non_exhaustive)]
#[serde_as]
#[turbo_tasks::value] #[turbo_tasks::value]
#[derive(Default)] #[derive(Default)]
#[non_exhaustive] #[non_exhaustive]
...@@ -72,7 +70,6 @@ pub struct ImageMetaData { ...@@ -72,7 +70,6 @@ pub struct ImageMetaData {
pub width: u32, pub width: u32,
pub height: u32, pub height: u32,
#[turbo_tasks(trace_ignore, debug_ignore)] #[turbo_tasks(trace_ignore, debug_ignore)]
#[serde_as(as = "Option<DisplayFromStr>")]
#[bincode(with = "turbo_bincode::mime_option")] #[bincode(with = "turbo_bincode::mime_option")]
pub mime_type: Option<Mime>, pub mime_type: Option<Mime>,
pub blur_placeholder: Option<BlurPlaceholder>, pub blur_placeholder: Option<BlurPlaceholder>,
......
...@@ -14,13 +14,11 @@ workspace = true ...@@ -14,13 +14,11 @@ workspace = true
[dependencies] [dependencies]
anyhow = { workspace = true } anyhow = { workspace = true }
markdown = { workspace = true } markdown = { workspace = true }
mdxjs = { workspace = true } mdxjs = { workspace = true }
serde = { workspace = true }
turbo-rcstr = { workspace = true } turbo-rcstr = { workspace = true }
turbo-tasks = { workspace = true } turbo-tasks = { workspace = true }
turbo-tasks-fs = { workspace = true } turbo-tasks-fs = { workspace = true }
turbopack-core = { workspace = true } turbopack-core = { workspace = true }
turbopack-ecmascript = { workspace = true } turbopack-ecmascript = { workspace = true }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
use anyhow::Result; use anyhow::Result;
use mdxjs::{MdxParseOptions, Options, compile}; use mdxjs::{MdxParseOptions, Options, compile};
use serde::Deserialize;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, ValueDefault, Vc}; use turbo_tasks::{ResolvedVc, ValueDefault, Vc};
use turbo_tasks_fs::{File, FileContent, FileSystemPath, rope::Rope}; use turbo_tasks_fs::{File, FileContent, FileSystemPath, rope::Rope};
...@@ -20,7 +21,7 @@ use turbopack_core::{ ...@@ -20,7 +21,7 @@ use turbopack_core::{
}; };
#[turbo_tasks::value(shared, operation)] #[turbo_tasks::value(shared, operation)]
#[derive(Hash, Debug, Clone)] #[derive(Hash, Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub enum MdxParseConstructs { pub enum MdxParseConstructs {
Commonmark, Commonmark,
...@@ -31,7 +32,7 @@ pub enum MdxParseConstructs { ...@@ -31,7 +32,7 @@ pub enum MdxParseConstructs {
/// into mdxjs. This is thin, near straightforward subset of mdxjs::Options to /// into mdxjs. This is thin, near straightforward subset of mdxjs::Options to
/// enable turbo tasks. /// enable turbo tasks.
#[turbo_tasks::value(shared, operation)] #[turbo_tasks::value(shared, operation)]
#[derive(Hash, Debug, Clone)] #[derive(Hash, Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase", default)] #[serde(rename_all = "camelCase", default)]
pub struct MdxTransformOptions { pub struct MdxTransformOptions {
pub development: Option<bool>, pub development: Option<bool>,
......
...@@ -8,6 +8,7 @@ use anyhow::Result; ...@@ -8,6 +8,7 @@ use anyhow::Result;
use const_format::concatcp; use const_format::concatcp;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use serde::Deserialize;
use turbo_tasks::{ReadRef, Vc}; use turbo_tasks::{ReadRef, Vc};
use turbo_tasks_fs::{ use turbo_tasks_fs::{
FileLinesContent, FileSystemPath, source_context::get_source_context, to_sys_path, FileLinesContent, FileSystemPath, source_context::get_source_context, to_sys_path,
...@@ -264,7 +265,7 @@ async fn resolve_source_mapping( ...@@ -264,7 +265,7 @@ async fn resolve_source_mapping(
} }
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Clone, Debug)] #[derive(Clone, Debug, Deserialize)]
pub struct StructuredError { pub struct StructuredError {
pub name: String, pub name: String,
pub message: String, pub message: String,
......
...@@ -36,7 +36,7 @@ use crate::{ ...@@ -36,7 +36,7 @@ use crate::{
}, },
}; };
#[derive(Debug, Clone)] #[derive(Debug, Clone, Deserialize)]
#[turbo_tasks::value] #[turbo_tasks::value]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct PostCssProcessingResult { struct PostCssProcessingResult {
......
...@@ -69,7 +69,7 @@ struct BytesBase64 { ...@@ -69,7 +69,7 @@ struct BytesBase64 {
binary: Vec<u8>, binary: Vec<u8>,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[turbo_tasks::value] #[turbo_tasks::value]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct WebpackLoadersProcessingResult { struct WebpackLoadersProcessingResult {
...@@ -442,19 +442,7 @@ pub enum ResponseMessage { ...@@ -442,19 +442,7 @@ pub enum ResponseMessage {
TrackFileRead {}, TrackFileRead {},
} }
#[derive( #[derive(Clone, PartialEq, Eq, Hash, TaskInput, Debug, TraceRawVcs, Encode, Decode)]
Clone,
PartialEq,
Eq,
Hash,
TaskInput,
Serialize,
Deserialize,
Debug,
TraceRawVcs,
Encode,
Decode,
)]
pub struct WebpackLoaderContext { pub struct WebpackLoaderContext {
pub entries: ResolvedVc<EvaluateEntries>, pub entries: ResolvedVc<EvaluateEntries>,
pub cwd: FileSystemPath, pub cwd: FileSystemPath,
......
...@@ -14,66 +14,48 @@ use turbopack_core::{ ...@@ -14,66 +14,48 @@ use turbopack_core::{
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Default, Clone)] #[derive(Default, Clone)]
pub struct ResolveOptionsContext { pub struct ResolveOptionsContext {
#[serde(default)]
pub emulate_environment: Option<ResolvedVc<Environment>>, pub emulate_environment: Option<ResolvedVc<Environment>>,
#[serde(default)]
pub enable_types: bool, pub enable_types: bool,
#[serde(default)]
pub enable_typescript: bool, pub enable_typescript: bool,
#[serde(default)]
pub enable_react: bool, pub enable_react: bool,
#[serde(default)]
pub enable_node_native_modules: bool, pub enable_node_native_modules: bool,
#[serde(default)]
// Enable resolving of .mjs files without the .mjs extension // Enable resolving of .mjs files without the .mjs extension
pub enable_mjs_extension: bool, pub enable_mjs_extension: bool,
#[serde(default)]
/// Enable resolving of the node_modules folder when within the provided /// Enable resolving of the node_modules folder when within the provided
/// directory /// directory
pub enable_node_modules: Option<FileSystemPath>, pub enable_node_modules: Option<FileSystemPath>,
#[serde(default)]
/// A specific path to a tsconfig.json file to use for resolving modules. If `None`, one will /// A specific path to a tsconfig.json file to use for resolving modules. If `None`, one will
/// be looked up through the filesystem /// be looked up through the filesystem
pub tsconfig_path: Option<FileSystemPath>, pub tsconfig_path: Option<FileSystemPath>,
#[serde(default)]
/// Mark well-known Node.js modules as external imports and load them using /// Mark well-known Node.js modules as external imports and load them using
/// native `require`. e.g. url, querystring, os /// native `require`. e.g. url, querystring, os
pub enable_node_externals: bool, pub enable_node_externals: bool,
/// Mark well-known Edge modules as external imports and load them using /// Mark well-known Edge modules as external imports and load them using
/// native `require`. e.g. buffer, events, assert /// native `require`. e.g. buffer, events, assert
pub enable_edge_node_externals: bool, pub enable_edge_node_externals: bool,
#[serde(default)]
/// Enables the "browser" field and export condition in package.json /// Enables the "browser" field and export condition in package.json
pub browser: bool, pub browser: bool,
#[serde(default)]
/// Enables the "module" field and export condition in package.json /// Enables the "module" field and export condition in package.json
pub module: bool, pub module: bool,
#[serde(default)]
pub custom_conditions: Vec<RcStr>, pub custom_conditions: Vec<RcStr>,
#[serde(default)]
pub custom_extensions: Option<Vec<RcStr>>, pub custom_extensions: Option<Vec<RcStr>>,
#[serde(default)]
/// An additional import map to use when resolving modules. /// An additional import map to use when resolving modules.
/// ///
/// If set, this import map will be applied to `ResolveOption::import_map`. /// If set, this import map will be applied to `ResolveOption::import_map`.
/// It is always applied last, so any mapping defined within will take /// It is always applied last, so any mapping defined within will take
/// precedence over any other (e.g. tsconfig.json `compilerOptions.paths`). /// precedence over any other (e.g. tsconfig.json `compilerOptions.paths`).
pub import_map: Option<ResolvedVc<ImportMap>>, pub import_map: Option<ResolvedVc<ImportMap>>,
#[serde(default)]
/// An import map to fall back to when a request could not be resolved. /// An import map to fall back to when a request could not be resolved.
/// ///
/// If set, this import map will be applied to /// If set, this import map will be applied to
/// `ResolveOption::fallback_import_map`. It is always applied last, so /// `ResolveOption::fallback_import_map`. It is always applied last, so
/// any mapping defined within will take precedence over any other. /// any mapping defined within will take precedence over any other.
pub fallback_import_map: Option<ResolvedVc<ImportMap>>, pub fallback_import_map: Option<ResolvedVc<ImportMap>>,
#[serde(default)]
/// An additional resolved map to use after modules have been resolved. /// An additional resolved map to use after modules have been resolved.
pub resolved_map: Option<ResolvedVc<ResolvedMap>>, pub resolved_map: Option<ResolvedVc<ResolvedMap>>,
#[serde(default)]
/// A list of rules to use a different resolve option context for certain /// A list of rules to use a different resolve option context for certain
/// context paths. The first matching is used. /// context paths. The first matching is used.
pub rules: Vec<(ContextCondition, ResolvedVc<ResolveOptionsContext>)>, pub rules: Vec<(ContextCondition, ResolvedVc<ResolveOptionsContext>)>,
#[serde(default)]
/// Plugins which get applied before and after resolving. /// Plugins which get applied before and after resolving.
pub after_resolve_plugins: Vec<ResolvedVc<Box<dyn AfterResolvePlugin>>>, pub after_resolve_plugins: Vec<ResolvedVc<Box<dyn AfterResolvePlugin>>>,
pub before_resolve_plugins: Vec<ResolvedVc<Box<dyn BeforeResolvePlugin>>>, pub before_resolve_plugins: Vec<ResolvedVc<Box<dyn BeforeResolvePlugin>>>,
...@@ -82,7 +64,6 @@ pub struct ResolveOptionsContext { ...@@ -82,7 +64,6 @@ pub struct ResolveOptionsContext {
/// Collect affecting sources for each resolve result. Useful for tracing. /// Collect affecting sources for each resolve result. Useful for tracing.
pub collect_affecting_sources: bool, pub collect_affecting_sources: bool,
#[serde(default)]
pub placeholder_for_future_extensions: (), pub placeholder_for_future_extensions: (),
} }
......
...@@ -69,7 +69,7 @@ struct RunTestResult { ...@@ -69,7 +69,7 @@ struct RunTestResult {
} }
#[turbo_tasks::value] #[turbo_tasks::value]
#[derive(Clone)] #[derive(Clone, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct JsResult { struct JsResult {
uncaught_exceptions: Vec<String>, uncaught_exceptions: Vec<String>,
......
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
use turbo_tasks::{NonLocalValue, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, trace::TraceRawVcs};
use turbopack_core::reference_type::ReferenceType; use turbopack_core::reference_type::ReferenceType;
#[derive( #[derive(Copy, Clone, Debug, PartialEq, Eq, TraceRawVcs, NonLocalValue, Encode, Decode)]
Copy,
Clone,
Debug,
PartialEq,
Eq,
Serialize,
Deserialize,
TraceRawVcs,
NonLocalValue,
Encode,
Decode,
)]
pub enum MatchMode { pub enum MatchMode {
// Match all but internal references. // Match all but internal references.
NonInternal, NonInternal,
......
...@@ -22,9 +22,7 @@ use turbopack_node::{ ...@@ -22,9 +22,7 @@ use turbopack_node::{
use super::ModuleRule; use super::ModuleRule;
use crate::module_options::RuleCondition; use crate::module_options::RuleCondition;
#[derive( #[derive(Clone, PartialEq, Eq, Debug, TraceRawVcs, NonLocalValue, Encode, Decode)]
Clone, PartialEq, Eq, Debug, TraceRawVcs, Serialize, Deserialize, NonLocalValue, Encode, Decode,
)]
pub struct LoaderRuleItem { pub struct LoaderRuleItem {
pub loaders: ResolvedVc<WebpackLoaderItems>, pub loaders: ResolvedVc<WebpackLoaderItems>,
pub rename_as: Option<RcStr>, pub rename_as: Option<RcStr>,
...@@ -182,7 +180,6 @@ pub struct ExternalsTracingOptions { ...@@ -182,7 +180,6 @@ pub struct ExternalsTracingOptions {
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Clone, Default)] #[derive(Clone, Default)]
#[serde(default)]
pub struct ModuleOptionsContext { pub struct ModuleOptionsContext {
pub ecmascript: EcmascriptOptionsContext, pub ecmascript: EcmascriptOptionsContext,
pub css: CssOptionsContext, pub css: CssOptionsContext,
...@@ -223,7 +220,6 @@ pub struct ModuleOptionsContext { ...@@ -223,7 +220,6 @@ pub struct ModuleOptionsContext {
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Clone, Default)] #[derive(Clone, Default)]
#[serde(default)]
pub struct EcmascriptOptionsContext { pub struct EcmascriptOptionsContext {
// TODO this should just be handled via CompileTimeInfo FreeVarReferences, but then it // TODO this should just be handled via CompileTimeInfo FreeVarReferences, but then it
// (currently) wouldn't be possible to have different replacement values in user code vs // (currently) wouldn't be possible to have different replacement values in user code vs
...@@ -260,7 +256,6 @@ pub struct EcmascriptOptionsContext { ...@@ -260,7 +256,6 @@ pub struct EcmascriptOptionsContext {
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Clone, Default)] #[derive(Clone, Default)]
#[serde(default)]
pub struct CssOptionsContext { pub struct CssOptionsContext {
/// This skips `GlobalCss` and `ModuleCss` module assets from being /// This skips `GlobalCss` and `ModuleCss` module assets from being
/// generated in the module graph, generating only `Css` module assets. /// generated in the module graph, generating only `Css` module assets.
......
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{NonLocalValue, ResolvedVc, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, ResolvedVc, trace::TraceRawVcs};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
...@@ -12,11 +11,9 @@ use turbopack_css::CssModuleAssetType; ...@@ -12,11 +11,9 @@ use turbopack_css::CssModuleAssetType;
use turbopack_ecmascript::{EcmascriptInputTransforms, EcmascriptOptions}; use turbopack_ecmascript::{EcmascriptInputTransforms, EcmascriptOptions};
use turbopack_wasm::source::WebAssemblySourceType; use turbopack_wasm::source::WebAssemblySourceType;
use super::{CustomModuleType, RuleCondition, match_mode::MatchMode}; use crate::module_options::{CustomModuleType, RuleCondition, match_mode::MatchMode};
#[derive( #[derive(Debug, Clone, TraceRawVcs, PartialEq, Eq, NonLocalValue, Encode, Decode)]
Debug, Clone, Serialize, Deserialize, TraceRawVcs, PartialEq, Eq, NonLocalValue, Encode, Decode,
)]
pub struct ModuleRule { pub struct ModuleRule {
condition: RuleCondition, condition: RuleCondition,
effects: Vec<ModuleRuleEffect>, effects: Vec<ModuleRuleEffect>,
......
...@@ -6,7 +6,6 @@ use std::{ ...@@ -6,7 +6,6 @@ use std::{
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use either::Either; use either::Either;
use serde::{Deserialize, Serialize};
use smallvec::SmallVec; use smallvec::SmallVec;
use turbo_esregex::EsRegex; use turbo_esregex::EsRegex;
use turbo_tasks::{NonLocalValue, ReadRef, ResolvedVc, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, ReadRef, ResolvedVc, trace::TraceRawVcs};
...@@ -15,9 +14,7 @@ use turbopack_core::{ ...@@ -15,9 +14,7 @@ use turbopack_core::{
asset::Asset, reference_type::ReferenceType, source::Source, virtual_source::VirtualSource, asset::Asset, reference_type::ReferenceType, source::Source, virtual_source::VirtualSource,
}; };
#[derive( #[derive(Debug, Clone, TraceRawVcs, PartialEq, Eq, NonLocalValue, Encode, Decode)]
Debug, Clone, Serialize, Deserialize, TraceRawVcs, PartialEq, Eq, NonLocalValue, Encode, Decode,
)]
pub enum RuleCondition { pub enum RuleCondition {
All(Vec<RuleCondition>), All(Vec<RuleCondition>),
Any(Vec<RuleCondition>), Any(Vec<RuleCondition>),
......
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
use turbo_tasks::{NonLocalValue, ResolvedVc, trace::TraceRawVcs}; use turbo_tasks::{NonLocalValue, ResolvedVc, trace::TraceRawVcs};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbopack_core::{reference_type::ReferenceType, source::Source}; use turbopack_core::{reference_type::ReferenceType, source::Source};
...@@ -10,9 +9,7 @@ use crate::{ ...@@ -10,9 +9,7 @@ use crate::{
transition::Transition, transition::Transition,
}; };
#[derive( #[derive(Debug, Clone, TraceRawVcs, PartialEq, Eq, NonLocalValue, Encode, Decode)]
Debug, Clone, Serialize, Deserialize, TraceRawVcs, PartialEq, Eq, NonLocalValue, Encode, Decode,
)]
pub struct TransitionRule { pub struct TransitionRule {
condition: RuleCondition, condition: RuleCondition,
transition: ResolvedVc<Box<dyn Transition>>, transition: ResolvedVc<Box<dyn Transition>>,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment