Skip to content

Commit

Permalink
chore(turbopack): Delete a bunch of dead/unused structs
Browse files Browse the repository at this point in the history
  • Loading branch information
bgw committed Oct 11, 2024
1 parent 57a4e5c commit 8920a1b
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 124 deletions.
17 changes: 1 addition & 16 deletions turbopack/crates/turbopack-core/src/module.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use indexmap::IndexSet;
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks::Vc;

use crate::{asset::Asset, ident::AssetIdent, reference::ModuleReferences};

Expand Down Expand Up @@ -35,17 +34,3 @@ impl Modules {
Vc::cell(Vec::new())
}
}

/// A set of [Module]s
#[turbo_tasks::value(transparent)]
pub struct ModulesSet(IndexSet<ResolvedVc<Box<dyn Module>>>);

#[turbo_tasks::value_impl]
impl ModulesSet {
#[turbo_tasks::function]
pub fn empty() -> Vc<Self> {
Vc::cell(IndexSet::new())
}
}

// TODO All Vc::try_resolve_downcast::<Box<dyn Module>> calls should be removed
21 changes: 1 addition & 20 deletions turbopack/crates/turbopack-core/src/resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -370,22 +368,6 @@ impl ModuleResolveResult {
}
}

#[turbo_tasks::value(transparent)]
pub struct ModuleResolveResultOption(Option<ResolvedVc<ModuleResolveResult>>);

#[turbo_tasks::value_impl]
impl ModuleResolveResultOption {
#[turbo_tasks::function]
pub fn some(result: ResolvedVc<ModuleResolveResult>) -> Vc<Self> {
ModuleResolveResultOption(Some(result)).cell()
}

#[turbo_tasks::function]
pub fn none() -> Vc<Self> {
ModuleResolveResultOption(None).cell()
}
}

#[derive(
Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize, TraceRawVcs, TaskInput,
)]
Expand Down Expand Up @@ -1293,7 +1275,6 @@ async fn find_package(
}
}
}
ResolveModules::Registry(_, _) => todo!(),
}
}
Ok(FindPackageResult::cell(FindPackageResult {
Expand Down
7 changes: 1 addition & 6 deletions turbopack/crates/turbopack-core/src/resolve/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -38,10 +37,6 @@ pub enum ResolveModules {
dir: Vc<FileSystemPath>,
excluded_extensions: Vc<ExcludedExtensions>,
},
/// lookup versions based on lockfile in the registry filesystem
/// registry filesystem is assumed to have structure like
/// @scope/module/version/<path-in-package>
Registry(ResolvedVc<FileSystemPath>, ResolvedVc<LockedVersions>),
}

#[derive(TraceRawVcs, Hash, PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)]
Expand Down
6 changes: 1 addition & 5 deletions turbopack/crates/turbopack-core/src/source_map/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -56,9 +55,6 @@ pub enum SourceMap {
Sectioned(#[turbo_tasks(trace_ignore)] SectionedSourceMap),
}

#[turbo_tasks::value(transparent)]
pub struct SectionMapping(IndexMap<String, ResolvedVc<Box<dyn GenerateSourceMap>>>);

#[turbo_tasks::value(transparent)]
pub struct OptionSourceMap(Option<Vc<SourceMap>>);

Expand Down
8 changes: 1 addition & 7 deletions turbopack/crates/turbopack-css/src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -36,9 +36,6 @@ pub struct CssChunk {
pub content: Vc<CssChunkContent>,
}

#[turbo_tasks::value(transparent)]
pub struct CssChunks(Vec<ResolvedVc<CssChunk>>);

#[turbo_tasks::value_impl]
impl CssChunk {
#[turbo_tasks::function]
Expand Down Expand Up @@ -350,9 +347,6 @@ impl CssChunkContext {
#[turbo_tasks::value_trait]
pub trait CssChunkPlaceable: ChunkableModule + Module + Asset {}

#[turbo_tasks::value(transparent)]
pub struct CssChunkPlaceables(Vec<ResolvedVc<Box<dyn CssChunkPlaceable>>>);

#[derive(Clone, Debug)]
#[turbo_tasks::value(shared)]
pub enum CssImport {
Expand Down
5 changes: 1 addition & 4 deletions turbopack/crates/turbopack-css/src/code_gen.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks::Vc;
use turbopack_core::chunk::ChunkingContext;

use crate::chunk::CssImport;
Expand All @@ -24,6 +24,3 @@ pub trait CodeGenerateable {
chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Vc<CodeGeneration>;
}

#[turbo_tasks::value(transparent)]
pub struct CodeGenerateables(Vec<ResolvedVc<Box<dyn CodeGenerateable>>>);
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -25,9 +25,6 @@ pub enum EmotionLabelKind {
Never,
}

#[turbo_tasks::value(transparent)]
pub struct OptionEmotionTransformConfig(Option<ResolvedVc<EmotionTransformConfig>>);

//[TODO]: need to support importmap, there are type mismatch between
//next.config.js to swc's emotion options
#[turbo_tasks::value(shared)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResolvedVc<StyledComponentsTransformConfig>>,
);

#[turbo_tasks::value(shared)]
#[derive(Clone, Debug)]
#[serde(default, rename_all = "camelCase")]
Expand Down
8 changes: 1 addition & 7 deletions turbopack/crates/turbopack-ecmascript/src/chunk/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -264,9 +264,3 @@ async fn module_factory_with_code_generation_issue(
},
)
}

#[turbo_tasks::value(transparent)]
pub struct EcmascriptChunkItemsChunk(Vec<ResolvedVc<Box<dyn EcmascriptChunkItem>>>);

#[turbo_tasks::value(transparent)]
pub struct EcmascriptChunkItems(pub(super) Vec<ResolvedVc<Box<dyn EcmascriptChunkItem>>>);
7 changes: 2 additions & 5 deletions turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -30,7 +30,7 @@ pub use self::{
EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkItemExt,
EcmascriptChunkItemOptions,
},
placeable::{EcmascriptChunkPlaceable, EcmascriptChunkPlaceables, EcmascriptExports},
placeable::{EcmascriptChunkPlaceable, EcmascriptExports},
};

#[turbo_tasks::value]
Expand All @@ -39,9 +39,6 @@ pub struct EcmascriptChunk {
pub content: Vc<EcmascriptChunkContent>,
}

#[turbo_tasks::value(transparent)]
pub struct EcmascriptChunks(Vec<ResolvedVc<EcmascriptChunk>>);

#[turbo_tasks::value_impl]
impl EcmascriptChunk {
#[turbo_tasks::function]
Expand Down
13 changes: 1 addition & 12 deletions turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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<ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>>);

#[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceables {
#[turbo_tasks::function]
pub fn empty() -> Vc<Self> {
Vc::cell(Vec::new())
}
}

#[turbo_tasks::value(shared)]
pub enum EcmascriptExports {
EsmExports(Vc<EsmExports>),
Expand Down
12 changes: 2 additions & 10 deletions turbopack/crates/turbopack-ecmascript/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -281,14 +281,6 @@ pub trait EcmascriptAnalyzable {
) -> Result<Vc<EcmascriptModuleContent>>;
}

/// An optional [EcmascriptModuleAsset]
#[turbo_tasks::value(transparent)]
pub struct OptionEcmascriptModuleAsset(Option<ResolvedVc<EcmascriptModuleAsset>>);

/// A list of [EcmascriptModuleAsset]s
#[turbo_tasks::value(transparent)]
pub struct EcmascriptModuleAssets(Vec<ResolvedVc<EcmascriptModuleAsset>>);

impl EcmascriptModuleAsset {
pub fn builder(
source: Vc<Box<dyn Source>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -104,10 +104,6 @@ pub struct EsmAssetReference {
pub import_externals: bool,
}

/// A list of [EsmAssetReference]s
#[turbo_tasks::value(transparent)]
pub struct EsmAssetReferences(Vec<ResolvedVc<EsmAssetReference>>);

impl EsmAssetReference {
fn get_origin(&self) -> Vc<Box<dyn ResolveOrigin>> {
let mut origin = self.origin;
Expand Down
13 changes: 1 addition & 12 deletions turbopack/crates/turbopack-ecmascript/src/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -81,17 +81,6 @@ pub trait CustomTransformer: Debug {
#[derive(Debug)]
pub struct TransformPlugin(#[turbo_tasks(trace_ignore)] Box<dyn CustomTransformer + Send + Sync>);

#[turbo_tasks::value(transparent)]
pub struct OptionTransformPlugin(Option<ResolvedVc<TransformPlugin>>);

#[turbo_tasks::value_impl]
impl ValueDefault for OptionTransformPlugin {
#[turbo_tasks::function]
fn value_default() -> Vc<Self> {
Vc::cell(None)
}
}

#[async_trait]
impl CustomTransformer for TransformPlugin {
async fn transform(&self, program: &mut Program, ctx: &TransformContext<'_>) -> Result<()> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
};
Expand Down Expand Up @@ -34,10 +34,6 @@ pub struct WebpackLoadersOptions {
pub loader_runner_package: Option<Vc<ImportMapping>>,
}

#[derive(Default)]
#[turbo_tasks::value(transparent)]
pub struct OptionWebpackLoadersOptions(Option<ResolvedVc<WebpackLoadersOptions>>);

/// The kind of decorators transform to use.
/// [TODO]: might need bikeshed for the name (Ecma)
#[derive(Clone, PartialEq, Eq, Debug, TraceRawVcs, Serialize, Deserialize)]
Expand Down

0 comments on commit 8920a1b

Please sign in to comment.