From 57a4e5c93bd525fe36e83e3becd89119b7cb9107 Mon Sep 17 00:00:00 2001 From: Benjamin Woodruff Date: Fri, 11 Oct 2024 11:23:52 -0700 Subject: [PATCH] codemod(turbopack): Rewrite a few instances of Vc as ResolvedVc (#70927) First PR generated by https://github.com/vercel/turbopack-resolved-vc-codemod (private repo, hacky low-quality throw-away code) The codemod is only able to "fix" compilation errors by rewriting function arguments as `ResolvedVc`, so it's very limited right now, but it's able to make some progress. The codemod uses ast-grep's JS API to make all the changes: https://ast-grep.github.io/guide/api-usage/js-api.html I also evaluated gritql, but it didn't seem sufficient for this codemod: [Internal discussion](https://vercel.slack.com/archives/C03EWR7LGEN/p1727755062182179?thread_ts=1727709174.550549&cid=C03EWR7LGEN) It turns out that a lot of these structs are actually dead code, so #70987 is a follow-up to delete them. --- crates/next-core/src/next_client/runtime_entry.rs | 4 ++-- .../transforms/swc_ecma_transform_plugins.rs | 5 +---- turbopack/crates/turbo-tasks-env/src/dotenv.rs | 9 ++++++--- turbopack/crates/turbo-tasks-testing/tests/debug.rs | 4 ++-- turbopack/crates/turbopack-core/src/chunk/mod.rs | 5 +++-- turbopack/crates/turbopack-core/src/ident.rs | 8 ++++---- turbopack/crates/turbopack-core/src/issue/mod.rs | 4 ++-- turbopack/crates/turbopack-core/src/module.rs | 4 ++-- turbopack/crates/turbopack-core/src/resolve/mod.rs | 8 +++++--- .../crates/turbopack-core/src/resolve/options.rs | 5 +++-- turbopack/crates/turbopack-core/src/resolve/plugin.rs | 10 +++++----- turbopack/crates/turbopack-core/src/source_map/mod.rs | 4 ++-- turbopack/crates/turbopack-css/src/chunk/mod.rs | 6 +++--- turbopack/crates/turbopack-css/src/code_gen.rs | 4 ++-- .../crates/turbopack-dev-server/src/source/mod.rs | 11 ++++++----- .../src/transform/emotion.rs | 4 ++-- .../src/transform/styled_components.rs | 6 ++++-- .../src/transform/swc_ecma_transform_plugins.rs | 6 ++++-- .../crates/turbopack-ecmascript/src/chunk/item.rs | 6 +++--- .../crates/turbopack-ecmascript/src/chunk/mod.rs | 4 ++-- .../turbopack-ecmascript/src/chunk/placeable.rs | 4 ++-- turbopack/crates/turbopack-ecmascript/src/lib.rs | 11 ++++++----- .../turbopack-ecmascript/src/references/esm/base.rs | 4 ++-- .../crates/turbopack-ecmascript/src/transform/mod.rs | 4 ++-- turbopack/crates/turbopack/src/lib.rs | 6 +++--- .../src/module_options/module_options_context.rs | 4 ++-- 26 files changed, 80 insertions(+), 70 deletions(-) diff --git a/crates/next-core/src/next_client/runtime_entry.rs b/crates/next-core/src/next_client/runtime_entry.rs index 719d8895ed506..11e3a953c6bd1 100644 --- a/crates/next-core/src/next_client/runtime_entry.rs +++ b/crates/next-core/src/next_client/runtime_entry.rs @@ -1,5 +1,5 @@ use anyhow::{bail, Result}; -use turbo_tasks::{ValueToString, Vc}; +use turbo_tasks::{ResolvedVc, ValueToString, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ chunk::{EvaluatableAsset, EvaluatableAssetExt, EvaluatableAssets}, @@ -15,7 +15,7 @@ use turbopack_ecmascript::resolve::cjs_resolve; pub enum RuntimeEntry { Request(Vc, Vc), Evaluatable(Vc>), - Source(Vc>), + Source(ResolvedVc>), } #[turbo_tasks::value_impl] diff --git a/crates/next-core/src/next_shared/transforms/swc_ecma_transform_plugins.rs b/crates/next-core/src/next_shared/transforms/swc_ecma_transform_plugins.rs index bd31bf0f175db..88ef32ff997fa 100644 --- a/crates/next-core/src/next_shared/transforms/swc_ecma_transform_plugins.rs +++ b/crates/next-core/src/next_shared/transforms/swc_ecma_transform_plugins.rs @@ -97,10 +97,7 @@ pub async fn get_swc_ecma_transform_rule_impl( }; plugins.push(( - SwcPluginModule::cell(SwcPluginModule::new( - name, - file.content().to_bytes()?.to_vec(), - )), + SwcPluginModule::new(name, file.content().to_bytes()?.to_vec()).resolved_cell(), config.clone(), )); } diff --git a/turbopack/crates/turbo-tasks-env/src/dotenv.rs b/turbopack/crates/turbo-tasks-env/src/dotenv.rs index b77b473bde1fb..04289fb72ee9f 100644 --- a/turbopack/crates/turbo-tasks-env/src/dotenv.rs +++ b/turbopack/crates/turbo-tasks-env/src/dotenv.rs @@ -2,7 +2,7 @@ use std::{env, sync::MutexGuard}; use anyhow::{anyhow, Context, Result}; use indexmap::IndexMap; -use turbo_tasks::{RcStr, ValueToString, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, ValueToString, Vc}; use turbo_tasks_fs::{FileContent, FileSystemPath}; use crate::{sorted_env_vars, EnvMap, ProcessEnv, GLOBAL_ENV_LOCK}; @@ -12,14 +12,17 @@ use crate::{sorted_env_vars, EnvMap, ProcessEnv, GLOBAL_ENV_LOCK}; /// from. #[turbo_tasks::value] pub struct DotenvProcessEnv { - prior: Option>>, + prior: Option>>, path: Vc, } #[turbo_tasks::value_impl] impl DotenvProcessEnv { #[turbo_tasks::function] - pub fn new(prior: Option>>, path: Vc) -> Vc { + pub fn new( + prior: Option>>, + path: Vc, + ) -> Vc { DotenvProcessEnv { prior, path }.cell() } diff --git a/turbopack/crates/turbo-tasks-testing/tests/debug.rs b/turbopack/crates/turbo-tasks-testing/tests/debug.rs index ef042973771ac..fc44f7c56e8c3 100644 --- a/turbopack/crates/turbo-tasks-testing/tests/debug.rs +++ b/turbopack/crates/turbo-tasks-testing/tests/debug.rs @@ -4,7 +4,7 @@ use std::sync::Mutex; -use turbo_tasks::{debug::ValueDebug, Vc}; +use turbo_tasks::{debug::ValueDebug, ResolvedVc, Vc}; use turbo_tasks_testing::{register, run, Registration}; static REGISTRATION: Registration = register!(); @@ -177,7 +177,7 @@ struct StructWithTransparent { #[turbo_tasks::value(shared)] struct StructWithOption { - option: Option>, + option: Option>, } #[turbo_tasks::value(shared)] diff --git a/turbopack/crates/turbopack-core/src/chunk/mod.rs b/turbopack/crates/turbopack-core/src/chunk/mod.rs index 5e4d96fd224ef..830bbf8310ba0 100644 --- a/turbopack/crates/turbopack-core/src/chunk/mod.rs +++ b/turbopack/crates/turbopack-core/src/chunk/mod.rs @@ -25,7 +25,8 @@ use turbo_tasks::{ debug::ValueDebugFormat, graph::{AdjacencyMap, GraphTraversal, GraphTraversalResult, Visit, VisitControlFlow}, trace::TraceRawVcs, - RcStr, ReadRef, TaskInput, TryFlatJoinIterExt, TryJoinIterExt, Upcast, ValueToString, Vc, + RcStr, ReadRef, ResolvedVc, TaskInput, TryFlatJoinIterExt, TryJoinIterExt, Upcast, + ValueToString, Vc, }; use turbo_tasks_fs::FileSystemPath; use turbo_tasks_hash::DeterministicHash; @@ -137,7 +138,7 @@ pub trait Chunk: Asset { #[derive(Default)] pub struct OutputChunkRuntimeInfo { pub included_ids: Option>, - pub excluded_ids: Option>, + pub excluded_ids: Option>, /// List of paths of chunks containing individual modules that are part of /// this chunk. This is useful for selectively loading modules from a chunk /// without loading the whole chunk. diff --git a/turbopack/crates/turbopack-core/src/ident.rs b/turbopack/crates/turbopack-core/src/ident.rs index 4bb9d3964fa0e..d0174c788146f 100644 --- a/turbopack/crates/turbopack-core/src/ident.rs +++ b/turbopack/crates/turbopack-core/src/ident.rs @@ -1,7 +1,7 @@ use std::fmt::Write; use anyhow::Result; -use turbo_tasks::{RcStr, Value, ValueToString, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, Value, ValueToString, Vc}; use turbo_tasks_fs::FileSystemPath; use turbo_tasks_hash::{encode_hex, hash_xxh3_hash64, DeterministicHash, Xxh3Hash64Hasher}; @@ -15,13 +15,13 @@ pub struct AssetIdent { /// The query string of the asset (e.g. `?foo=bar`) pub query: Vc, /// The fragment of the asset (e.g. `#foo`) - pub fragment: Option>, + pub fragment: Option>, /// The assets that are nested in this asset pub assets: Vec<(Vc, Vc)>, /// The modifiers of this asset (e.g. `client chunks`) pub modifiers: Vec>, /// The part of the asset that is a (ECMAScript) module - pub part: Option>, + pub part: Option>, /// The asset layer the asset was created from. pub layer: Option>, } @@ -144,7 +144,7 @@ impl AssetIdent { } #[turbo_tasks::function] - pub fn with_part(&self, part: Vc) -> Vc { + pub fn with_part(&self, part: ResolvedVc) -> Vc { let mut this = self.clone(); this.part = Some(part); Self::new(Value::new(this)) diff --git a/turbopack/crates/turbopack-core/src/issue/mod.rs b/turbopack/crates/turbopack-core/src/issue/mod.rs index abda6a078c932..ffebdb4e21730 100644 --- a/turbopack/crates/turbopack-core/src/issue/mod.rs +++ b/turbopack/crates/turbopack-core/src/issue/mod.rs @@ -12,7 +12,7 @@ use async_trait::async_trait; use auto_hash_map::AutoSet; use serde::Serialize; use turbo_tasks::{ - emit, CollectiblesSource, RawVc, RcStr, ReadRef, TransientInstance, TransientValue, + emit, CollectiblesSource, RawVc, RcStr, ReadRef, ResolvedVc, TransientInstance, TransientValue, TryJoinIterExt, Upcast, ValueToString, Vc, }; use turbo_tasks_fs::{FileContent, FileLine, FileLinesContent, FileSystemPath}; @@ -353,7 +353,7 @@ where } #[turbo_tasks::value(transparent)] -pub struct Issues(Vec>>); +pub struct Issues(Vec>>); /// A list of issues captured with [`Issue::peek_issues_with_path`] and /// [`Issue::take_issues_with_path`]. diff --git a/turbopack/crates/turbopack-core/src/module.rs b/turbopack/crates/turbopack-core/src/module.rs index a3b40fec6d549..7130e282e6f5e 100644 --- a/turbopack/crates/turbopack-core/src/module.rs +++ b/turbopack/crates/turbopack-core/src/module.rs @@ -1,5 +1,5 @@ use indexmap::IndexSet; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use crate::{asset::Asset, ident::AssetIdent, reference::ModuleReferences}; @@ -38,7 +38,7 @@ impl Modules { /// A set of [Module]s #[turbo_tasks::value(transparent)] -pub struct ModulesSet(IndexSet>>); +pub struct ModulesSet(IndexSet>>); #[turbo_tasks::value_impl] impl ModulesSet { diff --git a/turbopack/crates/turbopack-core/src/resolve/mod.rs b/turbopack/crates/turbopack-core/src/resolve/mod.rs index 19d36b4153b6d..627143b550311 100644 --- a/turbopack/crates/turbopack-core/src/resolve/mod.rs +++ b/turbopack/crates/turbopack-core/src/resolve/mod.rs @@ -10,7 +10,9 @@ use anyhow::{bail, Result}; use indexmap::{indexmap, IndexMap, IndexSet}; use serde::{Deserialize, Serialize}; use tracing::{Instrument, Level}; -use turbo_tasks::{trace::TraceRawVcs, RcStr, TaskInput, TryJoinIterExt, Value, ValueToString, Vc}; +use turbo_tasks::{ + trace::TraceRawVcs, RcStr, ResolvedVc, TaskInput, TryJoinIterExt, Value, ValueToString, Vc, +}; use turbo_tasks_fs::{ util::normalize_request, FileSystemEntryType, FileSystemPath, RealPathResult, }; @@ -369,12 +371,12 @@ impl ModuleResolveResult { } #[turbo_tasks::value(transparent)] -pub struct ModuleResolveResultOption(Option>); +pub struct ModuleResolveResultOption(Option>); #[turbo_tasks::value_impl] impl ModuleResolveResultOption { #[turbo_tasks::function] - pub fn some(result: Vc) -> Vc { + pub fn some(result: ResolvedVc) -> Vc { ModuleResolveResultOption(Some(result)).cell() } diff --git a/turbopack/crates/turbopack-core/src/resolve/options.rs b/turbopack/crates/turbopack-core/src/resolve/options.rs index 844168168ced0..f9937f25b6409 100644 --- a/turbopack/crates/turbopack-core/src/resolve/options.rs +++ b/turbopack/crates/turbopack-core/src/resolve/options.rs @@ -4,7 +4,8 @@ use anyhow::{bail, Result}; use indexmap::IndexSet; use serde::{Deserialize, Serialize}; use turbo_tasks::{ - debug::ValueDebugFormat, trace::TraceRawVcs, RcStr, TryJoinIterExt, Value, ValueToString, Vc, + debug::ValueDebugFormat, trace::TraceRawVcs, RcStr, ResolvedVc, TryJoinIterExt, Value, + ValueToString, Vc, }; use turbo_tasks_fs::{glob::Glob, FileSystemPath}; @@ -40,7 +41,7 @@ pub enum ResolveModules { /// lookup versions based on lockfile in the registry filesystem /// registry filesystem is assumed to have structure like /// @scope/module/version/ - Registry(Vc, Vc), + Registry(ResolvedVc, ResolvedVc), } #[derive(TraceRawVcs, Hash, PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] diff --git a/turbopack/crates/turbopack-core/src/resolve/plugin.rs b/turbopack/crates/turbopack-core/src/resolve/plugin.rs index b714898f3c296..e3b2ad1661f07 100644 --- a/turbopack/crates/turbopack-core/src/resolve/plugin.rs +++ b/turbopack/crates/turbopack-core/src/resolve/plugin.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::{RcStr, Value, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, Value, Vc}; use turbo_tasks_fs::{glob::Glob, FileSystemPath}; use crate::{ @@ -41,19 +41,19 @@ impl AfterResolvePluginCondition { /// A condition which determines if the hooks of a resolve plugin gets called. #[turbo_tasks::value] pub enum BeforeResolvePluginCondition { - Request(Vc), - Modules(Vc>), + Request(ResolvedVc), + Modules(ResolvedVc>), } #[turbo_tasks::value_impl] impl BeforeResolvePluginCondition { #[turbo_tasks::function] - pub fn from_modules(modules: Vc>) -> Vc { + pub fn from_modules(modules: ResolvedVc>) -> Vc { BeforeResolvePluginCondition::Modules(modules).cell() } #[turbo_tasks::function] - pub fn from_request_glob(glob: Vc) -> Vc { + pub fn from_request_glob(glob: ResolvedVc) -> Vc { BeforeResolvePluginCondition::Request(glob).cell() } } diff --git a/turbopack/crates/turbopack-core/src/source_map/mod.rs b/turbopack/crates/turbopack-core/src/source_map/mod.rs index a8d99577571c4..3815b9829b9bd 100644 --- a/turbopack/crates/turbopack-core/src/source_map/mod.rs +++ b/turbopack/crates/turbopack-core/src/source_map/mod.rs @@ -7,7 +7,7 @@ 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, TryJoinIterExt, ValueToString, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, TryJoinIterExt, ValueToString, Vc}; use turbo_tasks_fs::{ rope::{Rope, RopeBuilder}, File, FileContent, FileSystem, FileSystemPath, VirtualFileSystem, @@ -57,7 +57,7 @@ pub enum SourceMap { } #[turbo_tasks::value(transparent)] -pub struct SectionMapping(IndexMap>>); +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 d86523be5c04e..446479fde9437 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, TryJoinIterExt, Value, ValueDefault, ValueToString, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, TryJoinIterExt, Value, ValueDefault, ValueToString, Vc}; use turbo_tasks_fs::{rope::Rope, File, FileSystem}; use turbopack_core::{ asset::{Asset, AssetContent}, @@ -37,7 +37,7 @@ pub struct CssChunk { } #[turbo_tasks::value(transparent)] -pub struct CssChunks(Vec>); +pub struct CssChunks(Vec>); #[turbo_tasks::value_impl] impl CssChunk { @@ -351,7 +351,7 @@ impl CssChunkContext { pub trait CssChunkPlaceable: ChunkableModule + Module + Asset {} #[turbo_tasks::value(transparent)] -pub struct CssChunkPlaceables(Vec>>); +pub struct CssChunkPlaceables(Vec>>); #[derive(Clone, Debug)] #[turbo_tasks::value(shared)] diff --git a/turbopack/crates/turbopack-css/src/code_gen.rs b/turbopack/crates/turbopack-css/src/code_gen.rs index 20855e79a1597..71b562d64f366 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::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack_core::chunk::ChunkingContext; use crate::chunk::CssImport; @@ -26,4 +26,4 @@ pub trait CodeGenerateable { } #[turbo_tasks::value(transparent)] -pub struct CodeGenerateables(Vec>>); +pub struct CodeGenerateables(Vec>>); diff --git a/turbopack/crates/turbopack-dev-server/src/source/mod.rs b/turbopack/crates/turbopack-dev-server/src/source/mod.rs index 0518db659f071..6531bcc6671fa 100644 --- a/turbopack/crates/turbopack-dev-server/src/source/mod.rs +++ b/turbopack/crates/turbopack-dev-server/src/source/mod.rs @@ -18,7 +18,8 @@ use anyhow::Result; use futures::{stream::Stream as StreamTrait, TryStreamExt}; use serde::{Deserialize, Serialize}; use turbo_tasks::{ - trace::TraceRawVcs, util::SharedError, Completion, RcStr, Upcast, Value, ValueDefault, Vc, + trace::TraceRawVcs, util::SharedError, Completion, RcStr, ResolvedVc, Upcast, Value, + ValueDefault, Vc, }; use turbo_tasks_bytes::{Bytes, Stream, StreamRead}; use turbo_tasks_fs::FileSystemPath; @@ -503,11 +504,11 @@ pub struct Rewrite { /// A [Headers] which will be appended to the eventual, fully resolved /// content result. This overwrites any previous matching headers. - pub response_headers: Option>, + pub response_headers: Option>, /// A [HeaderList] which will overwrite the values used during the lookup /// process. All headers not present in this list will be deleted. - pub request_headers: Option>, + pub request_headers: Option>, } pub struct RewriteBuilder { @@ -553,14 +554,14 @@ impl RewriteBuilder { /// Sets response headers to append to the eventual, fully resolved content /// result. - pub fn response_headers(mut self, headers: Vc) -> Self { + pub fn response_headers(mut self, headers: ResolvedVc) -> Self { self.rewrite.response_headers = Some(headers); self } /// Sets request headers to overwrite the headers used during the lookup /// process. - pub fn request_headers(mut self, headers: Vc) -> Self { + pub fn request_headers(mut self, headers: ResolvedVc) -> Self { self.rewrite.request_headers = Some(headers); self } diff --git a/turbopack/crates/turbopack-ecmascript-plugins/src/transform/emotion.rs b/turbopack/crates/turbopack-ecmascript-plugins/src/transform/emotion.rs index 469b77c4ed781..09b5e8ddac7d2 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, ValueDefault, Vc}; +use turbo_tasks::{trace::TraceRawVcs, ResolvedVc, ValueDefault, Vc}; use turbopack_ecmascript::{CustomTransformer, TransformContext}; #[derive(Clone, PartialEq, Eq, Debug, TraceRawVcs, Serialize, Deserialize)] @@ -26,7 +26,7 @@ pub enum EmotionLabelKind { } #[turbo_tasks::value(transparent)] -pub struct OptionEmotionTransformConfig(Option>); +pub struct OptionEmotionTransformConfig(Option>); //[TODO]: need to support importmap, there are type mismatch between //next.config.js to swc's emotion options 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 47d455ada4352..5b2da53785d65 100644 --- a/turbopack/crates/turbopack-ecmascript-plugins/src/transform/styled_components.rs +++ b/turbopack/crates/turbopack-ecmascript-plugins/src/transform/styled_components.rs @@ -6,11 +6,13 @@ use swc_core::{ common::{comments::NoopComments, FileName}, ecma::{ast::Program, atoms::JsWord, visit::VisitMutWith}, }; -use turbo_tasks::{ValueDefault, Vc}; +use turbo_tasks::{ResolvedVc, ValueDefault, Vc}; use turbopack_ecmascript::{CustomTransformer, TransformContext}; #[turbo_tasks::value(transparent)] -pub struct OptionStyledComponentsTransformConfig(Option>); +pub struct OptionStyledComponentsTransformConfig( + Option>, +); #[turbo_tasks::value(shared)] #[derive(Clone, Debug)] diff --git a/turbopack/crates/turbopack-ecmascript-plugins/src/transform/swc_ecma_transform_plugins.rs b/turbopack/crates/turbopack-ecmascript-plugins/src/transform/swc_ecma_transform_plugins.rs index ed1a3063c24ef..a0e854968a709 100644 --- a/turbopack/crates/turbopack-ecmascript-plugins/src/transform/swc_ecma_transform_plugins.rs +++ b/turbopack/crates/turbopack-ecmascript-plugins/src/transform/swc_ecma_transform_plugins.rs @@ -92,12 +92,14 @@ impl Issue for UnsupportedSwcEcmaTransformPluginsIssue { #[derive(Debug)] pub struct SwcEcmaTransformPluginsTransformer { #[cfg(feature = "swc_ecma_transform_plugin")] - plugins: Vec<(Vc, serde_json::Value)>, + plugins: Vec<(turbo_tasks::ResolvedVc, serde_json::Value)>, } impl SwcEcmaTransformPluginsTransformer { #[cfg(feature = "swc_ecma_transform_plugin")] - pub fn new(plugins: Vec<(Vc, serde_json::Value)>) -> Self { + pub fn new( + plugins: Vec<(turbo_tasks::ResolvedVc, serde_json::Value)>, + ) -> Self { Self { plugins } } diff --git a/turbopack/crates/turbopack-ecmascript/src/chunk/item.rs b/turbopack/crates/turbopack-ecmascript/src/chunk/item.rs index 88a12c1fb6248..8b5fa404e5dca 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, Upcast, ValueToString, Vc}; +use turbo_tasks::{trace::TraceRawVcs, ResolvedVc, Upcast, ValueToString, Vc}; use turbo_tasks_fs::rope::Rope; use turbopack_core::{ chunk::{AsyncModuleInfo, ChunkItem, ChunkItemExt, ChunkingContext}, @@ -266,7 +266,7 @@ async fn module_factory_with_code_generation_issue( } #[turbo_tasks::value(transparent)] -pub struct EcmascriptChunkItemsChunk(Vec>>); +pub struct EcmascriptChunkItemsChunk(Vec>>); #[turbo_tasks::value(transparent)] -pub struct EcmascriptChunkItems(pub(super) Vec>>); +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 7e09c2b555d3f..89d0c2d8e580d 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, Value, ValueToString, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, Value, ValueToString, Vc}; use turbo_tasks_fs::FileSystem; use turbopack_core::{ asset::{Asset, AssetContent}, @@ -40,7 +40,7 @@ pub struct EcmascriptChunk { } #[turbo_tasks::value(transparent)] -pub struct EcmascriptChunks(Vec>); +pub struct EcmascriptChunks(Vec>); #[turbo_tasks::value_impl] impl EcmascriptChunk { diff --git a/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs b/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs index 303c5ede1a9c5..65e462ed15bb5 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::{TryFlatJoinIterExt, Vc}; +use turbo_tasks::{ResolvedVc, TryFlatJoinIterExt, Vc}; use turbo_tasks_fs::{glob::Glob, FileJsonContent, FileSystemPath}; use turbopack_core::{ asset::Asset, @@ -189,7 +189,7 @@ pub async fn is_marked_as_side_effect_free( } #[turbo_tasks::value(transparent)] -pub struct EcmascriptChunkPlaceables(Vec>>); +pub struct EcmascriptChunkPlaceables(Vec>>); #[turbo_tasks::value_impl] impl EcmascriptChunkPlaceables { diff --git a/turbopack/crates/turbopack-ecmascript/src/lib.rs b/turbopack/crates/turbopack-ecmascript/src/lib.rs index bb0e9d49322a8..0f3c320b26dda 100644 --- a/turbopack/crates/turbopack-ecmascript/src/lib.rs +++ b/turbopack/crates/turbopack-ecmascript/src/lib.rs @@ -60,7 +60,8 @@ pub use transform::{ TransformContext, TransformPlugin, UnsupportedServerActionIssue, }; use turbo_tasks::{ - trace::TraceRawVcs, RcStr, ReadRef, TaskInput, TryJoinIterExt, Value, ValueToString, Vc, + trace::TraceRawVcs, RcStr, ReadRef, ResolvedVc, TaskInput, TryJoinIterExt, Value, + ValueToString, Vc, }; use turbo_tasks_fs::{rope::Rope, FileJsonContent, FileSystemPath}; use turbopack_core::{ @@ -250,7 +251,7 @@ pub struct EcmascriptModuleAsset { pub transforms: Vc, pub options: Vc, pub compile_time_info: Vc, - pub inner_assets: Option>, + pub inner_assets: Option>, #[turbo_tasks(debug_ignore)] last_successful_parse: turbo_tasks::TransientState>, } @@ -282,11 +283,11 @@ pub trait EcmascriptAnalyzable { /// An optional [EcmascriptModuleAsset] #[turbo_tasks::value(transparent)] -pub struct OptionEcmascriptModuleAsset(Option>); +pub struct OptionEcmascriptModuleAsset(Option>); /// A list of [EcmascriptModuleAsset]s #[turbo_tasks::value(transparent)] -pub struct EcmascriptModuleAssets(Vec>); +pub struct EcmascriptModuleAssets(Vec>); impl EcmascriptModuleAsset { pub fn builder( @@ -449,7 +450,7 @@ impl EcmascriptModuleAsset { transforms: Vc, options: Vc, compile_time_info: Vc, - inner_assets: Vc, + inner_assets: ResolvedVc, ) -> Vc { Self::cell(EcmascriptModuleAsset { source, diff --git a/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs b/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs index 0391d400cb892..3b05a72d99c23 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, Value, ValueToString, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, Value, ValueToString, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ chunk::{ @@ -106,7 +106,7 @@ pub struct EsmAssetReference { /// A list of [EsmAssetReference]s #[turbo_tasks::value(transparent)] -pub struct EsmAssetReferences(Vec>); +pub struct EsmAssetReferences(Vec>); impl EsmAssetReference { fn get_origin(&self) -> Vc> { diff --git a/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs b/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs index d388b57c0b1a2..ab188650e5686 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, ValueDefault, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, ValueDefault, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ environment::Environment, @@ -82,7 +82,7 @@ pub trait CustomTransformer: Debug { pub struct TransformPlugin(#[turbo_tasks(trace_ignore)] Box); #[turbo_tasks::value(transparent)] -pub struct OptionTransformPlugin(Option>); +pub struct OptionTransformPlugin(Option>); #[turbo_tasks::value_impl] impl ValueDefault for OptionTransformPlugin { diff --git a/turbopack/crates/turbopack/src/lib.rs b/turbopack/crates/turbopack/src/lib.rs index 06191ff7d7f32..a7e8f6b950906 100644 --- a/turbopack/crates/turbopack/src/lib.rs +++ b/turbopack/crates/turbopack/src/lib.rs @@ -30,7 +30,7 @@ use ecmascript::{ use graph::{aggregate, AggregatedGraph, AggregatedGraphNodeContent}; use module_options::{ModuleOptions, ModuleOptionsContext, ModuleRuleEffect, ModuleType}; use tracing::Instrument; -use turbo_tasks::{Completion, RcStr, Value, ValueToString, Vc}; +use turbo_tasks::{Completion, RcStr, ResolvedVc, Value, ValueToString, Vc}; use turbo_tasks_fs::{glob::Glob, FileSystemPath}; pub use turbopack_core::condition; use turbopack_core::{ @@ -327,7 +327,7 @@ pub struct ModuleAssetContext { pub module_options_context: Vc, pub resolve_options_context: Vc, pub layer: Vc, - transition: Option>>, + transition: Option>>, } #[turbo_tasks::value_impl] @@ -357,7 +357,7 @@ impl ModuleAssetContext { module_options_context: Vc, resolve_options_context: Vc, layer: Vc, - transition: Vc>, + transition: ResolvedVc>, ) -> Vc { Self::cell(ModuleAssetContext { transitions, 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 2d6b19374101d..8eaaa725f193b 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, ValueDefault, Vc}; +use turbo_tasks::{trace::TraceRawVcs, RcStr, ResolvedVc, ValueDefault, Vc}; use turbopack_core::{ condition::ContextCondition, environment::Environment, resolve::options::ImportMapping, }; @@ -36,7 +36,7 @@ pub struct WebpackLoadersOptions { #[derive(Default)] #[turbo_tasks::value(transparent)] -pub struct OptionWebpackLoadersOptions(Option>); +pub struct OptionWebpackLoadersOptions(Option>); /// The kind of decorators transform to use. /// [TODO]: might need bikeshed for the name (Ecma)