From 8920a1b93c9d848bbcbd97090e353b80409fae3f Mon Sep 17 00:00:00 2001 From: Benjamin Woodruff Date: Tue, 8 Oct 2024 14:27:59 -0700 Subject: [PATCH] chore(turbopack): Delete a bunch of dead/unused structs --- turbopack/crates/turbopack-core/src/module.rs | 17 +-------------- .../crates/turbopack-core/src/resolve/mod.rs | 21 +------------------ .../turbopack-core/src/resolve/options.rs | 7 +------ .../turbopack-core/src/source_map/mod.rs | 6 +----- .../crates/turbopack-css/src/chunk/mod.rs | 8 +------ .../crates/turbopack-css/src/code_gen.rs | 5 +---- .../src/transform/emotion.rs | 5 +---- .../src/transform/styled_components.rs | 7 +------ .../turbopack-ecmascript/src/chunk/item.rs | 8 +------ .../turbopack-ecmascript/src/chunk/mod.rs | 7 ++----- .../src/chunk/placeable.rs | 13 +----------- .../crates/turbopack-ecmascript/src/lib.rs | 12 ++--------- .../src/references/esm/base.rs | 6 +----- .../turbopack-ecmascript/src/transform/mod.rs | 13 +----------- .../module_options/module_options_context.rs | 6 +----- 15 files changed, 17 insertions(+), 124 deletions(-) diff --git a/turbopack/crates/turbopack-core/src/module.rs b/turbopack/crates/turbopack-core/src/module.rs index 7130e282e6f5e..994e43e14496a 100644 --- a/turbopack/crates/turbopack-core/src/module.rs +++ b/turbopack/crates/turbopack-core/src/module.rs @@ -1,5 +1,4 @@ -use indexmap::IndexSet; -use turbo_tasks::{ResolvedVc, Vc}; +use turbo_tasks::Vc; use crate::{asset::Asset, ident::AssetIdent, reference::ModuleReferences}; @@ -35,17 +34,3 @@ impl Modules { Vc::cell(Vec::new()) } } - -/// A set of [Module]s -#[turbo_tasks::value(transparent)] -pub struct ModulesSet(IndexSet>>); - -#[turbo_tasks::value_impl] -impl ModulesSet { - #[turbo_tasks::function] - pub fn empty() -> Vc { - Vc::cell(IndexSet::new()) - } -} - -// TODO All Vc::try_resolve_downcast::> calls should be removed diff --git a/turbopack/crates/turbopack-core/src/resolve/mod.rs b/turbopack/crates/turbopack-core/src/resolve/mod.rs index 627143b550311..92c6a2554d2c1 100644 --- a/turbopack/crates/turbopack-core/src/resolve/mod.rs +++ b/turbopack/crates/turbopack-core/src/resolve/mod.rs @@ -10,9 +10,7 @@ use anyhow::{bail, Result}; use indexmap::{indexmap, IndexMap, IndexSet}; use serde::{Deserialize, Serialize}; use tracing::{Instrument, Level}; -use turbo_tasks::{ - trace::TraceRawVcs, RcStr, ResolvedVc, TaskInput, TryJoinIterExt, Value, ValueToString, Vc, -}; +use turbo_tasks::{trace::TraceRawVcs, RcStr, TaskInput, TryJoinIterExt, Value, ValueToString, Vc}; use turbo_tasks_fs::{ util::normalize_request, FileSystemEntryType, FileSystemPath, RealPathResult, }; @@ -370,22 +368,6 @@ impl ModuleResolveResult { } } -#[turbo_tasks::value(transparent)] -pub struct ModuleResolveResultOption(Option>); - -#[turbo_tasks::value_impl] -impl ModuleResolveResultOption { - #[turbo_tasks::function] - pub fn some(result: ResolvedVc) -> Vc { - ModuleResolveResultOption(Some(result)).cell() - } - - #[turbo_tasks::function] - pub fn none() -> Vc { - ModuleResolveResultOption(None).cell() - } -} - #[derive( Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize, TraceRawVcs, TaskInput, )] @@ -1293,7 +1275,6 @@ async fn find_package( } } } - ResolveModules::Registry(_, _) => todo!(), } } Ok(FindPackageResult::cell(FindPackageResult { diff --git a/turbopack/crates/turbopack-core/src/resolve/options.rs b/turbopack/crates/turbopack-core/src/resolve/options.rs index f9937f25b6409..051f26e11a60c 100644 --- a/turbopack/crates/turbopack-core/src/resolve/options.rs +++ b/turbopack/crates/turbopack-core/src/resolve/options.rs @@ -4,8 +4,7 @@ use anyhow::{bail, Result}; use indexmap::IndexSet; use serde::{Deserialize, Serialize}; use turbo_tasks::{ - debug::ValueDebugFormat, trace::TraceRawVcs, RcStr, ResolvedVc, TryJoinIterExt, Value, - ValueToString, Vc, + debug::ValueDebugFormat, trace::TraceRawVcs, RcStr, TryJoinIterExt, Value, ValueToString, Vc, }; use turbo_tasks_fs::{glob::Glob, FileSystemPath}; @@ -38,10 +37,6 @@ pub enum ResolveModules { dir: Vc, excluded_extensions: Vc, }, - /// lookup versions based on lockfile in the registry filesystem - /// registry filesystem is assumed to have structure like - /// @scope/module/version/ - Registry(ResolvedVc, ResolvedVc), } #[derive(TraceRawVcs, Hash, PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] diff --git a/turbopack/crates/turbopack-core/src/source_map/mod.rs b/turbopack/crates/turbopack-core/src/source_map/mod.rs index 3815b9829b9bd..322980c8b9d1d 100644 --- a/turbopack/crates/turbopack-core/src/source_map/mod.rs +++ b/turbopack/crates/turbopack-core/src/source_map/mod.rs @@ -1,13 +1,12 @@ use std::{borrow::Cow, io::Write, ops::Deref, sync::Arc}; use anyhow::Result; -use indexmap::IndexMap; use once_cell::sync::Lazy; use ref_cast::RefCast; use regex::Regex; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use sourcemap::{DecodedMap, SourceMap as RegularMap, SourceMapBuilder, SourceMapIndex}; -use turbo_tasks::{RcStr, ResolvedVc, TryJoinIterExt, ValueToString, Vc}; +use turbo_tasks::{RcStr, TryJoinIterExt, ValueToString, Vc}; use turbo_tasks_fs::{ rope::{Rope, RopeBuilder}, File, FileContent, FileSystem, FileSystemPath, VirtualFileSystem, @@ -56,9 +55,6 @@ pub enum SourceMap { Sectioned(#[turbo_tasks(trace_ignore)] SectionedSourceMap), } -#[turbo_tasks::value(transparent)] -pub struct SectionMapping(IndexMap>>); - #[turbo_tasks::value(transparent)] pub struct OptionSourceMap(Option>); diff --git a/turbopack/crates/turbopack-css/src/chunk/mod.rs b/turbopack/crates/turbopack-css/src/chunk/mod.rs index 446479fde9437..8afff56a2c490 100644 --- a/turbopack/crates/turbopack-css/src/chunk/mod.rs +++ b/turbopack/crates/turbopack-css/src/chunk/mod.rs @@ -5,7 +5,7 @@ use std::fmt::Write; use anyhow::{bail, Result}; use indexmap::IndexSet; -use turbo_tasks::{RcStr, ResolvedVc, TryJoinIterExt, Value, ValueDefault, ValueToString, Vc}; +use turbo_tasks::{RcStr, TryJoinIterExt, Value, ValueDefault, ValueToString, Vc}; use turbo_tasks_fs::{rope::Rope, File, FileSystem}; use turbopack_core::{ asset::{Asset, AssetContent}, @@ -36,9 +36,6 @@ pub struct CssChunk { pub content: Vc, } -#[turbo_tasks::value(transparent)] -pub struct CssChunks(Vec>); - #[turbo_tasks::value_impl] impl CssChunk { #[turbo_tasks::function] @@ -350,9 +347,6 @@ impl CssChunkContext { #[turbo_tasks::value_trait] pub trait CssChunkPlaceable: ChunkableModule + Module + Asset {} -#[turbo_tasks::value(transparent)] -pub struct CssChunkPlaceables(Vec>>); - #[derive(Clone, Debug)] #[turbo_tasks::value(shared)] pub enum CssImport { diff --git a/turbopack/crates/turbopack-css/src/code_gen.rs b/turbopack/crates/turbopack-css/src/code_gen.rs index 71b562d64f366..6077eece5f384 100644 --- a/turbopack/crates/turbopack-css/src/code_gen.rs +++ b/turbopack/crates/turbopack-css/src/code_gen.rs @@ -1,4 +1,4 @@ -use turbo_tasks::{ResolvedVc, Vc}; +use turbo_tasks::Vc; use turbopack_core::chunk::ChunkingContext; use crate::chunk::CssImport; @@ -24,6 +24,3 @@ pub trait CodeGenerateable { chunking_context: Vc>, ) -> Vc; } - -#[turbo_tasks::value(transparent)] -pub struct CodeGenerateables(Vec>>); diff --git a/turbopack/crates/turbopack-ecmascript-plugins/src/transform/emotion.rs b/turbopack/crates/turbopack-ecmascript-plugins/src/transform/emotion.rs index 09b5e8ddac7d2..fe0c9aaf91641 100644 --- a/turbopack/crates/turbopack-ecmascript-plugins/src/transform/emotion.rs +++ b/turbopack/crates/turbopack-ecmascript-plugins/src/transform/emotion.rs @@ -14,7 +14,7 @@ use swc_core::{ visit::FoldWith, }, }; -use turbo_tasks::{trace::TraceRawVcs, ResolvedVc, ValueDefault, Vc}; +use turbo_tasks::{trace::TraceRawVcs, ValueDefault, Vc}; use turbopack_ecmascript::{CustomTransformer, TransformContext}; #[derive(Clone, PartialEq, Eq, Debug, TraceRawVcs, Serialize, Deserialize)] @@ -25,9 +25,6 @@ pub enum EmotionLabelKind { Never, } -#[turbo_tasks::value(transparent)] -pub struct OptionEmotionTransformConfig(Option>); - //[TODO]: need to support importmap, there are type mismatch between //next.config.js to swc's emotion options #[turbo_tasks::value(shared)] diff --git a/turbopack/crates/turbopack-ecmascript-plugins/src/transform/styled_components.rs b/turbopack/crates/turbopack-ecmascript-plugins/src/transform/styled_components.rs index 5b2da53785d65..88d3a0b5beba4 100644 --- a/turbopack/crates/turbopack-ecmascript-plugins/src/transform/styled_components.rs +++ b/turbopack/crates/turbopack-ecmascript-plugins/src/transform/styled_components.rs @@ -6,14 +6,9 @@ use swc_core::{ common::{comments::NoopComments, FileName}, ecma::{ast::Program, atoms::JsWord, visit::VisitMutWith}, }; -use turbo_tasks::{ResolvedVc, ValueDefault, Vc}; +use turbo_tasks::{ValueDefault, Vc}; use turbopack_ecmascript::{CustomTransformer, TransformContext}; -#[turbo_tasks::value(transparent)] -pub struct OptionStyledComponentsTransformConfig( - Option>, -); - #[turbo_tasks::value(shared)] #[derive(Clone, Debug)] #[serde(default, rename_all = "camelCase")] diff --git a/turbopack/crates/turbopack-ecmascript/src/chunk/item.rs b/turbopack/crates/turbopack-ecmascript/src/chunk/item.rs index 8b5fa404e5dca..4658192843e51 100644 --- a/turbopack/crates/turbopack-ecmascript/src/chunk/item.rs +++ b/turbopack/crates/turbopack-ecmascript/src/chunk/item.rs @@ -2,7 +2,7 @@ use std::io::Write; use anyhow::{bail, Result}; use serde::{Deserialize, Serialize}; -use turbo_tasks::{trace::TraceRawVcs, ResolvedVc, Upcast, ValueToString, Vc}; +use turbo_tasks::{trace::TraceRawVcs, Upcast, ValueToString, Vc}; use turbo_tasks_fs::rope::Rope; use turbopack_core::{ chunk::{AsyncModuleInfo, ChunkItem, ChunkItemExt, ChunkingContext}, @@ -264,9 +264,3 @@ async fn module_factory_with_code_generation_issue( }, ) } - -#[turbo_tasks::value(transparent)] -pub struct EcmascriptChunkItemsChunk(Vec>>); - -#[turbo_tasks::value(transparent)] -pub struct EcmascriptChunkItems(pub(super) Vec>>); diff --git a/turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs b/turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs index 89d0c2d8e580d..00ae0fe2633e4 100644 --- a/turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs @@ -7,7 +7,7 @@ pub(crate) mod placeable; use std::fmt::Write; use anyhow::{bail, Result}; -use turbo_tasks::{RcStr, ResolvedVc, Value, ValueToString, Vc}; +use turbo_tasks::{RcStr, Value, ValueToString, Vc}; use turbo_tasks_fs::FileSystem; use turbopack_core::{ asset::{Asset, AssetContent}, @@ -30,7 +30,7 @@ pub use self::{ EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkItemExt, EcmascriptChunkItemOptions, }, - placeable::{EcmascriptChunkPlaceable, EcmascriptChunkPlaceables, EcmascriptExports}, + placeable::{EcmascriptChunkPlaceable, EcmascriptExports}, }; #[turbo_tasks::value] @@ -39,9 +39,6 @@ pub struct EcmascriptChunk { pub content: Vc, } -#[turbo_tasks::value(transparent)] -pub struct EcmascriptChunks(Vec>); - #[turbo_tasks::value_impl] impl EcmascriptChunk { #[turbo_tasks::function] diff --git a/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs b/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs index 65e462ed15bb5..9fe28b18cceb8 100644 --- a/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs +++ b/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::{ResolvedVc, TryFlatJoinIterExt, Vc}; +use turbo_tasks::{TryFlatJoinIterExt, Vc}; use turbo_tasks_fs::{glob::Glob, FileJsonContent, FileSystemPath}; use turbopack_core::{ asset::Asset, @@ -188,17 +188,6 @@ pub async fn is_marked_as_side_effect_free( Ok(Vc::cell(false)) } -#[turbo_tasks::value(transparent)] -pub struct EcmascriptChunkPlaceables(Vec>>); - -#[turbo_tasks::value_impl] -impl EcmascriptChunkPlaceables { - #[turbo_tasks::function] - pub fn empty() -> Vc { - Vc::cell(Vec::new()) - } -} - #[turbo_tasks::value(shared)] pub enum EcmascriptExports { EsmExports(Vc), diff --git a/turbopack/crates/turbopack-ecmascript/src/lib.rs b/turbopack/crates/turbopack-ecmascript/src/lib.rs index 0f3c320b26dda..b5695d904a4dd 100644 --- a/turbopack/crates/turbopack-ecmascript/src/lib.rs +++ b/turbopack/crates/turbopack-ecmascript/src/lib.rs @@ -56,8 +56,8 @@ use swc_core::{ }, }; pub use transform::{ - CustomTransformer, EcmascriptInputTransform, EcmascriptInputTransforms, OptionTransformPlugin, - TransformContext, TransformPlugin, UnsupportedServerActionIssue, + CustomTransformer, EcmascriptInputTransform, EcmascriptInputTransforms, TransformContext, + TransformPlugin, UnsupportedServerActionIssue, }; use turbo_tasks::{ trace::TraceRawVcs, RcStr, ReadRef, ResolvedVc, TaskInput, TryJoinIterExt, Value, @@ -281,14 +281,6 @@ pub trait EcmascriptAnalyzable { ) -> Result>; } -/// An optional [EcmascriptModuleAsset] -#[turbo_tasks::value(transparent)] -pub struct OptionEcmascriptModuleAsset(Option>); - -/// A list of [EcmascriptModuleAsset]s -#[turbo_tasks::value(transparent)] -pub struct EcmascriptModuleAssets(Vec>); - impl EcmascriptModuleAsset { pub fn builder( source: Vc>, diff --git a/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs b/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs index 3b05a72d99c23..c030c622ac451 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs @@ -5,7 +5,7 @@ use swc_core::{ ecma::ast::{Decl, Expr, ExprStmt, Ident, Stmt}, quote, }; -use turbo_tasks::{RcStr, ResolvedVc, Value, ValueToString, Vc}; +use turbo_tasks::{RcStr, Value, ValueToString, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ chunk::{ @@ -104,10 +104,6 @@ pub struct EsmAssetReference { pub import_externals: bool, } -/// A list of [EsmAssetReference]s -#[turbo_tasks::value(transparent)] -pub struct EsmAssetReferences(Vec>); - impl EsmAssetReference { fn get_origin(&self) -> Vc> { let mut origin = self.origin; diff --git a/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs b/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs index ab188650e5686..264b011bb74fe 100644 --- a/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs @@ -18,7 +18,7 @@ use swc_core::{ }, quote, }; -use turbo_tasks::{RcStr, ResolvedVc, ValueDefault, Vc}; +use turbo_tasks::{RcStr, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ environment::Environment, @@ -81,17 +81,6 @@ pub trait CustomTransformer: Debug { #[derive(Debug)] pub struct TransformPlugin(#[turbo_tasks(trace_ignore)] Box); -#[turbo_tasks::value(transparent)] -pub struct OptionTransformPlugin(Option>); - -#[turbo_tasks::value_impl] -impl ValueDefault for OptionTransformPlugin { - #[turbo_tasks::function] - fn value_default() -> Vc { - Vc::cell(None) - } -} - #[async_trait] impl CustomTransformer for TransformPlugin { async fn transform(&self, program: &mut Program, ctx: &TransformContext<'_>) -> Result<()> { diff --git a/turbopack/crates/turbopack/src/module_options/module_options_context.rs b/turbopack/crates/turbopack/src/module_options/module_options_context.rs index 8eaaa725f193b..dbd8cbe9ad90a 100644 --- a/turbopack/crates/turbopack/src/module_options/module_options_context.rs +++ b/turbopack/crates/turbopack/src/module_options/module_options_context.rs @@ -1,6 +1,6 @@ use indexmap::IndexMap; use serde::{Deserialize, Serialize}; -use turbo_tasks::{trace::TraceRawVcs, RcStr, ResolvedVc, ValueDefault, Vc}; +use turbo_tasks::{trace::TraceRawVcs, RcStr, ValueDefault, Vc}; use turbopack_core::{ condition::ContextCondition, environment::Environment, resolve::options::ImportMapping, }; @@ -34,10 +34,6 @@ pub struct WebpackLoadersOptions { pub loader_runner_package: Option>, } -#[derive(Default)] -#[turbo_tasks::value(transparent)] -pub struct OptionWebpackLoadersOptions(Option>); - /// The kind of decorators transform to use. /// [TODO]: might need bikeshed for the name (Ecma) #[derive(Clone, PartialEq, Eq, Debug, TraceRawVcs, Serialize, Deserialize)]