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