diff --git a/crates/next-core/src/next_shared/transforms/debug_fn_name.rs b/crates/next-core/src/next_shared/transforms/debug_fn_name.rs index 7ae0b5e7b849e..a95e10ed6034f 100644 --- a/crates/next-core/src/next_shared/transforms/debug_fn_name.rs +++ b/crates/next-core/src/next_shared/transforms/debug_fn_name.rs @@ -2,15 +2,16 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::debug_fn_name::debug_fn_name; use swc_core::ecma::{ast::Program, visit::VisitMutWith}; -use turbo_tasks::{ResolvedVc, Vc}; +use turbo_tasks::ResolvedVc; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; use super::module_rule_match_js_no_url; pub fn get_debug_fn_name_rule(enable_mdx_rs: bool) -> ModuleRule { - let debug_fn_name_transform = - EcmascriptInputTransform::Plugin(Vc::cell(Box::new(DebugFnNameTransformer {}) as _)); + let debug_fn_name_transform = EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new( + DebugFnNameTransformer {}, + ) as _)); ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), diff --git a/crates/next-core/src/next_shared/transforms/mod.rs b/crates/next-core/src/next_shared/transforms/mod.rs index 307d4ab5d33b0..c1d32685da017 100644 --- a/crates/next-core/src/next_shared/transforms/mod.rs +++ b/crates/next-core/src/next_shared/transforms/mod.rs @@ -31,7 +31,7 @@ pub use next_font::get_next_font_transform_rule; pub use next_lint::get_next_lint_transform_rule; pub use next_strip_page_exports::get_next_pages_transforms_rule; pub use server_actions::get_server_actions_transform_rule; -use turbo_tasks::{ReadRef, ResolvedVc, Value, Vc}; +use turbo_tasks::{ReadRef, ResolvedVc, Value}; use turbo_tasks_fs::FileSystemPath; use turbopack::module_options::{ModuleRule, ModuleRuleEffect, ModuleType, RuleCondition}; use turbopack_core::reference_type::{ReferenceType, UrlReferenceSubType}; @@ -136,7 +136,7 @@ pub(crate) fn get_ecma_transform_rule( enable_mdx_rs: bool, prepend: bool, ) -> ModuleRule { - let transformer = EcmascriptInputTransform::Plugin(Vc::cell(transformer as _)); + let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell(transformer as _)); let (prepend, append) = if prepend { ( ResolvedVc::cell(vec![transformer]), diff --git a/crates/next-core/src/next_shared/transforms/modularize_imports.rs b/crates/next-core/src/next_shared/transforms/modularize_imports.rs index 413fb96d58dad..9e0119cb5272b 100644 --- a/crates/next-core/src/next_shared/transforms/modularize_imports.rs +++ b/crates/next-core/src/next_shared/transforms/modularize_imports.rs @@ -5,7 +5,7 @@ use async_trait::async_trait; use modularize_imports::{modularize_imports, PackageConfig}; use serde::{Deserialize, Serialize}; use swc_core::ecma::ast::Program; -use turbo_tasks::{trace::TraceRawVcs, FxIndexMap, ResolvedVc, Vc}; +use turbo_tasks::{trace::TraceRawVcs, FxIndexMap, ResolvedVc}; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -35,7 +35,7 @@ pub fn get_next_modularize_imports_rule( modularize_imports_config: &FxIndexMap, enable_mdx_rs: bool, ) -> ModuleRule { - let transformer = EcmascriptInputTransform::Plugin(Vc::cell(Box::new( + let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new( ModularizeImportsTransformer::new(modularize_imports_config), ) as _)); ModuleRule::new( diff --git a/crates/next-core/src/next_shared/transforms/next_amp_attributes.rs b/crates/next-core/src/next_shared/transforms/next_amp_attributes.rs index 1f9ff2298f280..e3a78f105c422 100644 --- a/crates/next-core/src/next_shared/transforms/next_amp_attributes.rs +++ b/crates/next-core/src/next_shared/transforms/next_amp_attributes.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::amp_attributes::amp_attributes; use swc_core::ecma::ast::*; -use turbo_tasks::{ResolvedVc, Vc}; +use turbo_tasks::ResolvedVc; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -10,7 +10,7 @@ use super::module_rule_match_js_no_url; pub fn get_next_amp_attr_rule(enable_mdx_rs: bool) -> ModuleRule { let transformer = - EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextAmpAttributes {}) as _)); + EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextAmpAttributes {}) as _)); ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { diff --git a/crates/next-core/src/next_shared/transforms/next_cjs_optimizer.rs b/crates/next-core/src/next_shared/transforms/next_cjs_optimizer.rs index e8c65150b6e00..c0d212b2df3de 100644 --- a/crates/next-core/src/next_shared/transforms/next_cjs_optimizer.rs +++ b/crates/next-core/src/next_shared/transforms/next_cjs_optimizer.rs @@ -6,7 +6,7 @@ use swc_core::{ common::SyntaxContext, ecma::{ast::*, visit::VisitMutWith}, }; -use turbo_tasks::{ResolvedVc, Vc}; +use turbo_tasks::ResolvedVc; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -47,8 +47,9 @@ pub fn get_next_cjs_optimizer_rule(enable_mdx_rs: bool) -> ModuleRule { )]), }; - let transformer = - EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextCjsOptimizer { config }) as _)); + let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell( + Box::new(NextCjsOptimizer { config }) as _, + )); ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { diff --git a/crates/next-core/src/next_shared/transforms/next_disallow_re_export_all_in_page.rs b/crates/next-core/src/next_shared/transforms/next_disallow_re_export_all_in_page.rs index c7ff8ae07f0a6..3be6bcc1f652a 100644 --- a/crates/next-core/src/next_shared/transforms/next_disallow_re_export_all_in_page.rs +++ b/crates/next-core/src/next_shared/transforms/next_disallow_re_export_all_in_page.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::disallow_re_export_all_in_page::disallow_re_export_all_in_page; use swc_core::ecma::ast::*; -use turbo_tasks::{ReadRef, ResolvedVc, Vc}; +use turbo_tasks::{ReadRef, ResolvedVc}; use turbo_tasks_fs::FileSystemPath; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -13,8 +13,9 @@ pub fn get_next_disallow_export_all_in_page_rule( enable_mdx_rs: bool, pages_dir: ReadRef, ) -> ModuleRule { - let transformer = - EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextDisallowReExportAllInPage) as _)); + let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new( + NextDisallowReExportAllInPage, + ) as _)); ModuleRule::new( module_rule_match_pages_page_file(enable_mdx_rs, pages_dir), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { diff --git a/crates/next-core/src/next_shared/transforms/next_dynamic.rs b/crates/next-core/src/next_shared/transforms/next_dynamic.rs index b993f8e3a18ad..5eada470327fb 100644 --- a/crates/next-core/src/next_shared/transforms/next_dynamic.rs +++ b/crates/next-core/src/next_shared/transforms/next_dynamic.rs @@ -17,12 +17,13 @@ pub async fn get_next_dynamic_transform_rule( mode: Vc, enable_mdx_rs: bool, ) -> Result { - let dynamic_transform = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextJsDynamic { - is_server_compiler, - is_react_server_layer, - is_app_dir, - mode: *mode.await?, - }) as _)); + let dynamic_transform = + EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextJsDynamic { + is_server_compiler, + is_react_server_layer, + is_app_dir, + mode: *mode.await?, + }) as _)); Ok(ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { diff --git a/crates/next-core/src/next_shared/transforms/next_edge_node_api_assert.rs b/crates/next-core/src/next_shared/transforms/next_edge_node_api_assert.rs index cfdf6013c80d5..13eaea081fb2d 100644 --- a/crates/next-core/src/next_shared/transforms/next_edge_node_api_assert.rs +++ b/crates/next-core/src/next_shared/transforms/next_edge_node_api_assert.rs @@ -5,7 +5,7 @@ use swc_core::{ common::SyntaxContext, ecma::{ast::*, utils::ExprCtx, visit::VisitWith}, }; -use turbo_tasks::{ResolvedVc, Vc}; +use turbo_tasks::ResolvedVc; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -16,10 +16,11 @@ pub fn next_edge_node_api_assert( should_error_for_node_apis: bool, is_production: bool, ) -> ModuleRule { - let transformer = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextEdgeNodeApiAssert { - should_error_for_node_apis, - is_production, - }) as _)); + let transformer = + EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextEdgeNodeApiAssert { + should_error_for_node_apis, + is_production, + }) as _)); ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { diff --git a/crates/next-core/src/next_shared/transforms/next_font.rs b/crates/next-core/src/next_shared/transforms/next_font.rs index 3bcf54b84f88e..0885ed92b79da 100644 --- a/crates/next-core/src/next_shared/transforms/next_font.rs +++ b/crates/next-core/src/next_shared/transforms/next_font.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::fonts::*; use swc_core::ecma::{ast::Program, atoms::JsWord, visit::VisitMutWith}; -use turbo_tasks::{ResolvedVc, Vc}; +use turbo_tasks::ResolvedVc; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -18,7 +18,9 @@ pub fn get_next_font_transform_rule(enable_mdx_rs: bool) -> ModuleRule { ]; let transformer = - EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextJsFont { font_loaders }) as _)); + EcmascriptInputTransform::Plugin(ResolvedVc::cell( + Box::new(NextJsFont { font_loaders }) as _ + )); ModuleRule::new( // TODO: Only match in pages (not pages/api), app/, etc. module_rule_match_js_no_url(enable_mdx_rs), diff --git a/crates/next-core/src/next_shared/transforms/next_middleware_dynamic_assert.rs b/crates/next-core/src/next_shared/transforms/next_middleware_dynamic_assert.rs index bb46d47b32660..c23635607b19c 100644 --- a/crates/next-core/src/next_shared/transforms/next_middleware_dynamic_assert.rs +++ b/crates/next-core/src/next_shared/transforms/next_middleware_dynamic_assert.rs @@ -2,15 +2,16 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::middleware_dynamic::next_middleware_dynamic; use swc_core::ecma::{ast::*, visit::VisitMutWith}; -use turbo_tasks::{ResolvedVc, Vc}; +use turbo_tasks::ResolvedVc; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; use super::module_rule_match_js_no_url; pub fn get_middleware_dynamic_assert_rule(enable_mdx_rs: bool) -> ModuleRule { - let transformer = - EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextMiddlewareDynamicAssert {}) as _)); + let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new( + NextMiddlewareDynamicAssert {}, + ) as _)); ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { diff --git a/crates/next-core/src/next_shared/transforms/next_optimize_server_react.rs b/crates/next-core/src/next_shared/transforms/next_optimize_server_react.rs index f48f525138f10..2fe243b00e461 100644 --- a/crates/next-core/src/next_shared/transforms/next_optimize_server_react.rs +++ b/crates/next-core/src/next_shared/transforms/next_optimize_server_react.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::optimize_server_react::{optimize_server_react, Config}; use swc_core::ecma::ast::*; -use turbo_tasks::{ResolvedVc, Vc}; +use turbo_tasks::ResolvedVc; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -14,7 +14,7 @@ pub fn get_next_optimize_server_react_rule( optimize_use_state: bool, ) -> ModuleRule { let transformer = - EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextOptimizeServerReact { + EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextOptimizeServerReact { optimize_use_state, }) as _)); ModuleRule::new( diff --git a/crates/next-core/src/next_shared/transforms/next_page_config.rs b/crates/next-core/src/next_shared/transforms/next_page_config.rs index 9e39cd4a66233..b7ee560a7b481 100644 --- a/crates/next-core/src/next_shared/transforms/next_page_config.rs +++ b/crates/next-core/src/next_shared/transforms/next_page_config.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::page_config::page_config; use swc_core::ecma::ast::*; -use turbo_tasks::{ReadRef, ResolvedVc, Vc}; +use turbo_tasks::{ReadRef, ResolvedVc}; use turbo_tasks_fs::FileSystemPath; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -13,7 +13,7 @@ pub fn get_next_page_config_rule( enable_mdx_rs: bool, pages_dir: ReadRef, ) -> ModuleRule { - let transformer = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextPageConfig { + let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextPageConfig { // [TODO]: update once turbopack build works is_development: true, }) as _)); diff --git a/crates/next-core/src/next_shared/transforms/next_page_static_info.rs b/crates/next-core/src/next_shared/transforms/next_page_static_info.rs index e26864de8cca7..ebc034cf35414 100644 --- a/crates/next-core/src/next_shared/transforms/next_page_static_info.rs +++ b/crates/next-core/src/next_shared/transforms/next_page_static_info.rs @@ -25,10 +25,11 @@ pub fn get_next_page_static_info_assert_rule( server_context: Option, client_context: Option, ) -> ModuleRule { - let transformer = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextPageStaticInfo { - server_context, - client_context, - }) as _)); + let transformer = + EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextPageStaticInfo { + server_context, + client_context, + }) as _)); ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { @@ -129,7 +130,7 @@ impl CustomTransformer for NextPageStaticInfo { #[turbo_tasks::value(shared)] pub struct PageStaticInfoIssue { - pub file_path: Vc, + pub file_path: ResolvedVc, pub messages: Vec, pub severity: IssueSeverity, } @@ -153,7 +154,7 @@ impl Issue for PageStaticInfoIssue { #[turbo_tasks::function] fn file_path(&self) -> Vc { - self.file_path + *self.file_path } #[turbo_tasks::function] diff --git a/crates/next-core/src/next_shared/transforms/next_pure.rs b/crates/next-core/src/next_shared/transforms/next_pure.rs index 033d7d02ef592..8226499ecd47e 100644 --- a/crates/next-core/src/next_shared/transforms/next_pure.rs +++ b/crates/next-core/src/next_shared/transforms/next_pure.rs @@ -2,14 +2,15 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::pure::pure_magic; use swc_core::ecma::{ast::*, visit::VisitMutWith}; -use turbo_tasks::{ResolvedVc, Vc}; +use turbo_tasks::ResolvedVc; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; use super::module_rule_match_js_no_url; pub fn get_next_pure_rule(enable_mdx_rs: bool) -> ModuleRule { - let transformer = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextPure {}) as _)); + let transformer = + EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextPure {}) as _)); ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { diff --git a/crates/next-core/src/next_shared/transforms/next_shake_exports.rs b/crates/next-core/src/next_shared/transforms/next_shake_exports.rs index 6e86422b84648..690420cb16220 100644 --- a/crates/next-core/src/next_shared/transforms/next_shake_exports.rs +++ b/crates/next-core/src/next_shared/transforms/next_shake_exports.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::shake_exports::{shake_exports, Config}; use swc_core::ecma::ast::*; -use turbo_tasks::{ResolvedVc, Vc}; +use turbo_tasks::ResolvedVc; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -10,8 +10,9 @@ use super::module_rule_match_js_no_url; #[allow(dead_code)] pub fn get_next_shake_exports_rule(enable_mdx_rs: bool, ignore: Vec) -> ModuleRule { - let transformer = - EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextShakeExports { ignore }) as _)); + let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell( + Box::new(NextShakeExports { ignore }) as _, + )); ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { diff --git a/crates/next-core/src/next_shared/transforms/next_strip_page_exports.rs b/crates/next-core/src/next_shared/transforms/next_strip_page_exports.rs index e6ccc13443ecc..8f8e2467dd1f0 100644 --- a/crates/next-core/src/next_shared/transforms/next_strip_page_exports.rs +++ b/crates/next-core/src/next_shared/transforms/next_strip_page_exports.rs @@ -18,9 +18,10 @@ pub async fn get_next_pages_transforms_rule( enable_mdx_rs: bool, ) -> Result { // Apply the Next SSG transform to all pages. - let strip_transform = EcmascriptInputTransform::Plugin(Vc::cell(Box::new( - NextJsStripPageExports { export_filter }, - ) as _)); + let strip_transform = + EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextJsStripPageExports { + export_filter, + }) as _)); Ok(ModuleRule::new( RuleCondition::all(vec![ RuleCondition::all(vec![ diff --git a/crates/next-core/src/next_shared/transforms/server_actions.rs b/crates/next-core/src/next_shared/transforms/server_actions.rs index f584f4bd8c480..ff120b7a5b624 100644 --- a/crates/next-core/src/next_shared/transforms/server_actions.rs +++ b/crates/next-core/src/next_shared/transforms/server_actions.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::server_actions::{server_actions, Config}; use swc_core::{common::FileName, ecma::ast::Program}; -use turbo_tasks::{ResolvedVc, Vc}; +use turbo_tasks::ResolvedVc; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -20,10 +20,11 @@ pub fn get_server_actions_transform_rule( enable_mdx_rs: bool, dynamic_io_enabled: bool, ) -> ModuleRule { - let transformer = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextServerActions { - transform, - dynamic_io_enabled, - }) as _)); + let transformer = + EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextServerActions { + transform, + dynamic_io_enabled, + }) as _)); ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { diff --git a/turbopack/crates/turbopack-cli/src/contexts.rs b/turbopack/crates/turbopack-cli/src/contexts.rs index 30239bd13fbdf..ffa6e63d568e2 100644 --- a/turbopack/crates/turbopack-cli/src/contexts.rs +++ b/turbopack/crates/turbopack-cli/src/contexts.rs @@ -145,16 +145,16 @@ async fn get_client_module_options_context( conditions, vec![ModuleRuleEffect::ExtendEcmascriptTransforms { prepend: ResolvedVc::cell(vec![ - EcmascriptInputTransform::Plugin(Vc::cell(Box::new( + EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new( EmotionTransformer::new(&EmotionTransformConfig::default()) .expect("Should be able to create emotion transformer"), ) as _)), - EcmascriptInputTransform::Plugin(Vc::cell(Box::new( + EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new( StyledComponentsTransformer::new(&StyledComponentsTransformConfig::default()), ) as _)), - EcmascriptInputTransform::Plugin(Vc::cell(Box::new(StyledJsxTransformer::new( - versions, - )) as _)), + EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new( + StyledJsxTransformer::new(versions), + ) as _)), ]), append: ResolvedVc::cell(vec![]), }], diff --git a/turbopack/crates/turbopack-core/src/introspect/utils.rs b/turbopack/crates/turbopack-core/src/introspect/utils.rs index 8d864812ee822..983d65556c06e 100644 --- a/turbopack/crates/turbopack-core/src/introspect/utils.rs +++ b/turbopack/crates/turbopack-core/src/introspect/utils.rs @@ -64,10 +64,10 @@ pub async fn children_from_module_references( let key = reference_ty(); let mut children = FxIndexSet::default(); let references = references.await?; - for reference in &*references { + for &reference in &*references { let mut key = key; if let Some(chunkable) = - Vc::try_resolve_downcast::>(*reference).await? + Vc::try_resolve_downcast::>(reference).await? { match &*chunkable.chunking_type().await? { None => {} 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 a0e854968a709..b2c6c13af4bda 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 @@ -1,7 +1,7 @@ use anyhow::Result; use async_trait::async_trait; use swc_core::ecma::ast::Program; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::issue::{Issue, IssueSeverity, IssueStage, OptionStyledString, StyledString}; use turbopack_ecmascript::{CustomTransformer, TransformContext}; @@ -49,7 +49,7 @@ impl SwcPluginModule { #[turbo_tasks::value(shared)] struct UnsupportedSwcEcmaTransformPluginsIssue { - pub file_path: Vc, + pub file_path: ResolvedVc, } #[turbo_tasks::value_impl] @@ -72,7 +72,7 @@ impl Issue for UnsupportedSwcEcmaTransformPluginsIssue { #[turbo_tasks::function] fn file_path(&self) -> Vc { - self.file_path + *self.file_path } #[turbo_tasks::function] diff --git a/turbopack/crates/turbopack-ecmascript/src/analyzer/mod.rs b/turbopack/crates/turbopack-ecmascript/src/analyzer/mod.rs index 41f3ed57f05b1..fd8e5a13faac7 100644 --- a/turbopack/crates/turbopack-ecmascript/src/analyzer/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/analyzer/mod.rs @@ -26,7 +26,7 @@ use swc_core::{ }, }; use turbo_rcstr::RcStr; -use turbo_tasks::{FxIndexMap, FxIndexSet, Vc}; +use turbo_tasks::{FxIndexMap, FxIndexSet, ResolvedVc, Vc}; use turbopack_core::compile_time_info::{ CompileTimeDefineValue, DefineableNameSegment, FreeVarReference, }; @@ -3789,9 +3789,9 @@ pub enum WellKnownFunctionKind { Require, RequireResolve, RequireContext, - RequireContextRequire(Vc), - RequireContextRequireKeys(Vc), - RequireContextRequireResolve(Vc), + RequireContextRequire(ResolvedVc), + RequireContextRequireKeys(ResolvedVc), + RequireContextRequireResolve(ResolvedVc), Define, FsReadMethod(JsWord), PathToFileUrl, @@ -3838,7 +3838,7 @@ fn is_unresolved_id(i: &Id, unresolved_mark: Mark) -> bool { #[doc(hidden)] pub mod test_utils { use anyhow::Result; - use turbo_tasks::{FxIndexMap, Vc}; + use turbo_tasks::{FxIndexMap, ResolvedVc, Vc}; use turbopack_core::{compile_time_info::CompileTimeInfo, error::PrettyPrintError}; use super::{ @@ -3900,7 +3900,7 @@ pub mod test_utils { map.insert("./c".into(), format!("[context: {}]/c", options.dir).into()); JsValue::WellKnownFunction(WellKnownFunctionKind::RequireContextRequire( - Vc::cell(map), + ResolvedVc::cell(map), )) } Err(err) => v.into_unknown(true, PrettyPrintError(&err).to_string()), diff --git a/turbopack/crates/turbopack-ecmascript/src/analyzer/well_known.rs b/turbopack/crates/turbopack-ecmascript/src/analyzer/well_known.rs index fdd5788dbd432..c4d83de309d3e 100644 --- a/turbopack/crates/turbopack-ecmascript/src/analyzer/well_known.rs +++ b/turbopack/crates/turbopack-ecmascript/src/analyzer/well_known.rs @@ -1,7 +1,7 @@ use std::mem::take; use anyhow::Result; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack_core::compile_time_info::CompileTimeInfo; use url::Url; @@ -354,8 +354,8 @@ pub fn require(args: Vec) -> JsValue { } /// (try to) statically evaluate `require.context(...)()` -pub async fn require_context_require( - val: Vc, +async fn require_context_require( + val: ResolvedVc, args: Vec, ) -> Result { if args.is_empty() { @@ -406,8 +406,8 @@ pub async fn require_context_require( } /// (try to) statically evaluate `require.context(...).keys()` -pub async fn require_context_require_keys( - val: Vc, +async fn require_context_require_keys( + val: ResolvedVc, args: Vec, ) -> Result { Ok(if args.is_empty() { @@ -428,8 +428,8 @@ pub async fn require_context_require_keys( } /// (try to) statically evaluate `require.context(...).resolve()` -pub async fn require_context_require_resolve( - val: Vc, +async fn require_context_require_resolve( + val: ResolvedVc, args: Vec, ) -> Result { if args.len() != 1 { diff --git a/turbopack/crates/turbopack-ecmascript/src/async_chunk/chunk_item.rs b/turbopack/crates/turbopack-ecmascript/src/async_chunk/chunk_item.rs index 6fe0df7a47142..ac163751313ff 100644 --- a/turbopack/crates/turbopack-ecmascript/src/async_chunk/chunk_item.rs +++ b/turbopack/crates/turbopack-ecmascript/src/async_chunk/chunk_item.rs @@ -1,7 +1,7 @@ use anyhow::Result; use indoc::formatdoc; use turbo_rcstr::RcStr; -use turbo_tasks::{TryJoinIterExt, Value, Vc}; +use turbo_tasks::{ResolvedVc, TryJoinIterExt, Value, Vc}; use turbopack_core::{ chunk::{ ChunkData, ChunkItem, ChunkItemExt, ChunkType, ChunkableModule, ChunkingContext, @@ -24,8 +24,8 @@ use crate::{ #[turbo_tasks::value(shared)] pub struct AsyncLoaderChunkItem { - pub module: Vc, - pub chunking_context: Vc>, + pub module: ResolvedVc, + pub chunking_context: ResolvedVc>, } #[turbo_tasks::value_impl] @@ -38,7 +38,7 @@ impl AsyncLoaderChunkItem { .get( module .inner - .as_chunk_item(Vc::upcast(self.chunking_context)) + .as_chunk_item(*ResolvedVc::upcast(self.chunking_context)) .resolve() .await?, ) @@ -49,7 +49,7 @@ impl AsyncLoaderChunkItem { } } Ok(self.chunking_context.chunk_group_assets( - Vc::upcast(module.inner), + *ResolvedVc::upcast(module.inner), Value::new(module.availability_info), )) } @@ -68,7 +68,7 @@ impl AsyncLoaderChunkItem { impl EcmascriptChunkItem for AsyncLoaderChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - self.chunking_context + *self.chunking_context } #[turbo_tasks::function] @@ -77,11 +77,11 @@ impl EcmascriptChunkItem for AsyncLoaderChunkItem { let module = this.module.await?; let id = if let Some(placeable) = - Vc::try_resolve_downcast::>(module.inner).await? + Vc::try_resolve_downcast::>(*module.inner).await? { Some( placeable - .as_chunk_item(Vc::upcast(this.chunking_context)) + .as_chunk_item(*ResolvedVc::upcast(this.chunking_context)) .id() .await?, ) @@ -198,7 +198,7 @@ impl ChunkItem for AsyncLoaderChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - Vc::upcast(self.chunking_context) + *ResolvedVc::upcast(self.chunking_context) } #[turbo_tasks::function] @@ -210,6 +210,6 @@ impl ChunkItem for AsyncLoaderChunkItem { #[turbo_tasks::function] fn module(&self) -> Vc> { - Vc::upcast(self.module) + *ResolvedVc::upcast(self.module) } } diff --git a/turbopack/crates/turbopack-ecmascript/src/async_chunk/module.rs b/turbopack/crates/turbopack-ecmascript/src/async_chunk/module.rs index f68e63b3e76eb..dbe7067614646 100644 --- a/turbopack/crates/turbopack-ecmascript/src/async_chunk/module.rs +++ b/turbopack/crates/turbopack-ecmascript/src/async_chunk/module.rs @@ -1,6 +1,6 @@ use anyhow::Result; use turbo_rcstr::RcStr; -use turbo_tasks::{Value, Vc}; +use turbo_tasks::{ResolvedVc, Value, Vc}; use turbopack_core::{ asset::{Asset, AssetContent}, chunk::{availability_info::AvailabilityInfo, ChunkableModule, ChunkingContext}, @@ -20,8 +20,8 @@ fn modifier() -> Vc { /// putting it into a separate chunk group. #[turbo_tasks::value] pub struct AsyncLoaderModule { - pub inner: Vc>, - pub chunking_context: Vc>, + pub inner: ResolvedVc>, + pub chunking_context: ResolvedVc>, pub availability_info: AvailabilityInfo, } @@ -29,8 +29,8 @@ pub struct AsyncLoaderModule { impl AsyncLoaderModule { #[turbo_tasks::function] pub fn new( - module: Vc>, - chunking_context: Vc>, + module: ResolvedVc>, + chunking_context: ResolvedVc>, availability_info: Value, ) -> Vc { Self::cell(AsyncLoaderModule { @@ -55,13 +55,13 @@ fn inner_module_reference_description() -> Vc { impl Module for AsyncLoaderModule { #[turbo_tasks::function] fn ident(&self) -> Vc { - Self::asset_ident_for(self.inner) + Self::asset_ident_for(*self.inner) } #[turbo_tasks::function] async fn references(self: Vc) -> Result> { Ok(Vc::cell(vec![Vc::upcast(SingleModuleReference::new( - Vc::upcast(self.await?.inner), + *ResolvedVc::upcast(self.await?.inner), inner_module_reference_description(), ))])) } @@ -78,9 +78,9 @@ impl Asset for AsyncLoaderModule { #[turbo_tasks::value_impl] impl ChunkableModule for AsyncLoaderModule { #[turbo_tasks::function] - fn as_chunk_item( - self: Vc, - chunking_context: Vc>, + async fn as_chunk_item( + self: ResolvedVc, + chunking_context: ResolvedVc>, ) -> Vc> { Vc::upcast( AsyncLoaderChunkItem { diff --git a/turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs b/turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs index d721739f0fdb3..68e687b598c97 100644 --- a/turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs @@ -8,7 +8,7 @@ use std::fmt::Write; use anyhow::{bail, Result}; use turbo_rcstr::RcStr; -use turbo_tasks::{Value, ValueToString, Vc}; +use turbo_tasks::{ResolvedVc, Value, ValueToString, Vc}; use turbo_tasks_fs::FileSystem; use turbopack_core::{ asset::{Asset, AssetContent}, @@ -36,16 +36,16 @@ pub use self::{ #[turbo_tasks::value] pub struct EcmascriptChunk { - pub chunking_context: Vc>, - pub content: Vc, + pub chunking_context: ResolvedVc>, + pub content: ResolvedVc, } #[turbo_tasks::value_impl] impl EcmascriptChunk { #[turbo_tasks::function] pub fn new( - chunking_context: Vc>, - content: Vc, + chunking_context: ResolvedVc>, + content: ResolvedVc, ) -> Vc { EcmascriptChunk { chunking_context, @@ -127,7 +127,7 @@ impl Chunk for EcmascriptChunk { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - Vc::upcast(self.chunking_context) + *ResolvedVc::upcast(self.chunking_context) } #[turbo_tasks::function] @@ -163,7 +163,7 @@ impl ValueToString for EcmascriptChunk { impl EcmascriptChunk { #[turbo_tasks::function] pub fn chunk_content(&self) -> Vc { - self.content + *self.content } #[turbo_tasks::function] diff --git a/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs b/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs index 281866a3c0672..83624729f62d6 100644 --- a/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs +++ b/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs @@ -38,7 +38,7 @@ enum SideEffectsValue { #[turbo_tasks::function] async fn side_effects_from_package_json( - package_json: Vc, + package_json: ResolvedVc, ) -> Result> { if let FileJsonContent::Content(content) = &*package_json.read_json().await? { if let Some(side_effects) = content.get("sideEffects") { @@ -66,7 +66,7 @@ async fn side_effects_from_package_json( ) .into(), ) - .cell(), + .resolved_cell(), ), } .cell() @@ -88,7 +88,7 @@ async fn side_effects_from_package_json( ) .into(), ) - .cell(), + .resolved_cell(), ), } .cell() @@ -113,7 +113,7 @@ async fn side_effects_from_package_json( ) .into(), ) - .cell(), + .resolved_cell(), ), } .cell() @@ -126,8 +126,8 @@ async fn side_effects_from_package_json( #[turbo_tasks::value] struct SideEffectsInPackageJsonIssue { - path: Vc, - description: Option>, + path: ResolvedVc, + description: Option>, } #[turbo_tasks::value_impl] @@ -144,7 +144,7 @@ impl Issue for SideEffectsInPackageJsonIssue { #[turbo_tasks::function] fn file_path(&self) -> Vc { - self.path + *self.path } #[turbo_tasks::function] @@ -154,7 +154,7 @@ impl Issue for SideEffectsInPackageJsonIssue { #[turbo_tasks::function] fn description(&self) -> Vc { - Vc::cell(self.description) + Vc::cell(self.description.map(|v| *v)) } } diff --git a/turbopack/crates/turbopack-ecmascript/src/chunk_group_files_asset.rs b/turbopack/crates/turbopack-ecmascript/src/chunk_group_files_asset.rs index 02d291b7024b0..ab3cb1f302ca9 100644 --- a/turbopack/crates/turbopack-ecmascript/src/chunk_group_files_asset.rs +++ b/turbopack/crates/turbopack-ecmascript/src/chunk_group_files_asset.rs @@ -37,9 +37,9 @@ fn modifier() -> Vc { /// ChunkGroup with the provided ChunkingContext. #[turbo_tasks::value(shared)] pub struct ChunkGroupFilesAsset { - pub module: Vc>, - pub client_root: Vc, - pub chunking_context: Vc>, + pub module: ResolvedVc>, + pub client_root: ResolvedVc, + pub chunking_context: ResolvedVc>, pub runtime_entries: Option>, } @@ -63,7 +63,7 @@ impl Module for ChunkGroupFilesAsset { #[turbo_tasks::function] async fn references(&self) -> Result> { let mut references: Vec>> = vec![Vc::upcast( - SingleModuleReference::new(Vc::upcast(self.module), module_description()), + SingleModuleReference::new(*ResolvedVc::upcast(self.module), module_description()), )]; if let Some(runtime_entries) = self.runtime_entries { @@ -91,8 +91,8 @@ impl Asset for ChunkGroupFilesAsset { impl ChunkableModule for ChunkGroupFilesAsset { #[turbo_tasks::function] async fn as_chunk_item( - self: Vc, - chunking_context: Vc>, + self: ResolvedVc, + chunking_context: ResolvedVc>, ) -> Result>> { let this = self.await?; Ok(Vc::upcast( @@ -116,9 +116,9 @@ impl EcmascriptChunkPlaceable for ChunkGroupFilesAsset { #[turbo_tasks::value] struct ChunkGroupFilesChunkItem { - chunking_context: Vc>, - client_root: Vc, - inner: Vc, + chunking_context: ResolvedVc>, + client_root: ResolvedVc, + inner: ResolvedVc, } #[turbo_tasks::value_impl] @@ -127,7 +127,7 @@ impl ChunkGroupFilesChunkItem { async fn chunks(&self) -> Result> { let inner = self.inner.await?; let chunks = if let Some(ecma) = - Vc::try_resolve_sidecast::>(inner.module).await? + ResolvedVc::try_sidecast::>(inner.module).await? { inner.chunking_context.evaluated_chunk_group_assets( inner.module.ident(), @@ -136,13 +136,13 @@ impl ChunkGroupFilesChunkItem { .as_deref() .copied() .unwrap_or_else(EvaluatableAssets::empty) - .with_entry(ecma), + .with_entry(*ecma), Value::new(AvailabilityInfo::Root), ) } else { inner .chunking_context - .root_chunk_group_assets(Vc::upcast(inner.module)) + .root_chunk_group_assets(*ResolvedVc::upcast(inner.module)) }; Ok(chunks) } @@ -152,7 +152,7 @@ impl ChunkGroupFilesChunkItem { impl EcmascriptChunkItem for ChunkGroupFilesChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - self.chunking_context + *self.chunking_context } #[turbo_tasks::function] @@ -217,7 +217,7 @@ impl ChunkItem for ChunkGroupFilesChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - Vc::upcast(self.chunking_context) + *ResolvedVc::upcast(self.chunking_context) } #[turbo_tasks::function] @@ -229,7 +229,7 @@ impl ChunkItem for ChunkGroupFilesChunkItem { #[turbo_tasks::function] fn module(&self) -> Vc> { - Vc::upcast(self.inner) + *ResolvedVc::upcast(self.inner) } } @@ -255,7 +255,7 @@ impl Introspectable for ChunkGroupFilesAsset { let mut children = FxIndexSet::default(); children.insert(( Vc::cell("inner asset".into()), - IntrospectableModule::new(Vc::upcast(self.module)), + IntrospectableModule::new(*ResolvedVc::upcast(self.module)), )); Vc::cell(children) } diff --git a/turbopack/crates/turbopack-ecmascript/src/global_module_id_strategy.rs b/turbopack/crates/turbopack-ecmascript/src/global_module_id_strategy.rs index 3892a7987e36c..788ff336febdb 100644 --- a/turbopack/crates/turbopack-ecmascript/src/global_module_id_strategy.rs +++ b/turbopack/crates/turbopack-ecmascript/src/global_module_id_strategy.rs @@ -24,14 +24,14 @@ pub struct PreprocessedChildrenIdents { #[derive(Clone, Hash)] #[turbo_tasks::value(shared)] pub enum ReferencedModule { - Module(Vc>), + Module(ResolvedVc>), AsyncLoaderModule(ResolvedVc>), } impl ReferencedModule { fn module(&self) -> Vc> { match *self { - ReferencedModule::Module(module) => module, + ReferencedModule::Module(module) => *module, ReferencedModule::AsyncLoaderModule(module) => *module, } } @@ -86,7 +86,7 @@ async fn referenced_modules(module: Vc>) -> Result>(), get_children_modules, ) diff --git a/turbopack/crates/turbopack-ecmascript/src/lib.rs b/turbopack/crates/turbopack-ecmascript/src/lib.rs index 8c809fb31a72d..72847ee32fe57 100644 --- a/turbopack/crates/turbopack-ecmascript/src/lib.rs +++ b/turbopack/crates/turbopack-ecmascript/src/lib.rs @@ -237,12 +237,12 @@ impl EcmascriptModuleAssetBuilder { #[turbo_tasks::value] pub struct EcmascriptModuleAsset { - pub source: Vc>, - pub asset_context: Vc>, + pub source: ResolvedVc>, + pub asset_context: ResolvedVc>, pub ty: EcmascriptModuleAssetType, - pub transforms: Vc, - pub options: Vc, - pub compile_time_info: Vc, + pub transforms: ResolvedVc, + pub options: ResolvedVc, + pub compile_time_info: ResolvedVc, pub inner_assets: Option>, #[turbo_tasks(debug_ignore)] last_successful_parse: turbo_tasks::TransientState>, @@ -380,22 +380,22 @@ impl EcmascriptAnalyzable for EcmascriptModuleAsset { chunking_context: Vc>, async_module_info: Option>, ) -> Result> { - let parsed = self.parse().resolve().await?; + let parsed = self.parse().to_resolved().await?; let analyze = self.analyze().await?; let module_type_result = *self.determine_module_type().await?; Ok(EcmascriptModuleContent::new( - parsed, + *parsed, self.ident(), module_type_result.module_type, chunking_context, - analyze.references, - analyze.code_generation, - analyze.async_module, + *analyze.references, + *analyze.code_generation, + *analyze.async_module, analyze.source_map, - analyze.exports, + *analyze.exports, async_module_info, )) } @@ -405,13 +405,13 @@ impl EcmascriptAnalyzable for EcmascriptModuleAsset { impl EcmascriptModuleAsset { #[turbo_tasks::function] pub fn new( - source: Vc>, - asset_context: Vc>, + source: ResolvedVc>, + asset_context: ResolvedVc>, ty: Value, - transforms: Vc, - options: Vc, - compile_time_info: Vc, + transforms: ResolvedVc, + options: ResolvedVc, + compile_time_info: ResolvedVc, ) -> Vc { Self::cell(EcmascriptModuleAsset { source, @@ -428,12 +428,12 @@ impl EcmascriptModuleAsset { #[turbo_tasks::function] pub fn new_with_inner_assets( - source: Vc>, - asset_context: Vc>, + source: ResolvedVc>, + asset_context: ResolvedVc>, ty: Value, - transforms: Vc, - options: Vc, - compile_time_info: Vc, + transforms: ResolvedVc, + options: ResolvedVc, + compile_time_info: ResolvedVc, inner_assets: ResolvedVc, ) -> Vc { Self::cell(EcmascriptModuleAsset { @@ -450,7 +450,7 @@ impl EcmascriptModuleAsset { #[turbo_tasks::function] pub fn source(&self) -> Vc> { - self.source + *self.source } #[turbo_tasks::function] @@ -460,12 +460,12 @@ impl EcmascriptModuleAsset { #[turbo_tasks::function] pub fn options(&self) -> Vc { - self.options + *self.options } #[turbo_tasks::function] pub fn parse(&self) -> Vc { - parse(self.source, Value::new(self.ty), self.transforms) + parse(*self.source, Value::new(self.ty), *self.transforms) } #[turbo_tasks::function] @@ -561,8 +561,8 @@ impl Asset for EcmascriptModuleAsset { impl ChunkableModule for EcmascriptModuleAsset { #[turbo_tasks::function] fn as_chunk_item( - self: Vc, - chunking_context: Vc>, + self: ResolvedVc, + chunking_context: ResolvedVc>, ) -> Vc> { Vc::upcast(ModuleChunkItem::cell(ModuleChunkItem { module: self, @@ -575,12 +575,12 @@ impl ChunkableModule for EcmascriptModuleAsset { impl EcmascriptChunkPlaceable for EcmascriptModuleAsset { #[turbo_tasks::function] async fn get_exports(self: Vc) -> Result> { - Ok(self.analyze().await?.exports) + Ok(*self.analyze().await?.exports) } #[turbo_tasks::function] async fn get_async_module(self: Vc) -> Result> { - Ok(self.analyze().await?.async_module) + Ok(*self.analyze().await?.async_module) } } @@ -596,7 +596,7 @@ impl ResolveOrigin for EcmascriptModuleAsset { #[turbo_tasks::function] fn asset_context(&self) -> Vc> { - self.asset_context + *self.asset_context } #[turbo_tasks::function] @@ -615,8 +615,8 @@ impl ResolveOrigin for EcmascriptModuleAsset { #[turbo_tasks::value] struct ModuleChunkItem { - module: Vc, - chunking_context: Vc>, + module: ResolvedVc, + chunking_context: ResolvedVc>, } #[turbo_tasks::value_impl] @@ -633,7 +633,7 @@ impl ChunkItem for ModuleChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - Vc::upcast(self.chunking_context) + *ResolvedVc::upcast(self.chunking_context) } #[turbo_tasks::function] @@ -645,13 +645,13 @@ impl ChunkItem for ModuleChunkItem { #[turbo_tasks::function] fn module(&self) -> Vc> { - Vc::upcast(self.module) + *ResolvedVc::upcast(self.module) } #[turbo_tasks::function] async fn is_self_async(&self) -> Result> { if let Some(async_module) = *self.module.get_async_module().await? { - Ok(async_module.is_self_async(self.module.analyze().await?.references)) + Ok(async_module.is_self_async(*self.module.analyze().await?.references)) } else { Ok(Vc::cell(false)) } @@ -662,7 +662,7 @@ impl ChunkItem for ModuleChunkItem { impl EcmascriptChunkItem for ModuleChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - self.chunking_context + *self.chunking_context } #[turbo_tasks::function] @@ -689,11 +689,11 @@ impl EcmascriptChunkItem for ModuleChunkItem { // TODO check if we need to pass async_module_info at all let content = this .module - .module_content(this.chunking_context, async_module_info); + .module_content(*this.chunking_context, async_module_info); Ok(EcmascriptChunkItemContent::new( content, - this.chunking_context, + *this.chunking_context, this.module.options(), async_module_options, )) diff --git a/turbopack/crates/turbopack-ecmascript/src/manifest/chunk_asset.rs b/turbopack/crates/turbopack-ecmascript/src/manifest/chunk_asset.rs index 2b80d98db3bcf..c2e12e2b25e88 100644 --- a/turbopack/crates/turbopack-ecmascript/src/manifest/chunk_asset.rs +++ b/turbopack/crates/turbopack-ecmascript/src/manifest/chunk_asset.rs @@ -1,6 +1,6 @@ use anyhow::Result; use turbo_rcstr::RcStr; -use turbo_tasks::{Value, Vc}; +use turbo_tasks::{ResolvedVc, Value, Vc}; use turbopack_core::{ asset::{Asset, AssetContent}, chunk::{ @@ -33,17 +33,17 @@ fn modifier() -> Vc { /// import appears in. #[turbo_tasks::value(shared)] pub struct ManifestAsyncModule { - pub inner: Vc>, - pub chunking_context: Vc>, + pub inner: ResolvedVc>, + pub chunking_context: ResolvedVc>, pub availability_info: AvailabilityInfo, } #[turbo_tasks::value_impl] impl ManifestAsyncModule { #[turbo_tasks::function] - pub fn new( - module: Vc>, - chunking_context: Vc>, + pub async fn new( + module: ResolvedVc>, + chunking_context: ResolvedVc>, availability_info: Value, ) -> Vc { Self::cell(ManifestAsyncModule { @@ -55,8 +55,10 @@ impl ManifestAsyncModule { #[turbo_tasks::function] pub(super) fn chunks(&self) -> Vc { - self.chunking_context - .chunk_group_assets(Vc::upcast(self.inner), Value::new(self.availability_info)) + self.chunking_context.chunk_group_assets( + *ResolvedVc::upcast(self.inner), + Value::new(self.availability_info), + ) } #[turbo_tasks::function] @@ -66,7 +68,7 @@ impl ManifestAsyncModule { if chunk_items .get( this.inner - .as_chunk_item(Vc::upcast(this.chunking_context)) + .as_chunk_item(*ResolvedVc::upcast(this.chunking_context)) .resolve() .await?, ) @@ -140,9 +142,9 @@ impl Asset for ManifestAsyncModule { #[turbo_tasks::value_impl] impl ChunkableModule for ManifestAsyncModule { #[turbo_tasks::function] - fn as_chunk_item( - self: Vc, - chunking_context: Vc>, + async fn as_chunk_item( + self: ResolvedVc, + chunking_context: ResolvedVc>, ) -> Vc> { Vc::upcast( ManifestChunkItem { diff --git a/turbopack/crates/turbopack-ecmascript/src/manifest/chunk_item.rs b/turbopack/crates/turbopack-ecmascript/src/manifest/chunk_item.rs index 33e3f85e776f3..47471b11206a9 100644 --- a/turbopack/crates/turbopack-ecmascript/src/manifest/chunk_item.rs +++ b/turbopack/crates/turbopack-ecmascript/src/manifest/chunk_item.rs @@ -1,6 +1,6 @@ use anyhow::Result; use indoc::formatdoc; -use turbo_tasks::{TryJoinIterExt, Vc}; +use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc}; use turbopack_core::{ chunk::{ChunkData, ChunkItem, ChunkType, ChunkingContext, ChunksData}, ident::AssetIdent, @@ -22,8 +22,8 @@ use crate::{ /// __turbopack_import__ the actual module that was dynamically imported. #[turbo_tasks::value(shared)] pub(super) struct ManifestChunkItem { - pub chunking_context: Vc>, - pub manifest: Vc, + pub chunking_context: ResolvedVc>, + pub manifest: ResolvedVc, } #[turbo_tasks::value_impl] @@ -38,7 +38,7 @@ impl ManifestChunkItem { impl EcmascriptChunkItem for ManifestChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - self.chunking_context + *self.chunking_context } #[turbo_tasks::function] @@ -95,7 +95,7 @@ impl ChunkItem for ManifestChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - Vc::upcast(self.chunking_context) + *ResolvedVc::upcast(self.chunking_context) } #[turbo_tasks::function] @@ -107,6 +107,6 @@ impl ChunkItem for ManifestChunkItem { #[turbo_tasks::function] fn module(&self) -> Vc> { - Vc::upcast(self.manifest) + *ResolvedVc::upcast(self.manifest) } } diff --git a/turbopack/crates/turbopack-ecmascript/src/manifest/loader_item.rs b/turbopack/crates/turbopack-ecmascript/src/manifest/loader_item.rs index 3c3d9c3e87fd5..fbfefe9294e1c 100644 --- a/turbopack/crates/turbopack-ecmascript/src/manifest/loader_item.rs +++ b/turbopack/crates/turbopack-ecmascript/src/manifest/loader_item.rs @@ -3,7 +3,7 @@ use std::io::Write as _; use anyhow::{anyhow, Result}; use indoc::writedoc; use turbo_rcstr::RcStr; -use turbo_tasks::{TryJoinIterExt, Vc}; +use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc}; use turbopack_core::{ chunk::{ ChunkData, ChunkItem, ChunkItemExt, ChunkType, ChunkableModule, ChunkingContext, ChunksData, @@ -43,16 +43,16 @@ fn modifier() -> Vc { /// import appears in. #[turbo_tasks::value] pub struct ManifestLoaderChunkItem { - manifest: Vc, - chunking_context: Vc>, + manifest: ResolvedVc, + chunking_context: ResolvedVc>, } #[turbo_tasks::value_impl] impl ManifestLoaderChunkItem { #[turbo_tasks::function] pub fn new( - manifest: Vc, - chunking_context: Vc>, + manifest: ResolvedVc, + chunking_context: ResolvedVc>, ) -> Vc { Self::cell(ManifestLoaderChunkItem { manifest, @@ -125,7 +125,7 @@ impl ChunkItem for ManifestLoaderChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - Vc::upcast(self.chunking_context) + *ResolvedVc::upcast(self.chunking_context) } #[turbo_tasks::function] @@ -137,7 +137,7 @@ impl ChunkItem for ManifestLoaderChunkItem { #[turbo_tasks::function] fn module(&self) -> Vc> { - Vc::upcast(self.manifest) + *ResolvedVc::upcast(self.manifest) } } @@ -145,7 +145,7 @@ impl ChunkItem for ManifestLoaderChunkItem { impl EcmascriptChunkItem for ManifestLoaderChunkItem { #[turbo_tasks::function] async fn chunking_context(&self) -> Result>> { - Ok(self.manifest.await?.chunking_context) + Ok(*self.manifest.await?.chunking_context) } #[turbo_tasks::function] @@ -165,18 +165,18 @@ impl EcmascriptChunkItem for ManifestLoaderChunkItem { // exports a promise for all of the necessary chunk loads. let item_id = &*this .manifest - .as_chunk_item(Vc::upcast(manifest.chunking_context)) + .as_chunk_item(*ResolvedVc::upcast(manifest.chunking_context)) .id() .await?; // Finally, we need the id of the module that we're actually trying to // dynamically import. let placeable = - Vc::try_resolve_downcast::>(manifest.inner) + ResolvedVc::try_downcast::>(manifest.inner) .await? .ok_or_else(|| anyhow!("asset is not placeable in ecmascript chunk"))?; let dynamic_id = &*placeable - .as_chunk_item(Vc::upcast(manifest.chunking_context)) + .as_chunk_item(*ResolvedVc::upcast(manifest.chunking_context)) .id() .await?; diff --git a/turbopack/crates/turbopack-ecmascript/src/parse.rs b/turbopack/crates/turbopack-ecmascript/src/parse.rs index a56884b5473e8..4524a3067512b 100644 --- a/turbopack/crates/turbopack-ecmascript/src/parse.rs +++ b/turbopack/crates/turbopack-ecmascript/src/parse.rs @@ -22,7 +22,7 @@ use swc_core::{ }; use tracing::Instrument; use turbo_rcstr::RcStr; -use turbo_tasks::{util::WrapFuture, Value, ValueToString, Vc}; +use turbo_tasks::{util::WrapFuture, ResolvedVc, Value, ValueToString, Vc}; use turbo_tasks_fs::{FileContent, FileSystemPath}; use turbo_tasks_hash::hash_xxh3_hash64; use turbopack_core::{ @@ -155,7 +155,7 @@ impl SourceMapGenConfig for InlineSourcesContentConfig { #[turbo_tasks::function] pub async fn parse( - source: Vc>, + source: ResolvedVc>, ty: Value, transforms: Vc, ) -> Result> { @@ -174,7 +174,7 @@ pub async fn parse( } async fn parse_internal( - source: Vc>, + source: ResolvedVc>, ty: Value, transforms: Vc, ) -> Result> { @@ -253,7 +253,7 @@ async fn parse_file_content( fs_path: &FileSystemPath, ident: &str, file_path_hash: u128, - source: Vc>, + source: ResolvedVc>, ty: EcmascriptModuleAssetType, transforms: &[EcmascriptInputTransform], ) -> Result> { @@ -262,14 +262,14 @@ async fn parse_file_content( true, false, Box::new(IssueEmitter::new( - source, + *source, source_map.clone(), Some("Ecmascript file had an error".into()), )), ); let emitter = Box::new(IssueEmitter::new( - source, + *source, source_map.clone(), Some("Parsing ecmascript source code failed".into()), )); @@ -396,7 +396,7 @@ async fn parse_file_content( file_path_str: &fs_path.path, file_name_str: fs_path.file_name(), file_name_hash: file_path_hash, - file_path: fs_path_vc, + file_path: fs_path_vc.to_resolved().await?, }; let span = tracing::trace_span!("transforms"); async { @@ -435,7 +435,7 @@ async fn parse_file_content( unresolved_mark, top_level_mark, Some(&comments), - Some(source), + Some(*source), ); Ok::(ParseResult::Ok { @@ -467,7 +467,7 @@ async fn parse_file_content( #[turbo_tasks::value] struct ReadSourceIssue { - source: Vc>, + source: ResolvedVc>, error: RcStr, } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/amd.rs b/turbopack/crates/turbopack-ecmascript/src/references/amd.rs index bfe7b2d84a11b..eb66b6801c9b8 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/amd.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/amd.rs @@ -12,7 +12,8 @@ use swc_core::{ }; use turbo_rcstr::RcStr; use turbo_tasks::{ - debug::ValueDebugFormat, trace::TraceRawVcs, ReadRef, TryJoinIterExt, Value, ValueToString, Vc, + debug::ValueDebugFormat, trace::TraceRawVcs, ReadRef, ResolvedVc, TryJoinIterExt, Value, + ValueToString, Vc, }; use turbopack_core::{ chunk::{ChunkableModuleReference, ChunkingContext}, @@ -32,9 +33,9 @@ use crate::{ #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct AmdDefineAssetReference { - origin: Vc>, - request: Vc, - issue_source: Vc, + origin: ResolvedVc>, + request: ResolvedVc, + issue_source: ResolvedVc, in_try: bool, } @@ -42,9 +43,9 @@ pub struct AmdDefineAssetReference { impl AmdDefineAssetReference { #[turbo_tasks::function] pub fn new( - origin: Vc>, - request: Vc, - issue_source: Vc, + origin: ResolvedVc>, + request: ResolvedVc, + issue_source: ResolvedVc, in_try: bool, ) -> Vc { Self::cell(AmdDefineAssetReference { @@ -61,9 +62,9 @@ impl ModuleReference for AmdDefineAssetReference { #[turbo_tasks::function] fn resolve_reference(&self) -> Vc { cjs_resolve( - self.origin, - self.request, - Some(self.issue_source), + *self.origin, + *self.request, + Some(*self.issue_source), self.in_try, ) } @@ -107,7 +108,7 @@ pub enum AmdDefineFactoryType { pub struct AmdDefineWithDependenciesCodeGen { dependencies_requests: Vec, origin: Vc>, - path: Vc, + path: ResolvedVc, factory_type: AmdDefineFactoryType, issue_source: Vc, in_try: bool, @@ -117,7 +118,7 @@ impl AmdDefineWithDependenciesCodeGen { pub fn new( dependencies_requests: Vec, origin: Vc>, - path: Vc, + path: ResolvedVc, factory_type: AmdDefineFactoryType, issue_source: Vc, in_try: bool, diff --git a/turbopack/crates/turbopack-ecmascript/src/references/cjs.rs b/turbopack/crates/turbopack-ecmascript/src/references/cjs.rs index 22f671935044e..14ebf2d85ef8e 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/cjs.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/cjs.rs @@ -5,7 +5,7 @@ use swc_core::{ quote, }; use turbo_rcstr::RcStr; -use turbo_tasks::{Value, ValueToString, Vc}; +use turbo_tasks::{ResolvedVc, Value, ValueToString, Vc}; use turbopack_core::{ chunk::{ChunkableModuleReference, ChunkingContext}, issue::IssueSource, @@ -24,27 +24,27 @@ use crate::{ #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct CjsAssetReference { - pub origin: Vc>, - pub request: Vc, - pub issue_source: Vc, + pub origin: ResolvedVc>, + pub request: ResolvedVc, + pub issue_source: ResolvedVc, pub in_try: bool, } #[turbo_tasks::value_impl] impl CjsAssetReference { #[turbo_tasks::function] - pub fn new( - origin: Vc>, - request: Vc, - issue_source: Vc, + pub async fn new( + origin: ResolvedVc>, + request: ResolvedVc, + issue_source: ResolvedVc, in_try: bool, - ) -> Vc { - Self::cell(CjsAssetReference { + ) -> Result> { + Ok(Self::cell(CjsAssetReference { origin, request, issue_source, in_try, - }) + })) } } @@ -53,9 +53,9 @@ impl ModuleReference for CjsAssetReference { #[turbo_tasks::function] fn resolve_reference(&self) -> Vc { cjs_resolve( - self.origin, - self.request, - Some(self.issue_source), + *self.origin, + *self.request, + Some(*self.issue_source), self.in_try, ) } @@ -77,10 +77,10 @@ impl ChunkableModuleReference for CjsAssetReference {} #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct CjsRequireAssetReference { - pub origin: Vc>, - pub request: Vc, - pub path: Vc, - pub issue_source: Vc, + pub origin: ResolvedVc>, + pub request: ResolvedVc, + pub path: ResolvedVc, + pub issue_source: ResolvedVc, pub in_try: bool, } @@ -88,10 +88,10 @@ pub struct CjsRequireAssetReference { impl CjsRequireAssetReference { #[turbo_tasks::function] pub fn new( - origin: Vc>, - request: Vc, - path: Vc, - issue_source: Vc, + origin: ResolvedVc>, + request: ResolvedVc, + path: ResolvedVc, + issue_source: ResolvedVc, in_try: bool, ) -> Vc { Self::cell(CjsRequireAssetReference { @@ -109,9 +109,9 @@ impl ModuleReference for CjsRequireAssetReference { #[turbo_tasks::function] fn resolve_reference(&self) -> Vc { cjs_resolve( - self.origin, - self.request, - Some(self.issue_source), + *self.origin, + *self.request, + Some(*self.issue_source), self.in_try, ) } @@ -138,13 +138,13 @@ impl CodeGenerateable for CjsRequireAssetReference { chunking_context: Vc>, ) -> Result> { let pm = PatternMapping::resolve_request( - self.request, - self.origin, + *self.request, + *self.origin, Vc::upcast(chunking_context), cjs_resolve( - self.origin, - self.request, - Some(self.issue_source), + *self.origin, + *self.request, + Some(*self.issue_source), self.in_try, ), Value::new(ChunkItem), @@ -184,10 +184,10 @@ impl CodeGenerateable for CjsRequireAssetReference { #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct CjsRequireResolveAssetReference { - pub origin: Vc>, - pub request: Vc, - pub path: Vc, - pub issue_source: Vc, + pub origin: ResolvedVc>, + pub request: ResolvedVc, + pub path: ResolvedVc, + pub issue_source: ResolvedVc, pub in_try: bool, } @@ -195,10 +195,10 @@ pub struct CjsRequireResolveAssetReference { impl CjsRequireResolveAssetReference { #[turbo_tasks::function] pub fn new( - origin: Vc>, - request: Vc, - path: Vc, - issue_source: Vc, + origin: ResolvedVc>, + request: ResolvedVc, + path: ResolvedVc, + issue_source: ResolvedVc, in_try: bool, ) -> Vc { Self::cell(CjsRequireResolveAssetReference { @@ -216,9 +216,9 @@ impl ModuleReference for CjsRequireResolveAssetReference { #[turbo_tasks::function] fn resolve_reference(&self) -> Vc { cjs_resolve( - self.origin, - self.request, - Some(self.issue_source), + *self.origin, + *self.request, + Some(*self.issue_source), self.in_try, ) } @@ -245,13 +245,13 @@ impl CodeGenerateable for CjsRequireResolveAssetReference { chunking_context: Vc>, ) -> Result> { let pm = PatternMapping::resolve_request( - self.request, - self.origin, + *self.request, + *self.origin, Vc::upcast(chunking_context), cjs_resolve( - self.origin, - self.request, - Some(self.issue_source), + *self.origin, + *self.request, + Some(*self.issue_source), self.in_try, ), Value::new(ChunkItem), @@ -295,7 +295,7 @@ impl CodeGenerateable for CjsRequireResolveAssetReference { #[turbo_tasks::value(shared)] #[derive(Hash, Debug)] pub struct CjsRequireCacheAccess { - pub path: Vc, + pub path: ResolvedVc, } #[turbo_tasks::value_impl] diff --git a/turbopack/crates/turbopack-ecmascript/src/references/constant_condition.rs b/turbopack/crates/turbopack-ecmascript/src/references/constant_condition.rs index 2bfc2302f4aa4..1c9281f827d5c 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/constant_condition.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/constant_condition.rs @@ -1,6 +1,6 @@ use anyhow::Result; use swc_core::quote; -use turbo_tasks::{Value, Vc}; +use turbo_tasks::{ResolvedVc, Value, Vc}; use turbopack_core::chunk::ChunkingContext; use super::AstPath; @@ -20,13 +20,13 @@ pub enum ConstantConditionValue { #[turbo_tasks::value] pub struct ConstantCondition { value: ConstantConditionValue, - path: Vc, + path: ResolvedVc, } #[turbo_tasks::value_impl] impl ConstantCondition { #[turbo_tasks::function] - pub fn new(value: Value, path: Vc) -> Vc { + pub fn new(value: Value, path: ResolvedVc) -> Vc { Self::cell(ConstantCondition { value: value.into_value(), path, diff --git a/turbopack/crates/turbopack-ecmascript/src/references/constant_value.rs b/turbopack/crates/turbopack-ecmascript/src/references/constant_value.rs index 0af779f4f9158..7f67eb007156e 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/constant_value.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/constant_value.rs @@ -1,6 +1,6 @@ use anyhow::Result; use swc_core::quote; -use turbo_tasks::{Value, Vc}; +use turbo_tasks::{ResolvedVc, Value, Vc}; use turbopack_core::{chunk::ChunkingContext, compile_time_info::CompileTimeDefineValue}; use super::AstPath; @@ -12,13 +12,13 @@ use crate::{ #[turbo_tasks::value] pub struct ConstantValue { value: CompileTimeDefineValue, - path: Vc, + path: ResolvedVc, } #[turbo_tasks::value_impl] impl ConstantValue { #[turbo_tasks::function] - pub fn new(value: Value, path: Vc) -> Vc { + pub fn new(value: Value, path: ResolvedVc) -> Vc { Self::cell(ConstantValue { value: value.into_value(), path, diff --git a/turbopack/crates/turbopack-ecmascript/src/references/dynamic_expression.rs b/turbopack/crates/turbopack-ecmascript/src/references/dynamic_expression.rs index 662f8cc58042c..2d7dc4ee372ae 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/dynamic_expression.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/dynamic_expression.rs @@ -1,7 +1,7 @@ use anyhow::Result; use serde::{Deserialize, Serialize}; use swc_core::quote; -use turbo_tasks::{debug::ValueDebugFormat, trace::TraceRawVcs, Vc}; +use turbo_tasks::{debug::ValueDebugFormat, trace::TraceRawVcs, ResolvedVc, Vc}; use turbopack_core::chunk::ChunkingContext; use super::AstPath; @@ -18,14 +18,14 @@ enum DynamicExpressionType { #[turbo_tasks::value] pub struct DynamicExpression { - path: Vc, + path: ResolvedVc, ty: DynamicExpressionType, } #[turbo_tasks::value_impl] impl DynamicExpression { #[turbo_tasks::function] - pub fn new(path: Vc) -> Vc { + pub fn new(path: ResolvedVc) -> Vc { Self::cell(DynamicExpression { path, ty: DynamicExpressionType::Normal, @@ -33,7 +33,7 @@ impl DynamicExpression { } #[turbo_tasks::function] - pub fn new_promise(path: Vc) -> Vc { + pub fn new_promise(path: ResolvedVc) -> Vc { Self::cell(DynamicExpression { path, ty: DynamicExpressionType::Promise, diff --git a/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs b/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs index 3569fd2d6cf62..46559061626cb 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs @@ -102,17 +102,17 @@ impl ReferencedAsset { #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct EsmAssetReference { - pub origin: Vc>, - pub request: Vc, + pub origin: ResolvedVc>, + pub request: ResolvedVc, pub annotations: ImportAnnotations, - pub issue_source: Vc, + pub issue_source: ResolvedVc, pub export_name: Option>, pub import_externals: bool, } impl EsmAssetReference { fn get_origin(&self) -> Vc> { - let mut origin = self.origin; + let mut origin = *self.origin; if let Some(transition) = self.annotations.transition() { origin = origin.with_transition(transition.into()); } @@ -124,9 +124,9 @@ impl EsmAssetReference { impl EsmAssetReference { #[turbo_tasks::function] pub fn new( - origin: Vc>, - request: Vc, - issue_source: Vc, + origin: ResolvedVc>, + request: ResolvedVc, + issue_source: ResolvedVc, annotations: Value, export_name: Option>, import_externals: bool, @@ -162,13 +162,13 @@ impl ModuleReference for EsmAssetReference { if let Request::Module { module, .. } = &*self.request.await? { if module == TURBOPACK_PART_IMPORT_SOURCE { if let Some(part) = self.export_name { - let module: Vc = - Vc::try_resolve_downcast_type(self.origin) + let module: ResolvedVc = + ResolvedVc::try_downcast_type(self.origin) .await? .expect("EsmAssetReference origin should be a EcmascriptModuleAsset"); return Ok(ModuleResolveResult::module( - EcmascriptModulePartAsset::select_part(module, *part) + EcmascriptModulePartAsset::select_part(*module, *part) .to_resolved() .await?, ) @@ -181,10 +181,10 @@ impl ModuleReference for EsmAssetReference { let result = esm_resolve( self.get_origin().resolve().await?, - self.request, + *self.request, Value::new(ty), false, - Some(self.issue_source), + Some(*self.issue_source), ); if let Some(part) = self.export_name { @@ -195,8 +195,8 @@ impl ModuleReference for EsmAssetReference { let export = export_name.await?; if *is_export_missing(*module, export.clone_value()).await? { InvalidExport { - export: *export_name, - module: *module, + export: export_name, + module, source: self.issue_source, } .cell() @@ -260,7 +260,7 @@ impl CodeGenerateable for EsmAssetReference { if let ReferencedAsset::Unresolvable = &*referenced_asset { // Insert code that throws immediately at time of import if a request is // unresolvable - let request = request_to_string(this.request).await?.to_string(); + let request = request_to_string(*this.request).await?.to_string(); let stmt = Stmt::Expr(ExprStmt { expr: Box::new(throw_module_not_found_expr(&request)), span: DUMMY_SP, @@ -392,9 +392,9 @@ fn var_decl_with_span(mut decl: Stmt, span: Span) -> Stmt { #[turbo_tasks::value(shared)] pub struct InvalidExport { - export: Vc, - module: Vc>, - source: Vc, + export: ResolvedVc, + module: ResolvedVc>, + source: ResolvedVc, } #[turbo_tasks::value_impl] @@ -427,7 +427,7 @@ impl Issue for InvalidExport { #[turbo_tasks::function] async fn description(&self) -> Result> { let export = self.export.await?; - let export_names = all_known_export_names(self.module).await?; + let export_names = all_known_export_names(*self.module).await?; let did_you_mean = export_names .iter() .map(|s| (s, jaro(export.as_str(), s.as_str()))) @@ -463,7 +463,7 @@ impl Issue for InvalidExport { #[turbo_tasks::function] async fn detail(&self) -> Result> { - let export_names = all_known_export_names(self.module).await?; + let export_names = all_known_export_names(*self.module).await?; Ok(Vc::cell(Some( StyledString::Line(vec![ StyledString::Text("These are the exports of the module:\n".into()), @@ -482,6 +482,6 @@ impl Issue for InvalidExport { #[turbo_tasks::function] fn source(&self) -> Vc { - Vc::cell(Some(self.source)) + Vc::cell(Some(*self.source)) } } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/esm/binding.rs b/turbopack/crates/turbopack-ecmascript/src/references/esm/binding.rs index 72db76eaa6dc8..9745a0de363c9 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/esm/binding.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/esm/binding.rs @@ -14,7 +14,7 @@ use swc_core::{ }, }; use turbo_rcstr::RcStr; -use turbo_tasks::{trace::TraceRawVcs, TaskInput, Vc}; +use turbo_tasks::{trace::TraceRawVcs, ResolvedVc, TaskInput, Vc}; use turbopack_core::chunk::ChunkingContext; use super::EsmAssetReference; @@ -42,14 +42,14 @@ impl EsmBindings { pub struct EsmBinding { pub reference: Vc, pub export: Option, - pub ast_path: Vc, + pub ast_path: ResolvedVc, } impl EsmBinding { pub fn new( reference: Vc, export: Option, - ast_path: Vc, + ast_path: ResolvedVc, ) -> Self { EsmBinding { reference, diff --git a/turbopack/crates/turbopack-ecmascript/src/references/esm/dynamic.rs b/turbopack/crates/turbopack-ecmascript/src/references/esm/dynamic.rs index 583558df81479..fb8b9140ddf5a 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/esm/dynamic.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/esm/dynamic.rs @@ -5,7 +5,7 @@ use swc_core::{ quote_expr, }; use turbo_rcstr::RcStr; -use turbo_tasks::{Value, ValueToString, Vc}; +use turbo_tasks::{ResolvedVc, Value, ValueToString, Vc}; use turbopack_core::{ chunk::{ChunkableModuleReference, ChunkingContext, ChunkingType, ChunkingTypeOption}, environment::ChunkLoading, @@ -26,10 +26,10 @@ use crate::{ #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct EsmAsyncAssetReference { - pub origin: Vc>, - pub request: Vc, - pub path: Vc, - pub issue_source: Vc, + pub origin: ResolvedVc>, + pub request: ResolvedVc, + pub path: ResolvedVc, + pub issue_source: ResolvedVc, pub in_try: bool, pub import_externals: bool, } @@ -38,10 +38,10 @@ pub struct EsmAsyncAssetReference { impl EsmAsyncAssetReference { #[turbo_tasks::function] pub fn new( - origin: Vc>, - request: Vc, - path: Vc, - issue_source: Vc, + origin: ResolvedVc>, + request: ResolvedVc, + path: ResolvedVc, + issue_source: ResolvedVc, in_try: bool, import_externals: bool, ) -> Vc { @@ -61,11 +61,11 @@ impl ModuleReference for EsmAsyncAssetReference { #[turbo_tasks::function] fn resolve_reference(&self) -> Vc { esm_resolve( - self.origin, - self.request, + *self.origin, + *self.request, Value::new(EcmaScriptModulesReferenceSubType::DynamicImport), self.in_try, - Some(self.issue_source), + Some(*self.issue_source), ) } } @@ -96,15 +96,15 @@ impl CodeGenerateable for EsmAsyncAssetReference { chunking_context: Vc>, ) -> Result> { let pm = PatternMapping::resolve_request( - self.request, - self.origin, + *self.request, + *self.origin, Vc::upcast(chunking_context), esm_resolve( - self.origin, - self.request, + *self.origin, + *self.request, Value::new(EcmaScriptModulesReferenceSubType::DynamicImport), self.in_try, - Some(self.issue_source), + Some(*self.issue_source), ), if matches!( *chunking_context.environment().chunk_loading().await?, diff --git a/turbopack/crates/turbopack-ecmascript/src/references/esm/export.rs b/turbopack/crates/turbopack-ecmascript/src/references/esm/export.rs index 0ecd7779bb7c7..e853a06886d4b 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/esm/export.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/esm/export.rs @@ -52,7 +52,7 @@ pub enum EsmExport { #[turbo_tasks::function] pub async fn is_export_missing( - module: Vc>, + module: ResolvedVc>, export_name: RcStr, ) -> Result> { let exports = module.get_exports().await?; @@ -77,7 +77,7 @@ pub async fn is_export_missing( return Ok(Vc::cell(true)); } - let all_export_names = get_all_export_names(module).await?; + let all_export_names = get_all_export_names(*module).await?; if all_export_names.esm_exports.contains_key(&export_name) { return Ok(Vc::cell(false)); } @@ -438,7 +438,7 @@ impl EsmExports { let mut exports: BTreeMap = self.exports.clone(); let mut dynamic_exports = vec![]; - for esm_ref in self.star_exports.iter() { + for &esm_ref in self.star_exports.iter() { // TODO(PACK-2176): we probably need to handle re-exporting from external // modules. let ReferencedAsset::Some(asset) = @@ -453,7 +453,7 @@ impl EsmExports { if !exports.contains_key(export) { exports.insert( export.clone(), - EsmExport::ImportedBinding(Vc::upcast(*esm_ref), export.clone(), false), + EsmExport::ImportedBinding(Vc::upcast(esm_ref), export.clone(), false), ); } } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/esm/meta.rs b/turbopack/crates/turbopack-ecmascript/src/references/esm/meta.rs index 725cd5c8f3398..c6c8e17e85a46 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/esm/meta.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/esm/meta.rs @@ -6,7 +6,7 @@ use swc_core::{ ecma::ast::{Expr, Ident}, quote, }; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::chunk::ChunkingContext; @@ -24,13 +24,13 @@ use crate::{ #[turbo_tasks::value(shared)] #[derive(Hash, Debug)] pub struct ImportMetaBinding { - path: Vc, + path: ResolvedVc, } #[turbo_tasks::value_impl] impl ImportMetaBinding { #[turbo_tasks::function] - pub fn new(path: Vc) -> Vc { + pub fn new(path: ResolvedVc) -> Vc { ImportMetaBinding { path }.cell() } } @@ -42,7 +42,7 @@ impl CodeGenerateable for ImportMetaBinding { &self, _context: Vc>, ) -> Result> { - let path = as_abs_path(self.path).await?.as_str().map_or_else( + let path = as_abs_path(*self.path).await?.as_str().map_or_else( || { quote!( "(() => { throw new Error('could not convert import.meta.url to filepath') })()" @@ -79,13 +79,13 @@ impl CodeGenerateable for ImportMetaBinding { #[turbo_tasks::value(shared)] #[derive(Hash, Debug)] pub struct ImportMetaRef { - ast_path: Vc, + ast_path: ResolvedVc, } #[turbo_tasks::value_impl] impl ImportMetaRef { #[turbo_tasks::function] - pub fn new(ast_path: Vc) -> Vc { + pub fn new(ast_path: ResolvedVc) -> Vc { ImportMetaRef { ast_path }.cell() } } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/esm/module_id.rs b/turbopack/crates/turbopack-ecmascript/src/references/esm/module_id.rs index 2599a9fd14ab0..9c862dc2788d5 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/esm/module_id.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/esm/module_id.rs @@ -1,7 +1,7 @@ use anyhow::Result; use swc_core::quote; use turbo_rcstr::RcStr; -use turbo_tasks::{ValueToString, Vc}; +use turbo_tasks::{ResolvedVc, ValueToString, Vc}; use turbopack_core::{ chunk::{ ChunkItemExt, ChunkableModule, ChunkableModuleReference, ChunkingContext, @@ -22,14 +22,14 @@ use crate::{ #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct EsmModuleIdAssetReference { - inner: Vc, - ast_path: Vc, + inner: ResolvedVc, + ast_path: ResolvedVc, } #[turbo_tasks::value_impl] impl EsmModuleIdAssetReference { #[turbo_tasks::function] - pub fn new(inner: Vc, ast_path: Vc) -> Vc { + pub fn new(inner: ResolvedVc, ast_path: ResolvedVc) -> Vc { Self::cell(EsmModuleIdAssetReference { inner, ast_path }) } } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/esm/module_item.rs b/turbopack/crates/turbopack-ecmascript/src/references/esm/module_item.rs index ed6eb98524ee4..42295911f5300 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/esm/module_item.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/esm/module_item.rs @@ -9,7 +9,7 @@ use swc_core::{ }, quote, }; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack_core::chunk::ChunkingContext; use crate::{ @@ -24,13 +24,13 @@ use crate::{ #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct EsmModuleItem { - pub path: Vc, + pub path: ResolvedVc, } #[turbo_tasks::value_impl] impl EsmModuleItem { #[turbo_tasks::function] - pub fn new(path: Vc) -> Vc { + pub fn new(path: ResolvedVc) -> Vc { Self::cell(EsmModuleItem { path }) } } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/esm/url.rs b/turbopack/crates/turbopack-ecmascript/src/references/esm/url.rs index 3afbd26b18f55..ac61807f15b51 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/esm/url.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/esm/url.rs @@ -4,7 +4,7 @@ use swc_core::{ quote, }; use turbo_rcstr::RcStr; -use turbo_tasks::{Value, ValueToString, Vc}; +use turbo_tasks::{ResolvedVc, Value, ValueToString, Vc}; use turbopack_core::{ chunk::{ ChunkItemExt, ChunkableModule, ChunkableModuleReference, ChunkingContext, ChunkingType, @@ -48,26 +48,26 @@ pub enum UrlRewriteBehavior { /// referenced file to be imported/fetched/etc. #[turbo_tasks::value] pub struct UrlAssetReference { - origin: Vc>, - request: Vc, - rendering: Vc, - ast_path: Vc, - issue_source: Vc, + origin: ResolvedVc>, + request: ResolvedVc, + rendering: ResolvedVc, + ast_path: ResolvedVc, + issue_source: ResolvedVc, in_try: bool, - url_rewrite_behavior: Vc, + url_rewrite_behavior: ResolvedVc, } #[turbo_tasks::value_impl] impl UrlAssetReference { #[turbo_tasks::function] pub fn new( - origin: Vc>, - request: Vc, - rendering: Vc, - ast_path: Vc, - issue_source: Vc, + origin: ResolvedVc>, + request: ResolvedVc, + rendering: ResolvedVc, + ast_path: ResolvedVc, + issue_source: ResolvedVc, in_try: bool, - url_rewrite_behavior: Vc, + url_rewrite_behavior: ResolvedVc, ) -> Vc { UrlAssetReference { origin, @@ -92,10 +92,10 @@ impl ModuleReference for UrlAssetReference { #[turbo_tasks::function] fn resolve_reference(&self) -> Vc { url_resolve( - self.origin, - self.request, + *self.origin, + *self.request, Value::new(ReferenceType::Url(UrlReferenceSubType::EcmaScriptNewUrl)), - Some(self.issue_source), + Some(*self.issue_source), self.in_try, ) } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/external_module.rs b/turbopack/crates/turbopack-ecmascript/src/references/external_module.rs index 27a3d7b3e27a2..c4795aa3e0d01 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/external_module.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/external_module.rs @@ -3,7 +3,7 @@ use std::{fmt::Display, io::Write}; use anyhow::Result; use serde::{Deserialize, Serialize}; use turbo_rcstr::RcStr; -use turbo_tasks::{trace::TraceRawVcs, TaskInput, Vc}; +use turbo_tasks::{trace::TraceRawVcs, ResolvedVc, TaskInput, Vc}; use turbo_tasks_fs::{glob::Glob, rope::RopeBuilder, FileContent, FileSystem, VirtualFileSystem}; use turbopack_core::{ asset::{Asset, AssetContent}, @@ -124,8 +124,8 @@ impl Asset for CachedExternalModule { impl ChunkableModule for CachedExternalModule { #[turbo_tasks::function] fn as_chunk_item( - self: Vc, - chunking_context: Vc>, + self: ResolvedVc, + chunking_context: ResolvedVc>, ) -> Vc> { Vc::upcast( CachedExternalModuleChunkItem { @@ -176,8 +176,8 @@ impl EcmascriptChunkPlaceable for CachedExternalModule { #[turbo_tasks::value] pub struct CachedExternalModuleChunkItem { - module: Vc, - chunking_context: Vc>, + module: ResolvedVc, + chunking_context: ResolvedVc>, } #[turbo_tasks::value_impl] @@ -199,12 +199,12 @@ impl ChunkItem for CachedExternalModuleChunkItem { #[turbo_tasks::function] fn module(&self) -> Vc> { - Vc::upcast(self.module) + Vc::upcast(*self.module) } #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - self.chunking_context + *self.chunking_context } #[turbo_tasks::function] @@ -219,7 +219,7 @@ impl ChunkItem for CachedExternalModuleChunkItem { impl EcmascriptChunkItem for CachedExternalModuleChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - self.chunking_context + *self.chunking_context } #[turbo_tasks::function] @@ -239,7 +239,7 @@ impl EcmascriptChunkItem for CachedExternalModuleChunkItem { EcmascriptChunkItemContent::new( self.module.content(), - self.chunking_context, + *self.chunking_context, EcmascriptOptions::default().cell(), async_module_options, ) @@ -253,13 +253,13 @@ impl EcmascriptChunkItem for CachedExternalModuleChunkItem { /// "client modules" and "client modules ssr". #[turbo_tasks::value] pub struct IncludeIdentModule { - ident: Vc, + ident: ResolvedVc, } #[turbo_tasks::value_impl] impl IncludeIdentModule { #[turbo_tasks::function] - pub fn new(ident: Vc) -> Vc { + pub fn new(ident: ResolvedVc) -> Vc { Self { ident }.cell() } } @@ -274,6 +274,6 @@ impl Asset for IncludeIdentModule { impl Module for IncludeIdentModule { #[turbo_tasks::function] fn ident(&self) -> Vc { - self.ident + *self.ident } } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/mod.rs b/turbopack/crates/turbopack-ecmascript/src/references/mod.rs index 41b79fe22af59..53035699c20c7 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/mod.rs @@ -146,13 +146,13 @@ use crate::{ #[turbo_tasks::value(shared)] #[derive(Clone)] pub struct AnalyzeEcmascriptModuleResult { - pub references: Vc, - pub local_references: Vc, - pub reexport_references: Vc, - pub evaluation_references: Vc, - pub code_generation: Vc, - pub exports: Vc, - pub async_module: Vc, + pub references: ResolvedVc, + pub local_references: ResolvedVc, + pub reexport_references: ResolvedVc, + pub evaluation_references: ResolvedVc, + pub code_generation: ResolvedVc, + pub exports: ResolvedVc, + pub async_module: ResolvedVc, /// `true` when the analysis was successful. pub successful: bool, pub source_map: Vc, @@ -167,9 +167,9 @@ pub struct AnalyzeEcmascriptModuleResultBuilder { evaluation_references: FxIndexSet>>, code_gens: Vec, exports: EcmascriptExports, - async_module: Vc, + async_module: ResolvedVc, successful: bool, - source_map: Option>, + source_map: Option>, bindings: Vec, } @@ -182,7 +182,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { evaluation_references: FxIndexSet::default(), code_gens: Vec::new(), exports: EcmascriptExports::None, - async_module: Vc::cell(None), + async_module: ResolvedVc::cell(None), successful: false, source_map: None, bindings: Vec::new(), @@ -196,7 +196,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { { let r = Vc::upcast(reference); self.references.insert(r); - self.local_references.insert(Vc::upcast(reference)); + self.local_references.insert(r); } /// Adds an asset reference to the analysis result. @@ -254,7 +254,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { } /// Sets the analysis result ES export. - pub fn set_source_map(&mut self, source_map: ResolvedVc) { + pub fn set_source_map(&mut self, source_map: Vc) { self.source_map = Some(source_map); } @@ -265,7 +265,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { /// Sets the analysis result ES export. pub fn set_async_module(&mut self, async_module: Vc) { - self.async_module = Vc::cell(Some(async_module)); + self.async_module = ResolvedVc::cell(Some(async_module)); } /// Sets whether the analysis was successful. @@ -317,27 +317,26 @@ impl AnalyzeEcmascriptModuleResultBuilder { CodeGen::CodeGenerateable(c) => { *c = c.resolve().await?; } - CodeGen::CodeGenerateableWithAsyncModuleInfo(c) => { - *c = c.to_resolved().await?; - } + CodeGen::CodeGenerateableWithAsyncModuleInfo(..) => {} } } + let source_map = if let Some(source_map) = self.source_map { source_map } else { - OptionSourceMap::none().to_resolved().await? + OptionSourceMap::none() }; Ok(AnalyzeEcmascriptModuleResult::cell( AnalyzeEcmascriptModuleResult { - references: Vc::cell(references), - local_references: Vc::cell(local_references), - reexport_references: Vc::cell(reexport_references), - evaluation_references: Vc::cell(evaluation_references), - code_generation: Vc::cell(self.code_gens), - exports: self.exports.into(), + references: ResolvedVc::cell(references), + local_references: ResolvedVc::cell(local_references), + reexport_references: ResolvedVc::cell(reexport_references), + evaluation_references: ResolvedVc::cell(evaluation_references), + code_generation: ResolvedVc::cell(self.code_gens), + exports: self.exports.resolved_cell(), async_module: self.async_module, successful: self.successful, - source_map: *source_map, + source_map, }, )) } @@ -351,7 +350,7 @@ impl Default for AnalyzeEcmascriptModuleResultBuilder { struct AnalysisState<'a> { handler: &'a Handler, - source: Vc>, + source: ResolvedVc>, origin: Vc>, compile_time_info: Vc, var_graph: &'a VarGraph, @@ -400,7 +399,7 @@ where /// Analyse a provided [EcmascriptModuleAsset] and return a [AnalyzeEcmascriptModuleResult]. #[turbo_tasks::function] pub(crate) async fn analyse_ecmascript_module( - module: Vc, + module: ResolvedVc, part: Option>, ) -> Result> { let span = { @@ -421,7 +420,7 @@ pub(crate) async fn analyse_ecmascript_module( } pub(crate) async fn analyse_ecmascript_module_internal( - module: Vc, + module: ResolvedVc, part: Option>, ) -> Result> { let raw_module = module.await?; @@ -433,7 +432,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( let options = options.await?; let import_externals = options.import_externals; - let origin = Vc::upcast::>(module); + let origin = ResolvedVc::upcast::>(module); let mut analysis = AnalyzeEcmascriptModuleResultBuilder::new(); let path = origin.origin_path(); @@ -446,8 +445,8 @@ pub(crate) async fn analyse_ecmascript_module_internal( }; let parsed = if let Some(part) = part { - let parsed = parse(source, ty, transforms); - let split_data = split(source.ident(), source, parsed); + let parsed = parse(*source, ty, *transforms); + let split_data = split(source.ident(), *source, parsed); part_of_module(split_data, part) } else { module.failsafe_parse() @@ -465,7 +464,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( if analyze_types { match &*find_context_file(path.parent(), tsconfig()).await? { FindContextFileResult::Found(tsconfig, _) => { - analysis.add_reference(TsConfigReference::new(origin, **tsconfig)); + analysis.add_reference(TsConfigReference::new(*origin, **tsconfig)); } FindContextFileResult::NotFound(_) => {} }; @@ -488,7 +487,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( }; let compile_time_info = compile_time_info_for_module_type( - raw_module.compile_time_info, + *raw_module.compile_time_info, eval_context.is_esm(specified_type), ); @@ -510,12 +509,14 @@ pub(crate) async fn analyse_ecmascript_module_internal( let text = &comment.text; if let Some(m) = REFERENCE_PATH.captures(text) { let path = &m[1]; - analysis - .add_reference(TsReferencePathAssetReference::new(origin, path.into())); + analysis.add_reference(TsReferencePathAssetReference::new( + *origin, + path.into(), + )); } else if let Some(m) = REFERENCE_TYPES.captures(text) { let types = &m[1]; analysis.add_reference(TsReferenceTypeAssetReference::new( - origin, + *origin, types.into(), )); } @@ -553,43 +554,37 @@ pub(crate) async fn analyse_ecmascript_module_internal( let reference = SourceMapReference::new(origin_path, source_map_origin); analysis.add_reference(reference); let source_map = reference.generate_source_map(); - analysis.set_source_map( - convert_to_turbopack_source_map(source_map, source_map_origin) - .to_resolved() - .await?, - ); + analysis.set_source_map(convert_to_turbopack_source_map( + source_map, + source_map_origin, + )); source_map_from_comment = true; } else if path.starts_with("data:application/json;base64,") { let source_map_origin = origin_path; let source_map = maybe_decode_data_url(path.into()); - analysis.set_source_map( - convert_to_turbopack_source_map(source_map, source_map_origin) - .to_resolved() - .await?, - ); + analysis.set_source_map(convert_to_turbopack_source_map( + source_map, + source_map_origin, + )); source_map_from_comment = true; } } if !source_map_from_comment { if let Some(generate_source_map) = - Vc::try_resolve_sidecast::>(source).await? + ResolvedVc::try_sidecast::>(source).await? { let source_map_origin = source.ident().path(); - analysis.set_source_map( - convert_to_turbopack_source_map( - generate_source_map.generate_source_map(), - source_map_origin, - ) - .to_resolved() - .await?, - ); + analysis.set_source_map(convert_to_turbopack_source_map( + generate_source_map.generate_source_map(), + source_map_origin, + )); } } let handler = Handler::with_emitter( true, false, - Box::new(IssueEmitter::new(source, source_map.clone(), None)), + Box::new(IssueEmitter::new(*source, source_map.clone(), None)), ); let mut var_graph = @@ -599,10 +594,10 @@ pub(crate) async fn analyse_ecmascript_module_internal( for (i, r) in eval_context.imports.references().enumerate() { let r = EsmAssetReference::new( - origin, + *origin, Request::parse(Value::new(RcStr::from(&*r.module_path).into())), r.issue_source - .unwrap_or_else(|| IssueSource::from_source_only(source)), + .unwrap_or_else(|| IssueSource::from_source_only(*source)), Value::new(r.annotations.clone()), match options.tree_shaking_mode { Some(TreeShakingMode::ModuleFragments) => match &r.imported_symbol { @@ -720,7 +715,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( // Check if it was a webpack entry if let Some((request, span)) = webpack_runtime { let request = Request::parse(Value::new(request.into())); - let runtime = resolve_as_webpack_runtime(origin, request, transforms); + let runtime = resolve_as_webpack_runtime(*origin, request, *transforms); if let WebpackRuntime::Webpack5 { .. } = &*runtime.await? { ignore_effect_span = Some(span); @@ -761,7 +756,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( let exports = if !esm_exports.is_empty() || !esm_star_exports.is_empty() { if specified_type == SpecifiedModuleType::CommonJs { SpecifiedModuleTypeIssue { - path: source.ident().path(), + path: source.ident().path().to_resolved().await?, specified_type, } .cell() @@ -779,7 +774,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( match detect_dynamic_export(program) { DetectedDynamicExportType::CommonJs => { SpecifiedModuleTypeIssue { - path: source.ident().path(), + path: source.ident().path().to_resolved().await?, specified_type, } .cell() @@ -838,7 +833,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( .cell(), source_ident: source.ident(), severity: IssueSeverity::Error.into(), - source: Some(issue_source(source, span)), + source: Some(issue_source(*source, span)), title: Vc::cell("unexpected top level await".into()), } .cell() @@ -852,7 +847,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( let mut analysis_state = AnalysisState { handler: &handler, source, - origin, + origin: *origin, compile_time_info, var_graph: &var_graph, fun_args_values: Mutex::new(HashMap::>::new()), @@ -1182,14 +1177,18 @@ pub(crate) async fn analyse_ecmascript_module_internal( span: _, in_try: _, } => { - if let Some(r) = import_references.get(esm_reference_index) { + if let Some(&r) = import_references.get(esm_reference_index) { if let Some("__turbopack_module_id__") = export.as_deref() { analysis - .add_reference(EsmModuleIdAssetReference::new(*r, Vc::cell(ast_path))) + .add_reference(EsmModuleIdAssetReference::new(r, Vc::cell(ast_path))) } else { - analysis.add_local_reference(*r); - analysis.add_import_reference(*r); - analysis.add_binding(EsmBinding::new(*r, export, Vc::cell(ast_path))); + analysis.add_local_reference(r); + analysis.add_import_reference(r); + analysis.add_binding(EsmBinding::new( + r, + export, + ResolvedVc::cell(ast_path), + )); } } } @@ -1353,7 +1352,7 @@ async fn handle_call) + Send + Sync>( Request::parse(Value::new(pat)), compile_time_info.environment().rendering(), Vc::cell(ast_path.to_vec()), - issue_source(source, span), + issue_source(*source, span), in_try, url_rewrite_behavior .unwrap_or(UrlRewriteBehavior::Relative) @@ -1386,7 +1385,7 @@ async fn handle_call) + Send + Sync>( origin, Request::parse(Value::new(pat)), Vc::cell(ast_path.to_vec()), - issue_source(source, span), + issue_source(*source, span), in_try, )); } @@ -1460,7 +1459,7 @@ async fn handle_call) + Send + Sync>( origin, Request::parse(Value::new(pat)), Vc::cell(ast_path.to_vec()), - issue_source(source, span), + issue_source(*source, span), in_try, state.import_externals, )); @@ -1497,7 +1496,7 @@ async fn handle_call) + Send + Sync>( origin, Request::parse(Value::new(pat)), Vc::cell(ast_path.to_vec()), - issue_source(source, span), + issue_source(*source, span), in_try, )); return Ok(()); @@ -1511,7 +1510,7 @@ async fn handle_call) + Send + Sync>( } JsValue::WellKnownFunction(WellKnownFunctionKind::Define) => { analyze_amd_define( - source, + *source, analysis, origin, handler, @@ -1519,7 +1518,8 @@ async fn handle_call) + Send + Sync>( ast_path, linked_args(args).await?, in_try, - ); + ) + .await?; } JsValue::WellKnownFunction(WellKnownFunctionKind::RequireResolve) => { @@ -1544,7 +1544,7 @@ async fn handle_call) + Send + Sync>( origin, Request::parse(Value::new(pat)), Vc::cell(ast_path.to_vec()), - issue_source(source, span), + issue_source(*source, span), in_try, )); return Ok(()); @@ -1580,13 +1580,13 @@ async fn handle_call) + Send + Sync>( }; analysis.add_reference(RequireContextAssetReference::new( - source, + *source, origin, options.dir, options.include_subdirs, Vc::cell(options.filter), Vc::cell(ast_path.to_vec()), - Some(issue_source(source, span)), + Some(issue_source(*source, span)), in_try, )); } @@ -1608,7 +1608,7 @@ async fn handle_call) + Send + Sync>( return Ok(()); } } - analysis.add_reference(FileSourceReference::new(source, Pattern::new(pat))); + analysis.add_reference(FileSourceReference::new(*source, Pattern::new(pat))); return Ok(()); } let (args, hints) = explain_args(&args); @@ -1651,7 +1651,7 @@ async fn handle_call) + Send + Sync>( return Ok(()); } } - analysis.add_reference(FileSourceReference::new(source, Pattern::new(pat))); + analysis.add_reference(FileSourceReference::new(*source, Pattern::new(pat))); return Ok(()); } @@ -1685,7 +1685,7 @@ async fn handle_call) + Send + Sync>( return Ok(()); } } - analysis.add_reference(DirAssetReference::new(source, Pattern::new(pat))); + analysis.add_reference(DirAssetReference::new(*source, Pattern::new(pat))); return Ok(()); } JsValue::WellKnownFunction(WellKnownFunctionKind::ChildProcessSpawnMethod(name)) => { @@ -1714,7 +1714,7 @@ async fn handle_call) + Send + Sync>( analysis.add_reference(CjsAssetReference::new( origin, Request::parse(Value::new(pat)), - issue_source(source, span), + issue_source(*source, span), in_try, )); } @@ -1724,7 +1724,7 @@ async fn handle_call) + Send + Sync>( show_dynamic_warning = true; } if !dynamic || !ignore_dynamic_requests { - analysis.add_reference(FileSourceReference::new(source, Pattern::new(pat))); + analysis.add_reference(FileSourceReference::new(*source, Pattern::new(pat))); } if show_dynamic_warning { let (args, hints) = explain_args(&args); @@ -1768,7 +1768,7 @@ async fn handle_call) + Send + Sync>( analysis.add_reference(CjsAssetReference::new( origin, Request::parse(Value::new(pat)), - issue_source(source, span), + issue_source(*source, span), in_try, )); return Ok(()); @@ -1916,7 +1916,7 @@ async fn handle_call) + Send + Sync>( js_value_to_pattern(&linked_func_call) }; analysis.add_reference(DirAssetReference::new( - source, + *source, Pattern::new(abs_pattern), )); return Ok(()); @@ -1929,7 +1929,7 @@ async fn handle_call) + Send + Sync>( analysis.add_reference(CjsAssetReference::new( origin, Request::parse(Value::new(pat)), - issue_source(source, span), + issue_source(*source, span), in_try, )); } @@ -1972,7 +1972,7 @@ async fn handle_call) + Send + Sync>( .await?; js_value_to_pattern(&linked_func_call) }; - analysis.add_reference(DirAssetReference::new(source, Pattern::new(abs_pattern))); + analysis.add_reference(DirAssetReference::new(*source, Pattern::new(abs_pattern))); return Ok(()); } let (args, hints) = explain_args(&args); @@ -1993,7 +1993,7 @@ async fn handle_call) + Send + Sync>( analysis.add_reference(CjsAssetReference::new( origin, Request::parse(Value::new(js_value_to_pattern(&args[1]))), - issue_source(source, span), + issue_source(*source, span), in_try, )); return Ok(()); @@ -2031,7 +2031,7 @@ async fn handle_call) + Send + Sync>( .flatten() { analysis.add_reference(DirAssetReference::new( - source, + *source, Pattern::new(Pattern::Constant(dir.into())), )); } @@ -2098,7 +2098,7 @@ async fn handle_member( ) if s.as_str() == Some("cache") => { analysis.add_code_gen( CjsRequireCacheAccess { - path: Vc::cell(ast_path.to_vec()), + path: ResolvedVc::cell(ast_path.to_vec()), } .cell(), ); @@ -2208,7 +2208,11 @@ async fn handle_free_var_reference( )) }), Request::parse(Value::new(request.clone().into())), - IssueSource::from_swc_offsets(state.source, span.lo.to_usize(), span.hi.to_usize()), + IssueSource::from_swc_offsets( + *state.source, + span.lo.to_usize(), + span.hi.to_usize(), + ), Default::default(), match state.tree_shaking_mode { Some(TreeShakingMode::ModuleFragments) @@ -2218,14 +2222,12 @@ async fn handle_free_var_reference( None => None, }, state.import_externals, - ) - .resolve() - .await?; + ); analysis.add_reference(esm_reference); analysis.add_binding(EsmBinding::new( esm_reference, export.clone(), - Vc::cell(ast_path.to_vec()), + ResolvedVc::cell(ast_path.to_vec()), )); } } @@ -2236,7 +2238,7 @@ fn issue_source(source: Vc>, span: Span) -> Vc { IssueSource::from_swc_offsets(source, span.lo.to_usize(), span.hi.to_usize()) } -fn analyze_amd_define( +async fn analyze_amd_define( source: Vc>, analysis: &mut AnalyzeEcmascriptModuleResultBuilder, origin: Vc>, @@ -2245,7 +2247,7 @@ fn analyze_amd_define( ast_path: &[AstParentKind], args: Vec, in_try: bool, -) { +) -> Result<()> { match &args[..] { [JsValue::Constant(id), JsValue::Array { items: deps, .. }, _] if id.as_str().is_some() => { analyze_amd_define_with_deps( @@ -2258,12 +2260,14 @@ fn analyze_amd_define( id.as_str(), deps, in_try, - ); + ) + .await?; } [JsValue::Array { items: deps, .. }, _] => { analyze_amd_define_with_deps( source, analysis, origin, handler, span, ast_path, None, deps, in_try, - ); + ) + .await?; } [JsValue::Constant(id), JsValue::Function(..)] if id.as_str().is_some() => { analysis.add_code_gen(AmdDefineWithDependenciesCodeGen::new( @@ -2273,7 +2277,7 @@ fn analyze_amd_define( AmdDefineDependencyElement::Module, ], origin, - Vc::cell(ast_path.to_vec()), + ResolvedVc::cell(ast_path.to_vec()), AmdDefineFactoryType::Function, issue_source(source, span), in_try, @@ -2287,7 +2291,7 @@ fn analyze_amd_define( AmdDefineDependencyElement::Module, ], origin, - Vc::cell(ast_path.to_vec()), + ResolvedVc::cell(ast_path.to_vec()), AmdDefineFactoryType::Unknown, issue_source(source, span), in_try, @@ -2301,7 +2305,7 @@ fn analyze_amd_define( AmdDefineDependencyElement::Module, ], origin, - Vc::cell(ast_path.to_vec()), + ResolvedVc::cell(ast_path.to_vec()), AmdDefineFactoryType::Function, issue_source(source, span), in_try, @@ -2311,7 +2315,7 @@ fn analyze_amd_define( analysis.add_code_gen(AmdDefineWithDependenciesCodeGen::new( vec![], origin, - Vc::cell(ast_path.to_vec()), + ResolvedVc::cell(ast_path.to_vec()), AmdDefineFactoryType::Value, issue_source(source, span), in_try, @@ -2325,7 +2329,7 @@ fn analyze_amd_define( AmdDefineDependencyElement::Module, ], origin, - Vc::cell(ast_path.to_vec()), + ResolvedVc::cell(ast_path.to_vec()), AmdDefineFactoryType::Unknown, issue_source(source, span), in_try, @@ -2339,9 +2343,11 @@ fn analyze_amd_define( ); } } + + Ok(()) } -fn analyze_amd_define_with_deps( +async fn analyze_amd_define_with_deps( source: Vc>, analysis: &mut AnalyzeEcmascriptModuleResultBuilder, origin: Vc>, @@ -2351,7 +2357,7 @@ fn analyze_amd_define_with_deps( id: Option<&str>, deps: &[JsValue], in_try: bool, -) { +) -> Result<()> { let mut requests = Vec::new(); for dep in deps { if let Some(dep) = dep.as_str() { @@ -2409,11 +2415,13 @@ fn analyze_amd_define_with_deps( analysis.add_code_gen(AmdDefineWithDependenciesCodeGen::new( requests, origin, - Vc::cell(ast_path.to_vec()), + ResolvedVc::cell(ast_path.to_vec()), AmdDefineFactoryType::Function, issue_source(source, span), in_try, )); + + Ok(()) } /// Used to generate the "root" path to a __filename/__dirname/import.meta.url @@ -2650,7 +2658,11 @@ async fn require_context_visitor( ); Ok(JsValue::WellKnownFunction( - WellKnownFunctionKind::RequireContextRequire(RequireContextValue::from_context_map(map)), + WellKnownFunctionKind::RequireContextRequire( + RequireContextValue::from_context_map(map) + .to_resolved() + .await?, + ), )) } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/node.rs b/turbopack/crates/turbopack-ecmascript/src/references/node.rs index 1986ea3acbaee..0036221b0bae7 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/node.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/node.rs @@ -17,13 +17,13 @@ use turbopack_core::{ #[turbo_tasks::value] #[derive(Hash, Clone, Debug)] pub struct PackageJsonReference { - pub package_json: Vc, + pub package_json: ResolvedVc, } #[turbo_tasks::value_impl] impl PackageJsonReference { #[turbo_tasks::function] - pub fn new(package_json: Vc) -> Vc { + pub fn new(package_json: ResolvedVc) -> Vc { Self::cell(PackageJsonReference { package_json }) } } @@ -33,7 +33,7 @@ impl ModuleReference for PackageJsonReference { #[turbo_tasks::function] async fn resolve_reference(&self) -> Result> { Ok(ModuleResolveResult::module(ResolvedVc::upcast( - RawModule::new(Vc::upcast(FileSource::new(self.package_json))) + RawModule::new(Vc::upcast(FileSource::new(*self.package_json))) .to_resolved() .await?, )) @@ -54,14 +54,14 @@ impl ValueToString for PackageJsonReference { #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct DirAssetReference { - pub source: Vc>, - pub path: Vc, + pub source: ResolvedVc>, + pub path: ResolvedVc, } #[turbo_tasks::value_impl] impl DirAssetReference { #[turbo_tasks::function] - pub fn new(source: Vc>, path: Vc) -> Vc { + pub fn new(source: ResolvedVc>, path: ResolvedVc) -> Vc { Self::cell(DirAssetReference { source, path }) } } @@ -151,7 +151,7 @@ impl ModuleReference for DirAssetReference { let parent_path = self.source.ident().path().parent(); Ok(resolve_reference_from_dir( parent_path.resolve().await?, - self.path, + *self.path, )) } } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/raw.rs b/turbopack/crates/turbopack-ecmascript/src/references/raw.rs index 62583d912159f..0e0d1dccd3a69 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/raw.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/raw.rs @@ -1,6 +1,6 @@ use anyhow::Result; use turbo_rcstr::RcStr; -use turbo_tasks::{ValueToString, Vc}; +use turbo_tasks::{ResolvedVc, ValueToString, Vc}; use turbopack_core::{ reference::ModuleReference, resolve::{pattern::Pattern, resolve_raw, ModuleResolveResult}, @@ -10,14 +10,14 @@ use turbopack_core::{ #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct FileSourceReference { - pub source: Vc>, - pub path: Vc, + pub source: ResolvedVc>, + pub path: ResolvedVc, } #[turbo_tasks::value_impl] impl FileSourceReference { #[turbo_tasks::function] - pub fn new(source: Vc>, path: Vc) -> Vc { + pub fn new(source: ResolvedVc>, path: ResolvedVc) -> Vc { Self::cell(FileSourceReference { source, path }) } } @@ -28,7 +28,7 @@ impl ModuleReference for FileSourceReference { fn resolve_reference(&self) -> Vc { let context_dir = self.source.ident().path().parent(); - resolve_raw(context_dir, self.path, false).as_raw_module_result() + resolve_raw(context_dir, *self.path, false).as_raw_module_result() } } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/require_context.rs b/turbopack/crates/turbopack-ecmascript/src/references/require_context.rs index 78009c9c409fb..d555f6e75aa94 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/require_context.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/require_context.rs @@ -122,7 +122,7 @@ impl DirList { for (k, entry) in &*dir { match entry { DirListEntry::File(path) => { - list.insert(k.clone(), **path); + list.insert(k.clone(), *path); } DirListEntry::Dir(d) => { queue.push_back(d.await?); @@ -136,7 +136,7 @@ impl DirList { } #[turbo_tasks::value(transparent)] -pub(crate) struct FlatDirList(FxIndexMap>); +pub(crate) struct FlatDirList(FxIndexMap>); #[turbo_tasks::value_impl] impl FlatDirList { @@ -150,8 +150,8 @@ impl FlatDirList { #[derive(Debug)] pub struct RequireContextMapEntry { pub origin_relative: RcStr, - pub request: Vc, - pub result: Vc, + pub request: ResolvedVc, + pub result: ResolvedVc, } /// The resolved context map for a `require.context(..)` call. @@ -166,7 +166,7 @@ impl RequireContextMap { dir: Vc, recursive: bool, filter: Vc, - issue_source: Option>, + issue_source: Option>, is_optional: bool, ) -> Result> { let origin_path = &*origin.origin_path().parent().await?; @@ -177,8 +177,12 @@ impl RequireContextMap { for (context_relative, path) in list { if let Some(origin_relative) = origin_path.get_relative_path_to(&*path.await?) { - let request = Request::parse(Value::new(origin_relative.clone().into())); - let result = cjs_resolve(origin, request, issue_source, is_optional); + let request = Request::parse(Value::new(origin_relative.clone().into())) + .to_resolved() + .await?; + let result = cjs_resolve(origin, *request, issue_source.map(|v| *v), is_optional) + .to_resolved() + .await?; map.insert( context_relative.clone(), @@ -206,32 +210,34 @@ pub struct RequireContextAssetReference { pub dir: RcStr, pub include_subdirs: bool, - pub path: Vc, - pub issue_source: Option>, + pub path: ResolvedVc, + pub issue_source: Option>, pub in_try: bool, } #[turbo_tasks::value_impl] impl RequireContextAssetReference { #[turbo_tasks::function] - pub fn new( - source: Vc>, - origin: Vc>, + pub async fn new( + source: ResolvedVc>, + origin: ResolvedVc>, dir: RcStr, include_subdirs: bool, filter: Vc, - path: Vc, - issue_source: Option>, + path: ResolvedVc, + issue_source: Option>, in_try: bool, - ) -> Vc { + ) -> Result> { let map = RequireContextMap::generate( - origin, + *origin, origin.origin_path().parent().join(dir.clone()), include_subdirs, filter, - issue_source, + issue_source.map(|v| *v), in_try, - ); + ) + .to_resolved() + .await?; let inner = RequireContextAsset { source, origin, @@ -242,14 +248,14 @@ impl RequireContextAssetReference { } .resolved_cell(); - Self::cell(RequireContextAssetReference { + Ok(Self::cell(RequireContextAssetReference { inner, dir, include_subdirs, path, issue_source, in_try, - }) + })) } } @@ -306,13 +312,13 @@ impl CodeGenerateable for RequireContextAssetReference { } #[turbo_tasks::value(transparent)] -pub struct ResolvedModuleReference(Vc); +pub struct ResolvedModuleReference(ResolvedVc); #[turbo_tasks::value_impl] impl ModuleReference for ResolvedModuleReference { #[turbo_tasks::function] fn resolve_reference(&self) -> Vc { - self.0 + *self.0 } } @@ -329,10 +335,10 @@ impl ChunkableModuleReference for ResolvedModuleReference {} #[turbo_tasks::value] pub struct RequireContextAsset { - source: Vc>, + source: ResolvedVc>, - origin: Vc>, - map: Vc, + origin: ResolvedVc>, + map: ResolvedVc, dir: RcStr, include_subdirs: bool, @@ -383,8 +389,8 @@ impl Asset for RequireContextAsset { impl ChunkableModule for RequireContextAsset { #[turbo_tasks::function] async fn as_chunk_item( - self: Vc, - chunking_context: Vc>, + self: ResolvedVc, + chunking_context: ResolvedVc>, ) -> Result>> { let this = self.await?; Ok(Vc::upcast( @@ -410,18 +416,18 @@ impl EcmascriptChunkPlaceable for RequireContextAsset { #[turbo_tasks::value] pub struct RequireContextChunkItem { - chunking_context: Vc>, - inner: Vc, + chunking_context: ResolvedVc>, + inner: ResolvedVc, - origin: Vc>, - map: Vc, + origin: ResolvedVc>, + map: ResolvedVc, } #[turbo_tasks::value_impl] impl EcmascriptChunkItem for RequireContextChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - self.chunking_context + *self.chunking_context } #[turbo_tasks::function] @@ -435,10 +441,10 @@ impl EcmascriptChunkItem for RequireContextChunkItem { for (key, entry) in map { let pm = PatternMapping::resolve_request( - entry.request, - self.origin, - Vc::upcast(self.chunking_context), - entry.result, + *entry.request, + *self.origin, + *ResolvedVc::upcast(self.chunking_context), + *entry.result, Value::new(ResolveType::ChunkItem), ) .await?; @@ -512,7 +518,7 @@ impl ChunkItem for RequireContextChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - Vc::upcast(self.chunking_context) + *ResolvedVc::upcast(self.chunking_context) } #[turbo_tasks::function] @@ -524,6 +530,6 @@ impl ChunkItem for RequireContextChunkItem { #[turbo_tasks::function] fn module(&self) -> Vc> { - Vc::upcast(self.inner) + *ResolvedVc::upcast(self.inner) } } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/type_issue.rs b/turbopack/crates/turbopack-ecmascript/src/references/type_issue.rs index 5e6d8a8da9900..14c1cf1dcab84 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/type_issue.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/type_issue.rs @@ -1,4 +1,4 @@ -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::issue::{Issue, IssueSeverity, IssueStage, OptionStyledString, StyledString}; @@ -6,7 +6,7 @@ use crate::SpecifiedModuleType; #[turbo_tasks::value(shared)] pub struct SpecifiedModuleTypeIssue { - pub path: Vc, + pub path: ResolvedVc, pub specified_type: SpecifiedModuleType, } @@ -14,7 +14,7 @@ pub struct SpecifiedModuleTypeIssue { impl Issue for SpecifiedModuleTypeIssue { #[turbo_tasks::function] fn file_path(&self) -> Vc { - self.path + *self.path } #[turbo_tasks::function] diff --git a/turbopack/crates/turbopack-ecmascript/src/references/typescript.rs b/turbopack/crates/turbopack-ecmascript/src/references/typescript.rs index fedd41189772b..401a3399fc8de 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/typescript.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/typescript.rs @@ -16,14 +16,17 @@ use crate::typescript::TsConfigModuleAsset; #[turbo_tasks::value] #[derive(Hash, Clone, Debug)] pub struct TsConfigReference { - pub tsconfig: Vc, - pub origin: Vc>, + pub tsconfig: ResolvedVc, + pub origin: ResolvedVc>, } #[turbo_tasks::value_impl] impl TsConfigReference { #[turbo_tasks::function] - pub fn new(origin: Vc>, tsconfig: Vc) -> Vc { + pub fn new( + origin: ResolvedVc>, + tsconfig: ResolvedVc, + ) -> Vc { Self::cell(TsConfigReference { tsconfig, origin }) } } @@ -33,7 +36,7 @@ impl ModuleReference for TsConfigReference { #[turbo_tasks::function] async fn resolve_reference(&self) -> Result> { Ok(ModuleResolveResult::module(ResolvedVc::upcast( - TsConfigModuleAsset::new(self.origin, Vc::upcast(FileSource::new(self.tsconfig))) + TsConfigModuleAsset::new(*self.origin, Vc::upcast(FileSource::new(*self.tsconfig))) .to_resolved() .await?, )) @@ -54,14 +57,14 @@ impl ValueToString for TsConfigReference { #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct TsReferencePathAssetReference { - pub origin: Vc>, + pub origin: ResolvedVc>, pub path: RcStr, } #[turbo_tasks::value_impl] impl TsReferencePathAssetReference { #[turbo_tasks::function] - pub fn new(origin: Vc>, path: RcStr) -> Vc { + pub fn new(origin: ResolvedVc>, path: RcStr) -> Vc { Self::cell(TsReferencePathAssetReference { origin, path }) } } @@ -109,14 +112,14 @@ impl ValueToString for TsReferencePathAssetReference { #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct TsReferenceTypeAssetReference { - pub origin: Vc>, + pub origin: ResolvedVc>, pub module: RcStr, } #[turbo_tasks::value_impl] impl TsReferenceTypeAssetReference { #[turbo_tasks::function] - pub fn new(origin: Vc>, module: RcStr) -> Vc { + pub fn new(origin: ResolvedVc>, module: RcStr) -> Vc { Self::cell(TsReferenceTypeAssetReference { origin, module }) } } @@ -126,7 +129,7 @@ impl ModuleReference for TsReferenceTypeAssetReference { #[turbo_tasks::function] fn resolve_reference(&self) -> Vc { type_resolve( - self.origin, + *self.origin, Request::module( self.module.clone(), Value::new(RcStr::default().into()), diff --git a/turbopack/crates/turbopack-ecmascript/src/references/unreachable.rs b/turbopack/crates/turbopack-ecmascript/src/references/unreachable.rs index b5208bb4c14aa..9c784689166c3 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/unreachable.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/unreachable.rs @@ -16,7 +16,7 @@ use swc_core::{ }, quote, }; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack_core::chunk::ChunkingContext; use crate::{ @@ -27,13 +27,13 @@ use crate::{ #[turbo_tasks::value] pub struct Unreachable { - range: Vc, + range: ResolvedVc, } #[turbo_tasks::value_impl] impl Unreachable { #[turbo_tasks::function] - pub fn new(range: Vc) -> Vc { + pub fn new(range: ResolvedVc) -> Vc { Self::cell(Unreachable { range }) } } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/worker.rs b/turbopack/crates/turbopack-ecmascript/src/references/worker.rs index f951f7748da90..ad3a44201535f 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/worker.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/worker.rs @@ -24,10 +24,10 @@ use crate::{ #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct WorkerAssetReference { - pub origin: Vc>, - pub request: Vc, - pub path: Vc, - pub issue_source: Vc, + pub origin: ResolvedVc>, + pub request: ResolvedVc, + pub path: ResolvedVc, + pub issue_source: ResolvedVc, pub in_try: bool, } @@ -35,10 +35,10 @@ pub struct WorkerAssetReference { impl WorkerAssetReference { #[turbo_tasks::function] pub fn new( - origin: Vc>, - request: Vc, - path: Vc, - issue_source: Vc, + origin: ResolvedVc>, + request: ResolvedVc, + path: ResolvedVc, + issue_source: ResolvedVc, in_try: bool, ) -> Vc { Self::cell(WorkerAssetReference { @@ -56,11 +56,11 @@ impl WorkerAssetReference { self: &WorkerAssetReference, ) -> Result>> { let module = url_resolve( - self.origin, - self.request, + *self.origin, + *self.request, // TODO support more worker types Value::new(ReferenceType::Worker(WorkerReferenceSubType::WebWorker)), - Some(self.issue_source), + Some(*self.issue_source), self.in_try, ); diff --git a/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/chunk_item.rs b/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/chunk_item.rs index 658cb5c06ebd0..6ac97d316043c 100644 --- a/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/chunk_item.rs +++ b/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/chunk_item.rs @@ -8,7 +8,7 @@ use swc_core::{ codegen::{text_writer::JsWriter, Emitter}, }, }; -use turbo_tasks::{TryJoinIterExt, Vc}; +use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc}; use turbo_tasks_fs::rope::RopeBuilder; use turbopack_core::{ chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkingContext}, @@ -30,8 +30,8 @@ use crate::{ /// The chunk item for [EcmascriptModuleFacadeModule]. #[turbo_tasks::value(shared)] pub struct EcmascriptModuleFacadeChunkItem { - pub(crate) module: Vc, - pub(crate) chunking_context: Vc>, + pub(crate) module: ResolvedVc, + pub(crate) chunking_context: ResolvedVc>, } #[turbo_tasks::value_impl] @@ -74,19 +74,19 @@ impl EcmascriptChunkItem for EcmascriptModuleFacadeChunkItem { if let Some(code_gen) = Vc::try_resolve_sidecast::>(r).await? { - code_gens.push(code_gen.code_generation(chunking_context, async_module_info)); + code_gens.push(code_gen.code_generation(*chunking_context, async_module_info)); } else if let Some(code_gen) = Vc::try_resolve_sidecast::>(r).await? { - code_gens.push(code_gen.code_generation(chunking_context)); + code_gens.push(code_gen.code_generation(*chunking_context)); } } code_gens.push(self.module.async_module().code_generation( - chunking_context, + *chunking_context, async_module_info, references, )); - code_gens.push(exports.code_generation(chunking_context)); + code_gens.push(exports.code_generation(*chunking_context)); let code_gens = code_gens.into_iter().try_join().await?; let code_gens = code_gens.iter().map(|cg| &**cg).collect::>(); @@ -124,7 +124,7 @@ impl EcmascriptChunkItem for EcmascriptModuleFacadeChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - self.chunking_context + *self.chunking_context } } @@ -142,7 +142,7 @@ impl ChunkItem for EcmascriptModuleFacadeChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - Vc::upcast(self.chunking_context) + *ResolvedVc::upcast(self.chunking_context) } #[turbo_tasks::function] @@ -154,7 +154,7 @@ impl ChunkItem for EcmascriptModuleFacadeChunkItem { #[turbo_tasks::function] fn module(&self) -> Vc> { - Vc::upcast(self.module) + *ResolvedVc::upcast(self.module) } #[turbo_tasks::function] diff --git a/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs b/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs index 30c5316ced247..5118a8f08f5d2 100644 --- a/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs +++ b/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use anyhow::{bail, Result}; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks_fs::{glob::Glob, File, FileContent}; use turbopack_core::{ asset::{Asset, AssetContent}, @@ -28,14 +28,17 @@ use crate::{ /// [EcmascriptModuleLocalsModule]. It allows to follow #[turbo_tasks::value] pub struct EcmascriptModuleFacadeModule { - pub module: Vc>, - pub ty: Vc, + pub module: ResolvedVc>, + pub ty: ResolvedVc, } #[turbo_tasks::value_impl] impl EcmascriptModuleFacadeModule { #[turbo_tasks::function] - pub fn new(module: Vc>, ty: Vc) -> Vc { + pub fn new( + module: ResolvedVc>, + ty: ResolvedVc, + ) -> Vc { EcmascriptModuleFacadeModule { module, ty }.cell() } @@ -64,7 +67,7 @@ impl Module for EcmascriptModuleFacadeModule { async fn ident(&self) -> Result> { let inner = self.module.ident(); - Ok(inner.with_part(self.ty)) + Ok(inner.with_part(*self.ty)) } #[turbo_tasks::function] @@ -72,7 +75,7 @@ impl Module for EcmascriptModuleFacadeModule { let references = match &*self.ty.await? { ModulePart::Evaluation => { let Some(module) = - Vc::try_resolve_sidecast::>(self.module).await? + ResolvedVc::try_sidecast::>(self.module).await? else { bail!( "Expected EcmascriptModuleAsset for a EcmascriptModuleFacadeModule with \ @@ -83,14 +86,14 @@ impl Module for EcmascriptModuleFacadeModule { let references = result.evaluation_references; let mut references = references.await?.clone_value(); references.push(Vc::upcast(EcmascriptModulePartReference::new_part( - self.module, + *self.module, ModulePart::locals(), ))); references } ModulePart::Exports => { let Some(module) = - Vc::try_resolve_sidecast::>(self.module).await? + ResolvedVc::try_sidecast::>(self.module).await? else { bail!( "Expected EcmascriptModuleAsset for a EcmascriptModuleFacadeModule with \ @@ -101,7 +104,7 @@ impl Module for EcmascriptModuleFacadeModule { let references = result.reexport_references; let mut references = references.await?.clone_value(); references.push(Vc::upcast(EcmascriptModulePartReference::new_part( - self.module, + *self.module, ModulePart::locals(), ))); references @@ -109,20 +112,20 @@ impl Module for EcmascriptModuleFacadeModule { ModulePart::Facade => { vec![ Vc::upcast(EcmascriptModulePartReference::new_part( - self.module, + *self.module, ModulePart::evaluation(), )), Vc::upcast(EcmascriptModulePartReference::new_part( - self.module, + *self.module, ModulePart::exports(), )), ] } ModulePart::RenamedNamespace { .. } => { - vec![Vc::upcast(EcmascriptModulePartReference::new(self.module))] + vec![Vc::upcast(EcmascriptModulePartReference::new(*self.module))] } ModulePart::RenamedExport { .. } => { - vec![Vc::upcast(EcmascriptModulePartReference::new(self.module))] + vec![Vc::upcast(EcmascriptModulePartReference::new(*self.module))] } _ => { bail!("Unexpected ModulePart for EcmascriptModuleFacadeModule"); @@ -166,7 +169,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule { name.clone(), EsmExport::ImportedBinding( Vc::upcast(EcmascriptModulePartReference::new_part( - self.module, + *self.module, ModulePart::locals(), )), name, @@ -209,7 +212,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule { "default".into(), EsmExport::ImportedBinding( Vc::upcast(EcmascriptModulePartReference::new_part( - self.module, + *self.module, ModulePart::exports(), )), "default".into(), @@ -218,7 +221,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule { ); } star_exports.push(Vc::upcast(EcmascriptModulePartReference::new_part( - self.module, + *self.module, ModulePart::exports(), ))); } @@ -230,7 +233,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule { exports.insert( export.await?.clone_value(), EsmExport::ImportedBinding( - Vc::upcast(EcmascriptModulePartReference::new(self.module)), + Vc::upcast(EcmascriptModulePartReference::new(*self.module)), original_export.clone_value(), false, ), @@ -240,7 +243,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule { exports.insert( export.await?.clone_value(), EsmExport::ImportedNamespace(Vc::upcast(EcmascriptModulePartReference::new( - self.module, + *self.module, ))), ); } @@ -284,8 +287,8 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule { impl ChunkableModule for EcmascriptModuleFacadeModule { #[turbo_tasks::function] fn as_chunk_item( - self: Vc, - chunking_context: Vc>, + self: ResolvedVc, + chunking_context: ResolvedVc>, ) -> Vc> { Vc::upcast( EcmascriptModuleFacadeChunkItem { diff --git a/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/locals/chunk_item.rs b/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/locals/chunk_item.rs index 7fba3a91d88aa..17266ccda0327 100644 --- a/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/locals/chunk_item.rs +++ b/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/locals/chunk_item.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack_core::{ chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkingContext}, ident::AssetIdent, @@ -19,8 +19,8 @@ use crate::{ /// The chunk item for [EcmascriptModuleLocalsModule]. #[turbo_tasks::value(shared)] pub struct EcmascriptModuleLocalsChunkItem { - pub(super) module: Vc, - pub(super) chunking_context: Vc>, + pub(super) module: ResolvedVc, + pub(super) chunking_context: ResolvedVc>, } #[turbo_tasks::value_impl] @@ -52,10 +52,10 @@ impl EcmascriptChunkItem for EcmascriptModuleLocalsChunkItem { parsed, self.module.ident(), module_type_result.module_type, - chunking_context, - analyze_result.local_references, - analyze_result.code_generation, - analyze_result.async_module, + *chunking_context, + *analyze_result.local_references, + *analyze_result.code_generation, + *analyze_result.async_module, analyze_result.source_map, exports, async_module_info, @@ -63,15 +63,15 @@ impl EcmascriptChunkItem for EcmascriptModuleLocalsChunkItem { Ok(EcmascriptChunkItemContent::new( content, - self.chunking_context, - original_module.await?.options, + *chunking_context, + *original_module.await?.options, async_module_options, )) } #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - self.chunking_context + *self.chunking_context } } @@ -89,7 +89,7 @@ impl ChunkItem for EcmascriptModuleLocalsChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - Vc::upcast(self.chunking_context) + *ResolvedVc::upcast(self.chunking_context) } #[turbo_tasks::function] @@ -101,7 +101,7 @@ impl ChunkItem for EcmascriptModuleLocalsChunkItem { #[turbo_tasks::function] fn module(&self) -> Vc> { - Vc::upcast(self.module) + *ResolvedVc::upcast(self.module) } #[turbo_tasks::function] @@ -109,7 +109,7 @@ impl ChunkItem for EcmascriptModuleLocalsChunkItem { let module = self.module.await?; let analyze = module.module.analyze().await?; if let Some(async_module) = *analyze.async_module.await? { - let is_self_async = async_module.is_self_async(analyze.local_references); + let is_self_async = async_module.is_self_async(*analyze.local_references); Ok(is_self_async) } else { Ok(Vc::cell(false)) diff --git a/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/locals/module.rs b/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/locals/module.rs index 90faab22b121d..2dae886936bc3 100644 --- a/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/locals/module.rs +++ b/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/locals/module.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use anyhow::{bail, Result}; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks_fs::glob::Glob; use turbopack_core::{ asset::{Asset, AssetContent}, @@ -27,13 +27,13 @@ use crate::{ /// from [EcmascriptModuleFacadeModule] instead. #[turbo_tasks::value] pub struct EcmascriptModuleLocalsModule { - pub module: Vc, + pub module: ResolvedVc, } #[turbo_tasks::value_impl] impl EcmascriptModuleLocalsModule { #[turbo_tasks::function] - pub fn new(module: Vc) -> Vc { + pub fn new(module: ResolvedVc) -> Vc { EcmascriptModuleLocalsModule { module }.cell() } } @@ -50,7 +50,7 @@ impl Module for EcmascriptModuleLocalsModule { #[turbo_tasks::function] async fn references(&self) -> Result> { let result = self.module.analyze().await?; - Ok(result.local_references) + Ok(*result.local_references) } } @@ -113,8 +113,8 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleLocalsModule { impl ChunkableModule for EcmascriptModuleLocalsModule { #[turbo_tasks::function] fn as_chunk_item( - self: Vc, - chunking_context: Vc>, + self: ResolvedVc, + chunking_context: ResolvedVc>, ) -> Vc> { Vc::upcast( EcmascriptModuleLocalsChunkItem { diff --git a/turbopack/crates/turbopack-ecmascript/src/static_code.rs b/turbopack/crates/turbopack-ecmascript/src/static_code.rs index 7e0339c56bcb0..31a290eba4cb4 100644 --- a/turbopack/crates/turbopack-ecmascript/src/static_code.rs +++ b/turbopack/crates/turbopack-ecmascript/src/static_code.rs @@ -1,5 +1,5 @@ use anyhow::{bail, Result}; -use turbo_tasks::{Value, Vc}; +use turbo_tasks::{ResolvedVc, Value, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ code_builder::{Code, CodeBuilder}, @@ -16,7 +16,7 @@ use crate::EcmascriptAnalyzable; /// the final runtime code, while keeping source map information. #[turbo_tasks::value] pub struct StaticEcmascriptCode { - asset_context: Vc>, + asset_context: ResolvedVc>, asset: Vc>, } @@ -25,12 +25,12 @@ impl StaticEcmascriptCode { /// Creates a new [`Vc`]. #[turbo_tasks::function] pub async fn new( - asset_context: Vc>, - asset_path: Vc, + asset_context: ResolvedVc>, + asset_path: ResolvedVc, ) -> Result> { let module = asset_context .process( - Vc::upcast(FileSource::new(asset_path)), + Vc::upcast(FileSource::new(*asset_path)), Value::new(ReferenceType::Runtime), ) .module(); diff --git a/turbopack/crates/turbopack-ecmascript/src/text/mod.rs b/turbopack/crates/turbopack-ecmascript/src/text/mod.rs index 3dfc4dd7a3c4c..2253e9285c2d9 100644 --- a/turbopack/crates/turbopack-ecmascript/src/text/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/text/mod.rs @@ -1,6 +1,6 @@ use anyhow::Result; use turbo_rcstr::RcStr; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks_fs::FileContent; use turbopack_core::{ asset::{Asset, AssetContent}, @@ -19,13 +19,13 @@ fn modifier() -> Vc { /// export of a JS module. #[turbo_tasks::value] pub struct TextContentFileSource { - pub source: Vc>, + pub source: ResolvedVc>, } #[turbo_tasks::value_impl] impl TextContentFileSource { #[turbo_tasks::function] - pub fn new(source: Vc>) -> Vc { + pub fn new(source: ResolvedVc>) -> Vc { TextContentFileSource { source }.cell() } } diff --git a/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs b/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs index e58c43409350c..2f0c72b7b9e79 100644 --- a/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs @@ -29,7 +29,7 @@ use turbopack_core::{ #[derive(Debug, Clone, Hash)] pub enum EcmascriptInputTransform { CommonJs, - Plugin(Vc), + Plugin(ResolvedVc), PresetEnv(ResolvedVc), React { #[serde(default)] @@ -37,9 +37,9 @@ pub enum EcmascriptInputTransform { #[serde(default)] refresh: bool, // swc.jsc.transform.react.importSource - import_source: Vc>, + import_source: ResolvedVc>, // swc.jsc.transform.react.runtime, - runtime: Vc>, + runtime: ResolvedVc>, }, GlobalTypeofs { window_value: String, @@ -115,7 +115,7 @@ pub struct TransformContext<'a> { pub file_path_str: &'a str, pub file_name_str: &'a str, pub file_name_hash: u128, - pub file_path: Vc, + pub file_path: ResolvedVc, } impl EcmascriptInputTransform { @@ -305,7 +305,7 @@ pub fn remove_shebang(program: &mut Program) { #[turbo_tasks::value(shared)] pub struct UnsupportedServerActionIssue { - pub file_path: Vc, + pub file_path: ResolvedVc, } #[turbo_tasks::value_impl] @@ -325,7 +325,7 @@ impl Issue for UnsupportedServerActionIssue { #[turbo_tasks::function] fn file_path(&self) -> Vc { - self.file_path + *self.file_path } #[turbo_tasks::function] diff --git a/turbopack/crates/turbopack-ecmascript/src/tree_shake/asset.rs b/turbopack/crates/turbopack-ecmascript/src/tree_shake/asset.rs index cbcf7befb6c53..6c37c96622bec 100644 --- a/turbopack/crates/turbopack-ecmascript/src/tree_shake/asset.rs +++ b/turbopack/crates/turbopack-ecmascript/src/tree_shake/asset.rs @@ -1,5 +1,5 @@ use anyhow::{Context, Result}; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack_core::{ asset::{Asset, AssetContent}, chunk::{AsyncModuleInfo, ChunkableModule, ChunkingContext, EvaluatableAsset}, @@ -26,8 +26,8 @@ use crate::{ /// This type is used for an advanced tree shkaing. #[turbo_tasks::value] pub struct EcmascriptModulePartAsset { - pub full_module: Vc, - pub part: Vc, + pub full_module: ResolvedVc, + pub part: ResolvedVc, } #[turbo_tasks::value_impl] @@ -36,7 +36,7 @@ impl EcmascriptParsable for EcmascriptModulePartAsset { async fn failsafe_parse(&self) -> Result> { let parsed = self.full_module.failsafe_parse(); let split_data = split(self.full_module.ident(), self.full_module.source(), parsed); - Ok(part_of_module(split_data, self.part)) + Ok(part_of_module(split_data, *self.part)) } #[turbo_tasks::function] fn parse_original(&self) -> Vc { @@ -54,7 +54,7 @@ impl EcmascriptAnalyzable for EcmascriptModulePartAsset { #[turbo_tasks::function] fn analyze(&self) -> Vc { let part = self.part; - analyse_ecmascript_module(self.full_module, Some(part)) + analyse_ecmascript_module(*self.full_module, Some(*part)) } #[turbo_tasks::function] @@ -79,7 +79,10 @@ impl EcmascriptModulePartAsset { /// of a pointer to the full module and the [ModulePart] pointing the part /// of the module. #[turbo_tasks::function] - pub fn new(module: Vc, part: Vc) -> Vc { + pub fn new( + module: ResolvedVc, + part: ResolvedVc, + ) -> Vc { EcmascriptModulePartAsset { full_module: module, part, @@ -104,7 +107,7 @@ impl EcmascriptModulePartAsset { #[turbo_tasks::function] pub async fn is_async_module(self: Vc) -> Result> { let this = self.await?; - let result = analyze(this.full_module, this.part); + let result = analyze(*this.full_module, *this.part); if let Some(async_module) = *result.await?.async_module.await? { Ok(async_module.is_self_async(self.references())) @@ -118,23 +121,23 @@ impl EcmascriptModulePartAsset { impl Module for EcmascriptModulePartAsset { #[turbo_tasks::function] fn ident(&self) -> Vc { - self.full_module.ident().with_part(self.part) + self.full_module.ident().with_part(*self.part) } #[turbo_tasks::function] async fn references(&self) -> Result> { - let split_data = split_module(self.full_module).await?; + let split_data = split_module(*self.full_module).await?; - let analyze = analyze(self.full_module, self.part).await?; + let analyze = analyze(*self.full_module, *self.part).await?; let deps = match &*split_data { SplitResult::Ok { deps, .. } => deps, - SplitResult::Failed { .. } => return Ok(analyze.references), + SplitResult::Failed { .. } => return Ok(*analyze.references), }; let part_dep = |part: Vc| -> Vc> { Vc::upcast(SingleModuleReference::new( - Vc::upcast(EcmascriptModulePartAsset::new(self.full_module, part)), + Vc::upcast(EcmascriptModulePartAsset::new(*self.full_module, part)), Vc::cell("ecmascript module part".into()), )) }; @@ -149,7 +152,7 @@ impl Module for EcmascriptModulePartAsset { } let deps = { - let part_id = get_part_id(&split_data, self.part) + let part_id = get_part_id(&split_data, *self.part) .await .with_context(|| format!("part {:?} is not found in the module", self.part))?; @@ -194,7 +197,7 @@ impl Asset for EcmascriptModulePartAsset { impl EcmascriptChunkPlaceable for EcmascriptModulePartAsset { #[turbo_tasks::function] async fn get_exports(self: Vc) -> Result> { - Ok(self.analyze().await?.exports) + Ok(*self.analyze().await?.exports) } } @@ -202,8 +205,8 @@ impl EcmascriptChunkPlaceable for EcmascriptModulePartAsset { impl ChunkableModule for EcmascriptModulePartAsset { #[turbo_tasks::function] fn as_chunk_item( - self: Vc, - chunking_context: Vc>, + self: ResolvedVc, + chunking_context: ResolvedVc>, ) -> Vc> { Vc::upcast( EcmascriptModulePartChunkItem { @@ -219,7 +222,7 @@ impl ChunkableModule for EcmascriptModulePartAsset { impl EcmascriptModulePartAsset { #[turbo_tasks::function] pub(super) fn analyze(&self) -> Vc { - analyze(self.full_module, self.part) + analyze(*self.full_module, *self.part) } } diff --git a/turbopack/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs b/turbopack/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs index 9d7c8d4a29feb..28d1428927656 100644 --- a/turbopack/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs +++ b/turbopack/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack_core::{ chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkingContext}, ident::AssetIdent, @@ -19,8 +19,8 @@ use crate::{ /// This is a pointer to a part of an ES module. #[turbo_tasks::value(shared)] pub struct EcmascriptModulePartChunkItem { - pub(super) module: Vc, - pub(super) chunking_context: Vc>, + pub(super) module: ResolvedVc, + pub(super) chunking_context: ResolvedVc>, } #[turbo_tasks::value_impl] @@ -37,8 +37,8 @@ impl EcmascriptChunkItem for EcmascriptModulePartChunkItem { ) -> Result> { let module = self.module.await?; - let split_data = split_module(module.full_module); - let parsed = part_of_module(split_data, module.part); + let split_data = split_module(*module.full_module); + let parsed = part_of_module(split_data, *module.part); let analyze = self.module.analyze().await?; let async_module_options = analyze.async_module.module_options(async_module_info); @@ -49,26 +49,26 @@ impl EcmascriptChunkItem for EcmascriptModulePartChunkItem { parsed, module.full_module.ident(), module_type_result.module_type, - self.chunking_context, - analyze.references, - analyze.code_generation, - analyze.async_module, + *self.chunking_context, + *analyze.references, + *analyze.code_generation, + *analyze.async_module, analyze.source_map, - analyze.exports, + *analyze.exports, async_module_info, ); Ok(EcmascriptChunkItemContent::new( content, - self.chunking_context, - module.full_module.await?.options, + *self.chunking_context, + *module.full_module.await?.options, async_module_options, )) } #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - self.chunking_context + *self.chunking_context } } @@ -86,7 +86,7 @@ impl ChunkItem for EcmascriptModulePartChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - Vc::upcast(self.chunking_context) + *ResolvedVc::upcast(self.chunking_context) } #[turbo_tasks::function] @@ -98,7 +98,7 @@ impl ChunkItem for EcmascriptModulePartChunkItem { #[turbo_tasks::function] fn module(&self) -> Vc> { - Vc::upcast(self.module) + *ResolvedVc::upcast(self.module) } #[turbo_tasks::function] diff --git a/turbopack/crates/turbopack-ecmascript/src/tree_shake/mod.rs b/turbopack/crates/turbopack-ecmascript/src/tree_shake/mod.rs index 0c8bbf9aaf92b..b64043161a6c0 100644 --- a/turbopack/crates/turbopack-ecmascript/src/tree_shake/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/tree_shake/mod.rs @@ -13,7 +13,7 @@ use swc_core::{ }, }; use turbo_rcstr::RcStr; -use turbo_tasks::{FxIndexSet, ValueToString, Vc}; +use turbo_tasks::{FxIndexSet, ResolvedVc, ValueToString, Vc}; use turbopack_core::{ident::AssetIdent, resolve::ModulePart, source::Source}; pub(crate) use self::graph::{ @@ -442,14 +442,14 @@ async fn get_part_id(result: &SplitResult, part: Vc) -> Result #[turbo_tasks::value(shared, serialization = "none", eq = "manual")] pub(crate) enum SplitResult { Ok { - asset_ident: Vc, + asset_ident: ResolvedVc, /// `u32` is a index to `modules`. #[turbo_tasks(trace_ignore)] entrypoints: FxHashMap, #[turbo_tasks(debug_ignore, trace_ignore)] - modules: Vec>, + modules: Vec>, #[turbo_tasks(trace_ignore)] deps: FxHashMap>, @@ -458,7 +458,7 @@ pub(crate) enum SplitResult { star_reexports: Vec, }, Failed { - parse_result: Vc, + parse_result: ResolvedVc, }, } @@ -478,9 +478,9 @@ pub(super) async fn split_module(asset: Vc) -> Result, + ident: ResolvedVc, source: Vc>, - parsed: Vc, + parsed: ResolvedVc, ) -> Result> { // Do not split already split module if !ident.await?.parts.is_empty() { @@ -580,7 +580,7 @@ pub(super) async fn split( Some(source), ); - ParseResult::cell(ParseResult::Ok { + ParseResult::resolved_cell(ParseResult::Ok { program, globals: globals.clone(), comments: comments.clone(), @@ -728,8 +728,8 @@ pub(crate) async fn part_of_module( ); } - Ok(modules[part_id as usize]) + Ok(*modules[part_id as usize]) } - SplitResult::Failed { parse_result } => Ok(*parse_result), + SplitResult::Failed { parse_result } => Ok(**parse_result), } } diff --git a/turbopack/crates/turbopack-ecmascript/src/typescript/mod.rs b/turbopack/crates/turbopack-ecmascript/src/typescript/mod.rs index 88385cd21077f..820fdc3e50392 100644 --- a/turbopack/crates/turbopack-ecmascript/src/typescript/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/typescript/mod.rs @@ -169,14 +169,17 @@ impl Asset for TsConfigModuleAsset { #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct CompilerReference { - pub origin: Vc>, - pub request: Vc, + pub origin: ResolvedVc>, + pub request: ResolvedVc, } #[turbo_tasks::value_impl] impl CompilerReference { #[turbo_tasks::function] - pub fn new(origin: Vc>, request: Vc) -> Vc { + pub fn new( + origin: ResolvedVc>, + request: ResolvedVc, + ) -> Vc { Self::cell(CompilerReference { origin, request }) } } @@ -185,7 +188,7 @@ impl CompilerReference { impl ModuleReference for CompilerReference { #[turbo_tasks::function] fn resolve_reference(&self) -> Vc { - cjs_resolve(self.origin, self.request, None, false) + cjs_resolve(*self.origin, *self.request, None, false) } } @@ -202,13 +205,13 @@ impl ValueToString for CompilerReference { #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct TsExtendsReference { - pub config: Vc>, + pub config: ResolvedVc>, } #[turbo_tasks::value_impl] impl TsExtendsReference { #[turbo_tasks::function] - pub fn new(config: Vc>) -> Vc { + pub fn new(config: ResolvedVc>) -> Vc { Self::cell(TsExtendsReference { config }) } } @@ -218,7 +221,7 @@ impl ModuleReference for TsExtendsReference { #[turbo_tasks::function] async fn resolve_reference(&self) -> Result> { Ok(ModuleResolveResult::module(ResolvedVc::upcast( - RawModule::new(Vc::upcast(self.config)) + RawModule::new(*ResolvedVc::upcast(self.config)) .to_resolved() .await?, )) @@ -243,14 +246,17 @@ impl ValueToString for TsExtendsReference { #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct TsNodeRequireReference { - pub origin: Vc>, - pub request: Vc, + pub origin: ResolvedVc>, + pub request: ResolvedVc, } #[turbo_tasks::value_impl] impl TsNodeRequireReference { #[turbo_tasks::function] - pub fn new(origin: Vc>, request: Vc) -> Vc { + pub fn new( + origin: ResolvedVc>, + request: ResolvedVc, + ) -> Vc { Self::cell(TsNodeRequireReference { origin, request }) } } @@ -259,7 +265,7 @@ impl TsNodeRequireReference { impl ModuleReference for TsNodeRequireReference { #[turbo_tasks::function] fn resolve_reference(&self) -> Vc { - cjs_resolve(self.origin, self.request, None, false) + cjs_resolve(*self.origin, *self.request, None, false) } } @@ -280,14 +286,17 @@ impl ValueToString for TsNodeRequireReference { #[turbo_tasks::value] #[derive(Hash, Debug)] pub struct TsConfigTypesReference { - pub origin: Vc>, - pub request: Vc, + pub origin: ResolvedVc>, + pub request: ResolvedVc, } #[turbo_tasks::value_impl] impl TsConfigTypesReference { #[turbo_tasks::function] - pub fn new(origin: Vc>, request: Vc) -> Vc { + pub fn new( + origin: ResolvedVc>, + request: ResolvedVc, + ) -> Vc { Self::cell(TsConfigTypesReference { origin, request }) } } @@ -296,7 +305,7 @@ impl TsConfigTypesReference { impl ModuleReference for TsConfigTypesReference { #[turbo_tasks::function] fn resolve_reference(&self) -> Vc { - type_resolve(self.origin, self.request) + type_resolve(*self.origin, *self.request) } } diff --git a/turbopack/crates/turbopack-ecmascript/src/webpack/mod.rs b/turbopack/crates/turbopack-ecmascript/src/webpack/mod.rs index e70b3122305bc..c39f379cb0a79 100644 --- a/turbopack/crates/turbopack-ecmascript/src/webpack/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/webpack/mod.rs @@ -31,18 +31,18 @@ fn modifier() -> Vc { #[turbo_tasks::value] pub struct WebpackModuleAsset { - pub source: Vc>, - pub runtime: Vc, - pub transforms: Vc, + pub source: ResolvedVc>, + pub runtime: ResolvedVc, + pub transforms: ResolvedVc, } #[turbo_tasks::value_impl] impl WebpackModuleAsset { #[turbo_tasks::function] pub fn new( - source: Vc>, - runtime: Vc, - transforms: Vc, + source: ResolvedVc>, + runtime: ResolvedVc, + transforms: ResolvedVc, ) -> Vc { Self::cell(WebpackModuleAsset { source, @@ -61,7 +61,7 @@ impl Module for WebpackModuleAsset { #[turbo_tasks::function] fn references(&self) -> Vc { - module_references(self.source, self.runtime, self.transforms) + module_references(*self.source, *self.runtime, *self.transforms) } } @@ -78,7 +78,7 @@ pub struct WebpackChunkAssetReference { #[turbo_tasks(trace_ignore)] pub chunk_id: Lit, pub runtime: Vc, - pub transforms: Vc, + pub transforms: ResolvedVc, } #[turbo_tasks::value_impl] @@ -101,7 +101,7 @@ impl ModuleReference for WebpackChunkAssetReference { let source = Vc::upcast(FileSource::new(context_path.join(filename))); ModuleResolveResult::module(ResolvedVc::upcast( - WebpackModuleAsset::new(source, self.runtime, self.transforms) + WebpackModuleAsset::new(source, self.runtime, *self.transforms) .to_resolved() .await?, )) @@ -127,9 +127,9 @@ impl ValueToString for WebpackChunkAssetReference { #[turbo_tasks::value(shared)] pub struct WebpackEntryAssetReference { - pub source: Vc>, + pub source: ResolvedVc>, pub runtime: Vc, - pub transforms: Vc, + pub transforms: ResolvedVc, } #[turbo_tasks::value_impl] @@ -137,7 +137,7 @@ impl ModuleReference for WebpackEntryAssetReference { #[turbo_tasks::function] async fn resolve_reference(&self) -> Result> { Ok(ModuleResolveResult::module(ResolvedVc::upcast( - WebpackModuleAsset::new(self.source, self.runtime, self.transforms) + WebpackModuleAsset::new(*self.source, self.runtime, *self.transforms) .to_resolved() .await?, )) @@ -155,10 +155,10 @@ impl ValueToString for WebpackEntryAssetReference { #[turbo_tasks::value(shared)] pub struct WebpackRuntimeAssetReference { - pub origin: Vc>, + pub origin: ResolvedVc>, pub request: Vc, pub runtime: Vc, - pub transforms: Vc, + pub transforms: ResolvedVc, } #[turbo_tasks::value_impl] @@ -181,7 +181,7 @@ impl ModuleReference for WebpackRuntimeAssetReference { .await? .map_module(|source| async move { Ok(ModuleResolveResultItem::Module(ResolvedVc::upcast( - WebpackModuleAsset::new(*source, self.runtime, self.transforms) + WebpackModuleAsset::new(*source, self.runtime, *self.transforms) .to_resolved() .await?, ))) diff --git a/turbopack/crates/turbopack-ecmascript/src/webpack/parse.rs b/turbopack/crates/turbopack-ecmascript/src/webpack/parse.rs index 50567b3fc4ce7..b7a3a47f10649 100644 --- a/turbopack/crates/turbopack-ecmascript/src/webpack/parse.rs +++ b/turbopack/crates/turbopack-ecmascript/src/webpack/parse.rs @@ -12,7 +12,7 @@ use swc_core::{ visit::{Visit, VisitWith}, }, }; -use turbo_tasks::{Value, Vc}; +use turbo_tasks::{ResolvedVc, Value, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::source::Source; @@ -31,7 +31,7 @@ pub enum WebpackRuntime { /// before converting to string #[turbo_tasks(trace_ignore)] chunk_request_expr: JsValue, - context_path: Vc, + context_path: ResolvedVc, }, None, } @@ -232,7 +232,7 @@ pub async fn webpack_runtime( return Ok(WebpackRuntime::Webpack5 { chunk_request_expr: value, - context_path: source.ident().path().parent().resolve().await?, + context_path: source.ident().path().parent().to_resolved().await?, } .into()); } diff --git a/turbopack/crates/turbopack-ecmascript/src/webpack/references.rs b/turbopack/crates/turbopack-ecmascript/src/webpack/references.rs index fefcd468f411e..ee7750c034bf3 100644 --- a/turbopack/crates/turbopack-ecmascript/src/webpack/references.rs +++ b/turbopack/crates/turbopack-ecmascript/src/webpack/references.rs @@ -6,7 +6,7 @@ use swc_core::{ visit::{Visit, VisitWith}, }, }; -use turbo_tasks::{Value, Vc}; +use turbo_tasks::{ResolvedVc, Value, Vc}; use turbopack_core::{ reference::{ModuleReference, ModuleReferences}, source::Source, @@ -23,12 +23,12 @@ use crate::{ pub async fn module_references( source: Vc>, runtime: Vc, - transforms: Vc, + transforms: ResolvedVc, ) -> Result> { let parsed = parse( source, Value::new(EcmascriptModuleAssetType::Ecmascript), - transforms, + *transforms, ) .await?; match &*parsed { @@ -64,7 +64,7 @@ pub async fn module_references( struct ModuleReferencesVisitor<'a> { runtime: Vc, references: &'a mut Vec>>, - transforms: Vc, + transforms: ResolvedVc, } impl Visit for ModuleReferencesVisitor<'_> { diff --git a/turbopack/crates/turbopack-ecmascript/src/worker_chunk/chunk_item.rs b/turbopack/crates/turbopack-ecmascript/src/worker_chunk/chunk_item.rs index 09f522e3d2b06..2b6579d87d352 100644 --- a/turbopack/crates/turbopack-ecmascript/src/worker_chunk/chunk_item.rs +++ b/turbopack/crates/turbopack-ecmascript/src/worker_chunk/chunk_item.rs @@ -1,7 +1,7 @@ use anyhow::{bail, Result}; use indoc::formatdoc; use turbo_rcstr::RcStr; -use turbo_tasks::{TryJoinIterExt, Value, ValueToString, Vc}; +use turbo_tasks::{ResolvedVc, TryJoinIterExt, Value, ValueToString, Vc}; use turbopack_core::{ chunk::{ availability_info::AvailabilityInfo, ChunkData, ChunkItem, ChunkType, ChunkingContext, @@ -24,8 +24,8 @@ use crate::{ #[turbo_tasks::value(shared)] pub struct WorkerLoaderChunkItem { - pub module: Vc, - pub chunking_context: Vc>, + pub module: ResolvedVc, + pub chunking_context: ResolvedVc>, } #[turbo_tasks::function] @@ -40,7 +40,7 @@ impl WorkerLoaderChunkItem { let module = self.module.await?; let Some(evaluatable) = - Vc::try_resolve_downcast::>(module.inner).await? + ResolvedVc::try_downcast::>(module.inner).await? else { bail!( "{} is not evaluatable for Worker loader module", @@ -54,7 +54,7 @@ impl WorkerLoaderChunkItem { .chunk_path(module.inner.ident(), ".js".into()), ) .with_modifier(worker_modifier()), - EvaluatableAssets::empty().with_entry(evaluatable), + EvaluatableAssets::empty().with_entry(*evaluatable), Value::new(AvailabilityInfo::Root), )) } @@ -73,7 +73,7 @@ impl WorkerLoaderChunkItem { impl EcmascriptChunkItem for WorkerLoaderChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - self.chunking_context + *self.chunking_context } #[turbo_tasks::function] @@ -138,7 +138,7 @@ impl ChunkItem for WorkerLoaderChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - Vc::upcast(self.chunking_context) + *ResolvedVc::upcast(self.chunking_context) } #[turbo_tasks::function] @@ -150,6 +150,6 @@ impl ChunkItem for WorkerLoaderChunkItem { #[turbo_tasks::function] fn module(&self) -> Vc> { - Vc::upcast(self.module) + *ResolvedVc::upcast(self.module) } } diff --git a/turbopack/crates/turbopack-ecmascript/src/worker_chunk/module.rs b/turbopack/crates/turbopack-ecmascript/src/worker_chunk/module.rs index 65909800b9533..11c9ade6875c8 100644 --- a/turbopack/crates/turbopack-ecmascript/src/worker_chunk/module.rs +++ b/turbopack/crates/turbopack-ecmascript/src/worker_chunk/module.rs @@ -1,6 +1,6 @@ use anyhow::Result; use turbo_rcstr::RcStr; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack_core::{ asset::{Asset, AssetContent}, chunk::{ChunkableModule, ChunkingContext}, @@ -20,13 +20,13 @@ fn modifier() -> Vc { /// and exports a URL to pass to the worker constructor. #[turbo_tasks::value] pub struct WorkerLoaderModule { - pub inner: Vc>, + pub inner: ResolvedVc>, } #[turbo_tasks::value_impl] impl WorkerLoaderModule { #[turbo_tasks::function] - pub fn new(module: Vc>) -> Vc { + pub fn new(module: ResolvedVc>) -> Vc { Self::cell(WorkerLoaderModule { inner: module }) } @@ -45,13 +45,13 @@ fn inner_module_reference_description() -> Vc { impl Module for WorkerLoaderModule { #[turbo_tasks::function] fn ident(&self) -> Vc { - Self::asset_ident_for(self.inner) + Self::asset_ident_for(*self.inner) } #[turbo_tasks::function] async fn references(self: Vc) -> Result> { Ok(Vc::cell(vec![Vc::upcast(SingleModuleReference::new( - Vc::upcast(self.await?.inner), + *ResolvedVc::upcast(self.await?.inner), inner_module_reference_description(), ))])) } @@ -69,8 +69,8 @@ impl Asset for WorkerLoaderModule { impl ChunkableModule for WorkerLoaderModule { #[turbo_tasks::function] fn as_chunk_item( - self: Vc, - chunking_context: Vc>, + self: ResolvedVc, + chunking_context: ResolvedVc>, ) -> Vc> { Vc::upcast( WorkerLoaderChunkItem { diff --git a/turbopack/crates/turbopack-tests/tests/snapshot.rs b/turbopack/crates/turbopack-tests/tests/snapshot.rs index 078c22e4cc244..d995afa5caf62 100644 --- a/turbopack/crates/turbopack-tests/tests/snapshot.rs +++ b/turbopack/crates/turbopack-tests/tests/snapshot.rs @@ -249,11 +249,11 @@ async fn run_test(resource: RcStr) -> Result> { conditions, vec![ModuleRuleEffect::ExtendEcmascriptTransforms { prepend: ResolvedVc::cell(vec![ - EcmascriptInputTransform::Plugin(Vc::cell(Box::new( + EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new( EmotionTransformer::new(&EmotionTransformConfig::default()) .expect("Should be able to create emotion transformer"), ) as _)), - EcmascriptInputTransform::Plugin(Vc::cell(Box::new( + EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new( StyledComponentsTransformer::new(&StyledComponentsTransformConfig::default()), ) as _)), ]), diff --git a/turbopack/crates/turbopack/src/module_options/mod.rs b/turbopack/crates/turbopack/src/module_options/mod.rs index 4ad6d427aafdc..dde4a1b8e078d 100644 --- a/turbopack/crates/turbopack/src/module_options/mod.rs +++ b/turbopack/crates/turbopack/src/module_options/mod.rs @@ -120,8 +120,8 @@ impl ModuleOptions { transforms.push(EcmascriptInputTransform::React { development: jsx.development, refresh: jsx.react_refresh, - import_source: Vc::cell(jsx.import_source.clone()), - runtime: Vc::cell(jsx.runtime.clone()), + import_source: ResolvedVc::cell(jsx.import_source.clone()), + runtime: ResolvedVc::cell(jsx.runtime.clone()), }); }