diff --git a/crates/next-api/src/dynamic_imports.rs b/crates/next-api/src/dynamic_imports.rs index bd4b919ec3758..77ac436dc4655 100644 --- a/crates/next-api/src/dynamic_imports.rs +++ b/crates/next-api/src/dynamic_imports.rs @@ -11,7 +11,7 @@ use tracing::{Instrument, Level}; use turbo_tasks::{ graph::{GraphTraversal, NonDeterministic, VisitControlFlow, VisitedNodes}, trace::TraceRawVcs, - FxIndexMap, RcStr, ReadRef, TryJoinIterExt, Value, ValueToString, Vc, + FxIndexMap, RcStr, ReadRef, ResolvedVc, TryJoinIterExt, Value, ValueToString, Vc, }; use turbopack_core::{ chunk::{ @@ -162,7 +162,7 @@ pub(crate) async fn collect_next_dynamic_imports( .iter() .map(|module| async move { Ok(NextDynamicVisitEntry::Module( - module.resolve().await?, + module.to_resolved().await?, module.ident().to_string().await?, )) }) @@ -209,8 +209,8 @@ pub(crate) async fn collect_next_dynamic_imports( #[derive(Debug, PartialEq, Eq, Hash, Clone, TraceRawVcs, Serialize, Deserialize)] enum NextDynamicVisitEntry { - Module(Vc>, ReadRef), - DynamicImportsMap(Vc), + Module(ResolvedVc>, ReadRef), + DynamicImportsMap(ResolvedVc), } #[turbo_tasks::value(transparent)] @@ -227,7 +227,7 @@ async fn get_next_dynamic_edges( .iter() .map(|&referenced_module| async move { Ok(NextDynamicVisitEntry::Module( - referenced_module, + referenced_module.to_resolved().await?, referenced_module.ident().to_string().await?, )) }) @@ -236,7 +236,7 @@ async fn get_next_dynamic_edges( if let Some(dynamic_imports_map) = *dynamic_imports_map.await? { edges.reserve_exact(1); edges.push(NextDynamicVisitEntry::DynamicImportsMap( - dynamic_imports_map, + dynamic_imports_map.to_resolved().await?, )); } Ok(Vc::cell(edges)) @@ -264,7 +264,7 @@ impl turbo_tasks::graph::Visit for NextDynamicVisit { }; let client_asset_context = self.client_asset_context; async move { - Ok(get_next_dynamic_edges(client_asset_context, module) + Ok(get_next_dynamic_edges(client_asset_context, *module) .await? .into_iter() .cloned()) diff --git a/crates/next-core/src/next_app/include_modules_module.rs b/crates/next-core/src/next_app/include_modules_module.rs index bd1485e54dbf0..d7dec3d17152c 100644 --- a/crates/next-core/src/next_app/include_modules_module.rs +++ b/crates/next-core/src/next_app/include_modules_module.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::{RcStr, TryJoinIterExt, ValueToString, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, TryJoinIterExt, ValueToString, Vc}; use turbo_tasks_fs::glob::Glob; use turbopack_core::{ asset::{Asset, AssetContent}, @@ -19,13 +19,13 @@ use turbopack_ecmascript::chunk::{ #[turbo_tasks::value] pub struct IncludeModulesModule { ident: Vc, - modules: Vec>>, + modules: Vec>>, } #[turbo_tasks::value_impl] impl IncludeModulesModule { #[turbo_tasks::function] - pub fn new(ident: Vc, modules: Vec>>) -> Vc { + pub fn new(ident: Vc, modules: Vec>>) -> Vc { Self { ident, modules }.cell() } } @@ -50,7 +50,7 @@ impl Module for IncludeModulesModule { .iter() .map(|&module| async move { Ok(Vc::upcast( - IncludedModuleReference::new(module).resolve().await?, + IncludedModuleReference::new(*module).resolve().await?, )) }) .try_join() diff --git a/crates/next-core/src/next_client/context.rs b/crates/next-core/src/next_client/context.rs index 236d4d8fb6bd7..282fe17c86ef8 100644 --- a/crates/next-core/src/next_client/context.rs +++ b/crates/next-core/src/next_client/context.rs @@ -1,7 +1,7 @@ use std::iter::once; use anyhow::Result; -use turbo_tasks::{FxIndexMap, RcStr, Value, Vc}; +use turbo_tasks::{FxIndexMap, RcStr, ResolvedVc, Value, Vc}; use turbo_tasks_env::EnvMap; use turbo_tasks_fs::{FileSystem, FileSystemPath}; use turbopack::{ @@ -193,8 +193,8 @@ fn internal_assets_conditions() -> ContextCondition { #[turbo_tasks::function] pub async fn get_client_module_options_context( project_path: Vc, - execution_context: Vc, - env: Vc, + execution_context: ResolvedVc, + env: ResolvedVc, ty: Value, mode: Vc, next_config: Vc, @@ -202,7 +202,7 @@ pub async fn get_client_module_options_context( let next_mode = mode.await?; let resolve_options_context = - get_client_resolve_options_context(project_path, ty, mode, next_config, execution_context); + get_client_resolve_options_context(project_path, ty, mode, next_config, *execution_context); let tsconfig = get_typescript_transform_options(project_path); let decorators_options = get_decorators_transform_options(project_path); @@ -312,7 +312,7 @@ pub async fn get_client_module_options_context( ecmascript: EcmascriptOptionsContext { enable_jsx: Some(jsx_runtime_options), enable_typescript_transform: Some(tsconfig), - enable_decorators: Some(decorators_options), + enable_decorators: Some(decorators_options.to_resolved().await?), ..module_options_context.ecmascript.clone() }, enable_webpack_loaders, @@ -408,8 +408,10 @@ pub async fn get_client_runtime_entries( // because the bootstrap contains JSX which requires Refresh's global // functions to be available. if let Some(request) = enable_react_refresh { - runtime_entries - .push(RuntimeEntry::Request(request, project_root.join("_".into())).cell()) + runtime_entries.push( + RuntimeEntry::Request(request.to_resolved().await?, project_root.join("_".into())) + .cell(), + ) }; } @@ -418,7 +420,9 @@ pub async fn get_client_runtime_entries( RuntimeEntry::Request( Request::parse(Value::new(Pattern::Constant( "next/dist/client/app-next-turbopack.js".into(), - ))), + ))) + .to_resolved() + .await?, project_root.join("_".into()), ) .cell(), diff --git a/crates/next-core/src/next_client/runtime_entry.rs b/crates/next-core/src/next_client/runtime_entry.rs index 9661ea46bf151..eb8f0353017db 100644 --- a/crates/next-core/src/next_client/runtime_entry.rs +++ b/crates/next-core/src/next_client/runtime_entry.rs @@ -12,8 +12,8 @@ use turbopack_ecmascript::resolve::cjs_resolve; #[turbo_tasks::value(shared)] pub enum RuntimeEntry { - Request(Vc, Vc), - Evaluatable(Vc>), + Request(ResolvedVc, Vc), + Evaluatable(ResolvedVc>), Source(ResolvedVc>), } @@ -25,7 +25,7 @@ impl RuntimeEntry { asset_context: Vc>, ) -> Result> { let (request, path) = match *self.await? { - RuntimeEntry::Evaluatable(e) => return Ok(EvaluatableAssets::one(e)), + RuntimeEntry::Evaluatable(e) => return Ok(EvaluatableAssets::one(*e)), RuntimeEntry::Source(source) => { return Ok(EvaluatableAssets::one(source.to_evaluatable(asset_context))); } @@ -34,7 +34,7 @@ impl RuntimeEntry { let modules = cjs_resolve( Vc::upcast(PlainResolveOrigin::new(asset_context, path)), - request, + *request, None, false, ) diff --git a/crates/next-core/src/next_config.rs b/crates/next-core/src/next_config.rs index fc9c5723ca9e4..38b659bd860e9 100644 --- a/crates/next-core/src/next_config.rs +++ b/crates/next-core/src/next_config.rs @@ -3,7 +3,7 @@ use std::collections::HashSet; use anyhow::{bail, Context, Result}; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value as JsonValue; -use turbo_tasks::{trace::TraceRawVcs, FxIndexMap, RcStr, TaskInput, Vc}; +use turbo_tasks::{trace::TraceRawVcs, FxIndexMap, RcStr, ResolvedVc, TaskInput, Vc}; use turbo_tasks_env::EnvMap; use turbo_tasks_fs::FileSystemPath; use turbopack::module_options::{ @@ -481,7 +481,7 @@ pub enum ReactCompilerOptionsOrBoolean { } #[turbo_tasks::value(transparent)] -pub struct OptionalReactCompilerOptions(Option>); +pub struct OptionalReactCompilerOptions(Option>); #[turbo_tasks::value(eq = "manual")] #[derive(Clone, Debug, Default, PartialEq)] @@ -1080,11 +1080,11 @@ impl NextConfig { compilation_mode: None, panic_threshold: None, } - .cell(), + .resolved_cell(), )) } Some(ReactCompilerOptionsOrBoolean::Option(options)) => OptionalReactCompilerOptions( - Some(ReactCompilerOptions { ..options.clone() }.cell()), + Some(ReactCompilerOptions { ..options.clone() }.resolved_cell()), ), _ => OptionalReactCompilerOptions(None), }; diff --git a/crates/next-core/src/next_edge/context.rs b/crates/next-core/src/next_edge/context.rs index 962b67f4b32ab..e68f79b72393f 100644 --- a/crates/next-core/src/next_edge/context.rs +++ b/crates/next-core/src/next_edge/context.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::{FxIndexMap, RcStr, Value, Vc}; +use turbo_tasks::{FxIndexMap, RcStr, ResolvedVc, Value, Vc}; use turbo_tasks_env::EnvMap; use turbo_tasks_fs::FileSystemPath; use turbopack::resolve_options_context::ResolveOptionsContext; @@ -60,7 +60,7 @@ async fn next_edge_defines(define_env: Vc) -> Result, + project_path: ResolvedVc, define_env: Vc, ) -> Result> { Ok(free_var_references!( diff --git a/crates/next-core/src/next_server/context.rs b/crates/next-core/src/next_server/context.rs index db235f5c3c481..c0fb49b2aa6fd 100644 --- a/crates/next-core/src/next_server/context.rs +++ b/crates/next-core/src/next_server/context.rs @@ -1,7 +1,7 @@ use std::iter::once; use anyhow::{bail, Result}; -use turbo_tasks::{FxIndexMap, RcStr, Value, Vc}; +use turbo_tasks::{FxIndexMap, RcStr, ResolvedVc, Value, Vc}; use turbo_tasks_env::{EnvMap, ProcessEnv}; use turbo_tasks_fs::{FileSystem, FileSystemPath}; use turbopack::{ @@ -179,7 +179,7 @@ pub async fn get_server_resolve_options_context( let server_external_packages_plugin = ExternalCjsModulesResolvePlugin::new( project_path, project_path.root(), - ExternalPredicate::Only(Vc::cell(external_packages)).cell(), + ExternalPredicate::Only(ResolvedVc::cell(external_packages)).cell(), *next_config.import_externals().await?, ); @@ -202,7 +202,7 @@ pub async fn get_server_resolve_options_context( ExternalCjsModulesResolvePlugin::new( project_path, project_path.root(), - ExternalPredicate::AllExcept(Vc::cell(transpiled_packages)).cell(), + ExternalPredicate::AllExcept(ResolvedVc::cell(transpiled_packages)).cell(), *next_config.import_externals().await?, ) }; @@ -375,7 +375,7 @@ fn internal_assets_conditions() -> ContextCondition { #[turbo_tasks::function] pub async fn get_server_module_options_context( project_path: Vc, - execution_context: Vc, + execution_context: ResolvedVc, ty: Value, mode: Vc, next_config: Vc, @@ -569,7 +569,7 @@ pub async fn get_server_module_options_context( ecmascript: EcmascriptOptionsContext { enable_jsx: Some(jsx_runtime_options), enable_typescript_transform: Some(tsconfig), - enable_decorators: Some(decorators_options), + enable_decorators: Some(decorators_options.to_resolved().await?), ..module_options_context.ecmascript }, enable_webpack_loaders, @@ -632,7 +632,7 @@ pub async fn get_server_module_options_context( ecmascript: EcmascriptOptionsContext { enable_jsx: Some(jsx_runtime_options), enable_typescript_transform: Some(tsconfig), - enable_decorators: Some(decorators_options), + enable_decorators: Some(decorators_options.to_resolved().await?), ..module_options_context.ecmascript }, enable_webpack_loaders, @@ -706,7 +706,7 @@ pub async fn get_server_module_options_context( ecmascript: EcmascriptOptionsContext { enable_jsx: Some(rsc_jsx_runtime_options), enable_typescript_transform: Some(tsconfig), - enable_decorators: Some(decorators_options), + enable_decorators: Some(decorators_options.to_resolved().await?), ..module_options_context.ecmascript }, enable_webpack_loaders, @@ -779,7 +779,7 @@ pub async fn get_server_module_options_context( ecmascript: EcmascriptOptionsContext { enable_jsx: Some(rsc_jsx_runtime_options), enable_typescript_transform: Some(tsconfig), - enable_decorators: Some(decorators_options), + enable_decorators: Some(decorators_options.to_resolved().await?), ..module_options_context.ecmascript }, enable_webpack_loaders, @@ -869,7 +869,7 @@ pub async fn get_server_module_options_context( ecmascript: EcmascriptOptionsContext { enable_jsx: Some(jsx_runtime_options), enable_typescript_transform: Some(tsconfig), - enable_decorators: Some(decorators_options), + enable_decorators: Some(decorators_options.to_resolved().await?), ..module_options_context.ecmascript }, enable_webpack_loaders, diff --git a/crates/next-core/src/next_server/resolve.rs b/crates/next-core/src/next_server/resolve.rs index eaadf6a96e2bd..c5e3a5baabd46 100644 --- a/crates/next-core/src/next_server/resolve.rs +++ b/crates/next-core/src/next_server/resolve.rs @@ -1,6 +1,6 @@ use anyhow::Result; use serde::{Deserialize, Serialize}; -use turbo_tasks::{trace::TraceRawVcs, RcStr, Value, Vc}; +use turbo_tasks::{trace::TraceRawVcs, RcStr, ResolvedVc, Value, Vc}; use turbo_tasks_fs::{self, glob::Glob, FileJsonContent, FileSystemPath}; use turbopack_core::{ issue::{Issue, IssueExt, IssueSeverity, IssueStage, OptionStyledString, StyledString}, @@ -24,10 +24,10 @@ use turbopack_core::{ pub enum ExternalPredicate { /// Mark all modules as external if they're not listed in the list. /// Applies only to imports outside of node_modules. - AllExcept(Vc>), + AllExcept(ResolvedVc>), /// Only mark modules listed as external, whether inside node_modules or /// not. - Only(Vc>), + Only(ResolvedVc>), } /// Mark modules as external, so they're resolved at runtime instead of bundled. @@ -111,7 +111,7 @@ impl AfterResolvePlugin for ExternalCjsModulesResolvePlugin { return Ok(ResolveResultOption::none()); } - let exception_glob = packages_glob(*exceptions).await?; + let exception_glob = packages_glob(**exceptions).await?; if let Some(PackagesGlobs { path_glob, @@ -127,7 +127,7 @@ impl AfterResolvePlugin for ExternalCjsModulesResolvePlugin { false } ExternalPredicate::Only(externals) => { - let external_glob = packages_glob(*externals).await?; + let external_glob = packages_glob(**externals).await?; if let Some(PackagesGlobs { path_glob, diff --git a/crates/next-core/src/next_server_component/server_component_module.rs b/crates/next-core/src/next_server_component/server_component_module.rs index 5c684e69d52e3..d69c8dfe36e61 100644 --- a/crates/next-core/src/next_server_component/server_component_module.rs +++ b/crates/next-core/src/next_server_component/server_component_module.rs @@ -122,7 +122,7 @@ impl EcmascriptChunkPlaceable for NextServerComponentModule { exports, star_exports: vec![module_reference], } - .cell(), + .resolved_cell(), ) .cell() } diff --git a/crates/next-core/src/pages_structure.rs b/crates/next-core/src/pages_structure.rs index 87deebe96a959..284623574bcc9 100644 --- a/crates/next-core/src/pages_structure.rs +++ b/crates/next-core/src/pages_structure.rs @@ -1,6 +1,6 @@ use anyhow::Result; use tracing::Instrument; -use turbo_tasks::{RcStr, ValueToString, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, ValueToString, Vc}; use turbo_tasks_fs::{ DirectoryContent, DirectoryEntry, FileSystemEntryType, FileSystemPath, FileSystemPathOption, }; @@ -12,7 +12,7 @@ use crate::next_import_map::get_next_package; pub struct PagesStructureItem { pub base_path: Vc, pub extensions: Vc>, - pub fallback_path: Option>, + pub fallback_path: Option>, /// Pathname of this item in the Next.js router. pub next_router_path: Vc, @@ -29,7 +29,7 @@ impl PagesStructureItem { fn new( base_path: Vc, extensions: Vc>, - fallback_path: Option>, + fallback_path: Option>, next_router_path: Vc, original_path: Vc, ) -> Vc { @@ -53,7 +53,7 @@ impl PagesStructureItem { } } if let Some(fallback_path) = self.fallback_path { - Ok(fallback_path) + Ok(*fallback_path) } else { Ok(self.base_path) } diff --git a/turbopack/crates/turbo-tasks-testing/tests/all_in_one.rs b/turbopack/crates/turbo-tasks-testing/tests/all_in_one.rs index 2d2356e27820f..a5c50d36b669b 100644 --- a/turbopack/crates/turbo-tasks-testing/tests/all_in_one.rs +++ b/turbopack/crates/turbo-tasks-testing/tests/all_in_one.rs @@ -3,7 +3,7 @@ #![feature(arbitrary_self_types_pointers)] use anyhow::{anyhow, bail, Result}; -use turbo_tasks::{RcStr, Value, ValueToString, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, Value, ValueToString, Vc}; use turbo_tasks_testing::{register, run, Registration}; static REGISTRATION: Registration = register!(); @@ -22,7 +22,7 @@ async fn all_in_one() { let c = MyStructValue { value: 42, - next: Some(MyStructValue::new(a)), + next: Some(MyStructValue::new(a).to_resolved().await?), } .into(); @@ -101,7 +101,7 @@ impl ValueToString for MyEnumValue { #[turbo_tasks::value(shared)] struct MyStructValue { value: u32, - next: Option>, + next: Option>, } #[turbo_tasks::value_impl] diff --git a/turbopack/crates/turbo-tasks-testing/tests/debug.rs b/turbopack/crates/turbo-tasks-testing/tests/debug.rs index 35d13c8d4e6f5..fc44f7c56e8c3 100644 --- a/turbopack/crates/turbo-tasks-testing/tests/debug.rs +++ b/turbopack/crates/turbo-tasks-testing/tests/debug.rs @@ -47,7 +47,7 @@ async fn enum_none_debug() { #[tokio::test] async fn enum_transparent_debug() { run(®ISTRATION, || async { - let a: Vc = Enum::Transparent(Transparent(42).resolved_cell()).cell(); + let a: Vc = Enum::Transparent(Transparent(42).cell()).cell(); assert_eq!( format!("{:?}", a.dbg().await?), r#"Enum :: Transparent( @@ -63,7 +63,7 @@ async fn enum_transparent_debug() { #[tokio::test] async fn enum_inner_vc_debug() { run(®ISTRATION, || async { - let a: Vc = Enum::Enum(Enum::None.resolved_cell()).cell(); + let a: Vc = Enum::Enum(Enum::None.cell()).cell(); assert_eq!( format!("{:?}", a.dbg().await?), r#"Enum :: Enum( @@ -163,8 +163,8 @@ struct Transparent(u32); #[turbo_tasks::value(shared)] enum Enum { None, - Transparent(ResolvedVc), - Enum(ResolvedVc), + Transparent(Vc), + Enum(Vc), } #[turbo_tasks::value(shared)] diff --git a/turbopack/crates/turbopack-browser/src/react_refresh.rs b/turbopack/crates/turbopack-browser/src/react_refresh.rs index 359a7703fc7fe..66648990c32e7 100644 --- a/turbopack/crates/turbopack-browser/src/react_refresh.rs +++ b/turbopack/crates/turbopack-browser/src/react_refresh.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::{Value, Vc}; +use turbo_tasks::{ResolvedVc, Value, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ issue::{Issue, IssueExt, IssueSeverity, IssueStage, OptionStyledString, StyledString}, @@ -23,14 +23,14 @@ fn react_refresh_request_in_next() -> Vc { #[turbo_tasks::value] pub enum ResolveReactRefreshResult { NotFound, - Found(Vc), + Found(ResolvedVc), } impl ResolveReactRefreshResult { pub fn as_request(&self) -> Option> { match self { ResolveReactRefreshResult::NotFound => None, - ResolveReactRefreshResult::Found(r) => Some(*r), + ResolveReactRefreshResult::Found(r) => Some(**r), } } pub fn is_found(&self) -> bool { @@ -62,7 +62,7 @@ pub async fn assert_can_resolve_react_refresh( .first_source(); if result.await?.is_some() { - return Ok(ResolveReactRefreshResult::Found(request).cell()); + return Ok(ResolveReactRefreshResult::Found(request.to_resolved().await?).cell()); } } ReactRefreshResolvingIssue { path }.cell().emit(); diff --git a/turbopack/crates/turbopack-cli-utils/src/runtime_entry.rs b/turbopack/crates/turbopack-cli-utils/src/runtime_entry.rs index 04d9c377fdfce..ae243b5d4aeaa 100644 --- a/turbopack/crates/turbopack-cli-utils/src/runtime_entry.rs +++ b/turbopack/crates/turbopack-cli-utils/src/runtime_entry.rs @@ -1,5 +1,5 @@ use anyhow::{bail, Result}; -use turbo_tasks::{ValueToString, Vc}; +use turbo_tasks::{ResolvedVc, ValueToString, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ chunk::{EvaluatableAsset, EvaluatableAssetExt, EvaluatableAssets}, @@ -12,8 +12,8 @@ use turbopack_resolve::ecmascript::cjs_resolve; #[turbo_tasks::value(shared)] pub enum RuntimeEntry { - Request(Vc, Vc), - Evaluatable(Vc>), + Request(ResolvedVc, ResolvedVc), + Evaluatable(ResolvedVc>), Source(Vc>), } @@ -25,7 +25,7 @@ impl RuntimeEntry { asset_context: Vc>, ) -> Result> { let (request, path) = match *self.await? { - RuntimeEntry::Evaluatable(e) => return Ok(EvaluatableAssets::one(e)), + RuntimeEntry::Evaluatable(e) => return Ok(EvaluatableAssets::one(*e)), RuntimeEntry::Source(source) => { return Ok(EvaluatableAssets::one(source.to_evaluatable(asset_context))); } @@ -33,8 +33,8 @@ impl RuntimeEntry { }; let modules = cjs_resolve( - Vc::upcast(PlainResolveOrigin::new(asset_context, path)), - request, + Vc::upcast(PlainResolveOrigin::new(asset_context, *path)), + *request, None, false, ) diff --git a/turbopack/crates/turbopack-cli/src/contexts.rs b/turbopack/crates/turbopack-cli/src/contexts.rs index 6d6566e57c82e..b8fc3ee26ea47 100644 --- a/turbopack/crates/turbopack-cli/src/contexts.rs +++ b/turbopack/crates/turbopack-cli/src/contexts.rs @@ -1,7 +1,7 @@ use std::fmt; use anyhow::Result; -use turbo_tasks::{RcStr, Value, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, Value, Vc}; use turbo_tasks_fs::{FileSystem, FileSystemPath}; use turbopack::{ ecmascript::{EcmascriptInputTransform, TreeShakingMode}, @@ -98,8 +98,8 @@ pub async fn get_client_resolve_options_context( #[turbo_tasks::function] async fn get_client_module_options_context( project_path: Vc, - execution_context: Vc, - env: Vc, + execution_context: ResolvedVc, + env: ResolvedVc, node_env: Vc, ) -> Result> { let module_options_context = ModuleOptionsContext { diff --git a/turbopack/crates/turbopack-cli/src/dev/web_entry_source.rs b/turbopack/crates/turbopack-cli/src/dev/web_entry_source.rs index d4814a3758cf6..d0f0c401b80db 100644 --- a/turbopack/crates/turbopack-cli/src/dev/web_entry_source.rs +++ b/turbopack/crates/turbopack-cli/src/dev/web_entry_source.rs @@ -1,5 +1,5 @@ use anyhow::{anyhow, Result}; -use turbo_tasks::{RcStr, TryJoinIterExt, Value, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, TryJoinIterExt, Value, Vc}; use turbo_tasks_env::ProcessEnv; use turbo_tasks_fs::FileSystemPath; use turbopack_browser::{react_refresh::assert_can_resolve_react_refresh, BrowserChunkingContext}; @@ -52,21 +52,27 @@ pub fn get_client_chunking_context( #[turbo_tasks::function] pub async fn get_client_runtime_entries( - project_path: Vc, + project_path: ResolvedVc, ) -> Result> { - let resolve_options_context = get_client_resolve_options_context(project_path); + let resolve_options_context = get_client_resolve_options_context(*project_path); let mut runtime_entries = Vec::new(); let enable_react_refresh = - assert_can_resolve_react_refresh(project_path, resolve_options_context) + assert_can_resolve_react_refresh(*project_path, resolve_options_context) .await? .as_request(); // It's important that React Refresh come before the regular bootstrap file, // because the bootstrap contains JSX which requires Refresh's global // functions to be available. if let Some(request) = enable_react_refresh { - runtime_entries.push(RuntimeEntry::Request(request, project_path.join("_".into())).cell()) + runtime_entries.push( + RuntimeEntry::Request( + request.to_resolved().await?, + project_path.join("_".into()).to_resolved().await?, + ) + .cell(), + ) }; runtime_entries.push( diff --git a/turbopack/crates/turbopack-core/src/chunk/available_chunk_items.rs b/turbopack/crates/turbopack-core/src/chunk/available_chunk_items.rs index ddf5f02880d73..b05c9d31f1de0 100644 --- a/turbopack/crates/turbopack-core/src/chunk/available_chunk_items.rs +++ b/turbopack/crates/turbopack-core/src/chunk/available_chunk_items.rs @@ -1,8 +1,8 @@ use anyhow::Result; use serde::{Deserialize, Serialize}; use turbo_tasks::{ - debug::ValueDebugFormat, trace::TraceRawVcs, FxIndexMap, TryFlatJoinIterExt, TryJoinIterExt, - ValueToString, Vc, + debug::ValueDebugFormat, trace::TraceRawVcs, FxIndexMap, ResolvedVc, TryFlatJoinIterExt, + TryJoinIterExt, ValueToString, Vc, }; use turbo_tasks_hash::Xxh3Hash64Hasher; @@ -24,7 +24,7 @@ pub struct AvailableChunkItemInfoMap(FxIndexMap>, Availabl /// `include` queries. #[turbo_tasks::value] pub struct AvailableChunkItems { - parent: Option>, + parent: Option>, chunk_items: Vc, } @@ -57,7 +57,7 @@ impl AvailableChunkItems { .try_flat_join() .await?; Ok(AvailableChunkItems { - parent: Some(self), + parent: Some(self.to_resolved().await?), chunk_items: Vc::cell(chunk_items.into_iter().collect()), } .cell()) diff --git a/turbopack/crates/turbopack-core/src/chunk/mod.rs b/turbopack/crates/turbopack-core/src/chunk/mod.rs index 07ebb48010f7e..93f444cde3adc 100644 --- a/turbopack/crates/turbopack-core/src/chunk/mod.rs +++ b/turbopack/crates/turbopack-core/src/chunk/mod.rs @@ -240,7 +240,7 @@ enum ChunkContentGraphNode { module: Vc>, }, // ModuleReferences that are not placed in the current chunk group - ExternalModuleReference(Vc>), + ExternalModuleReference(ResolvedVc>), /// A list of directly referenced chunk items from which `is_async_module` /// will be inherited. InheritAsyncInfo { @@ -257,7 +257,7 @@ enum ChunkGraphNodeToReferences { #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, TraceRawVcs)] struct ChunkGraphEdge { - key: Option>>, + key: Option>>, node: ChunkContentGraphNode, } @@ -346,14 +346,18 @@ async fn graph_node_to_referenced_nodes( else { return Ok(vec![ChunkGraphEdge { key: None, - node: ChunkContentGraphNode::ExternalModuleReference(reference), + node: ChunkContentGraphNode::ExternalModuleReference( + reference.to_resolved().await?, + ), }]); }; let Some(chunking_type) = *chunkable_module_reference.chunking_type().await? else { return Ok(vec![ChunkGraphEdge { key: None, - node: ChunkContentGraphNode::ExternalModuleReference(reference), + node: ChunkContentGraphNode::ExternalModuleReference( + reference.to_resolved().await?, + ), }]); }; @@ -371,7 +375,9 @@ async fn graph_node_to_referenced_nodes( return Ok(( Some(ChunkGraphEdge { key: None, - node: ChunkContentGraphNode::ExternalModuleReference(reference), + node: ChunkContentGraphNode::ExternalModuleReference( + reference.to_resolved().await?, + ), }), None, )); @@ -385,7 +391,7 @@ async fn graph_node_to_referenced_nodes( .await?; Ok(( Some(ChunkGraphEdge { - key: Some(module), + key: Some(module.to_resolved().await?), node: ChunkContentGraphNode::ChunkItem { item: chunk_item, ident: module.ident().to_string().await?, @@ -401,7 +407,7 @@ async fn graph_node_to_referenced_nodes( .await?; Ok(( Some(ChunkGraphEdge { - key: Some(module), + key: Some(module.to_resolved().await?), node: ChunkContentGraphNode::ChunkItem { item: chunk_item, ident: module.ident().to_string().await?, @@ -436,7 +442,7 @@ async fn graph_node_to_referenced_nodes( .await?; Ok(( Some(ChunkGraphEdge { - key: Some(module), + key: Some(module.to_resolved().await?), node: ChunkContentGraphNode::ChunkItem { item: chunk_item, ident: module.ident().to_string().await?, @@ -518,7 +524,7 @@ impl Visit for ChunkContentVisit { } }; - if !self.processed_modules.insert(module) { + if !self.processed_modules.insert(*module) { return VisitControlFlow::Skip(node); } @@ -582,7 +588,7 @@ async fn chunk_content_internal_parallel( return Ok(None); }; Ok(Some(ChunkGraphEdge { - key: Some(entry), + key: Some(entry.to_resolved().await?), node: ChunkContentGraphNode::ChunkItem { item: chunkable_module .as_chunk_item(chunking_context) @@ -628,7 +634,7 @@ async fn chunk_content_internal_parallel( } ChunkContentGraphNode::ExternalModuleReference(reference) => { let reference = reference.resolve().await?; - external_module_references.insert(reference); + external_module_references.insert(*reference); } ChunkContentGraphNode::InheritAsyncInfo { item, references } => { for &(reference, ty) in &references { diff --git a/turbopack/crates/turbopack-core/src/compile_time_info.rs b/turbopack/crates/turbopack-core/src/compile_time_info.rs index 916da133d0b72..90f4305983ea5 100644 --- a/turbopack/crates/turbopack-core/src/compile_time_info.rs +++ b/turbopack/crates/turbopack-core/src/compile_time_info.rs @@ -1,4 +1,4 @@ -use turbo_tasks::{FxIndexMap, RcStr, Vc}; +use turbo_tasks::{FxIndexMap, RcStr, ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use crate::environment::Environment; @@ -203,7 +203,7 @@ impl CompileTimeDefines { pub enum FreeVarReference { EcmaScriptModule { request: RcStr, - lookup_path: Option>, + lookup_path: Option>, export: Option, }, Value(CompileTimeDefineValue), diff --git a/turbopack/crates/turbopack-core/src/environment.rs b/turbopack/crates/turbopack-core/src/environment.rs index 31812a7a9b380..c448210048122 100644 --- a/turbopack/crates/turbopack-core/src/environment.rs +++ b/turbopack/crates/turbopack-core/src/environment.rs @@ -5,7 +5,7 @@ use std::{ use anyhow::{anyhow, Context, Result}; use swc_core::ecma::preset_env::{Version, Versions}; -use turbo_tasks::{RcStr, Value, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, Value, Vc}; use turbo_tasks_env::ProcessEnv; use crate::target::CompileTarget; @@ -247,8 +247,8 @@ impl NodeJsEnvironment { #[turbo_tasks::function] pub async fn runtime_versions(&self) -> Result> { let str = match *self.node_version.await? { - NodeJsVersion::Current(process_env) => get_current_nodejs_version(process_env), - NodeJsVersion::Static(version) => version, + NodeJsVersion::Current(process_env) => get_current_nodejs_version(*process_env), + NodeJsVersion::Static(version) => *version, } .await?; @@ -261,7 +261,7 @@ impl NodeJsEnvironment { } #[turbo_tasks::function] - pub fn current(process_env: Vc>) -> Vc { + pub fn current(process_env: ResolvedVc>) -> Vc { Self::cell(NodeJsEnvironment { compile_target: CompileTarget::current(), node_version: NodeJsVersion::cell(NodeJsVersion::Current(process_env)), @@ -272,13 +272,13 @@ impl NodeJsEnvironment { #[turbo_tasks::value(shared)] pub enum NodeJsVersion { - Current(Vc>), - Static(Vc), + Current(ResolvedVc>), + Static(ResolvedVc), } impl Default for NodeJsVersion { fn default() -> Self { - NodeJsVersion::Static(Vc::cell(DEFAULT_NODEJS_VERSION.into())) + NodeJsVersion::Static(ResolvedVc::cell(DEFAULT_NODEJS_VERSION.into())) } } diff --git a/turbopack/crates/turbopack-core/src/ident.rs b/turbopack/crates/turbopack-core/src/ident.rs index d0174c788146f..5e8f583d0bbff 100644 --- a/turbopack/crates/turbopack-core/src/ident.rs +++ b/turbopack/crates/turbopack-core/src/ident.rs @@ -23,7 +23,7 @@ pub struct AssetIdent { /// The part of the asset that is a (ECMAScript) module pub part: Option>, /// The asset layer the asset was created from. - pub layer: Option>, + pub layer: Option>, } impl AssetIdent { @@ -158,7 +158,7 @@ impl AssetIdent { } #[turbo_tasks::function] - pub fn with_layer(&self, layer: Vc) -> Vc { + pub fn with_layer(&self, layer: ResolvedVc) -> Vc { let mut this = self.clone(); this.layer = Some(layer); Self::new(Value::new(this)) diff --git a/turbopack/crates/turbopack-core/src/issue/mod.rs b/turbopack/crates/turbopack-core/src/issue/mod.rs index ffebdb4e21730..b364fe27382f3 100644 --- a/turbopack/crates/turbopack-core/src/issue/mod.rs +++ b/turbopack/crates/turbopack-core/src/issue/mod.rs @@ -429,7 +429,7 @@ impl CapturedIssues { #[derive(Clone, Debug)] pub struct IssueSource { source: Vc>, - range: Option>, + range: Option>, } /// The end position is the first character after the range @@ -460,7 +460,7 @@ impl IssueSource { ) -> Vc { Self::cell(IssueSource { source, - range: Some(SourceRange::LineColumn(start, end).cell()), + range: Some(SourceRange::LineColumn(start, end).resolved_cell()), }) } @@ -492,7 +492,7 @@ impl IssueSource { if let Some((source, start, end)) = mapped { return Ok(Self::cell(IssueSource { source, - range: Some(SourceRange::LineColumn(start, end).cell()), + range: Some(SourceRange::LineColumn(start, end).resolved_cell()), })); } } @@ -514,9 +514,11 @@ impl IssueSource { source, range: match (start == 0, end == 0) { (true, true) => None, - (false, false) => Some(SourceRange::ByteOffset(start - 1, end - 1).cell()), - (false, true) => Some(SourceRange::ByteOffset(start - 1, start - 1).cell()), - (true, false) => Some(SourceRange::ByteOffset(end - 1, end - 1).cell()), + (false, false) => Some(SourceRange::ByteOffset(start - 1, end - 1).resolved_cell()), + (false, true) => { + Some(SourceRange::ByteOffset(start - 1, start - 1).resolved_cell()) + } + (true, false) => Some(SourceRange::ByteOffset(end - 1, end - 1).resolved_cell()), }, }) } @@ -541,7 +543,7 @@ impl IssueSource { range: if let FileLinesContent::Lines(lines) = &*source.content().lines().await? { let start = find_line_and_column(lines.as_ref(), start); let end = find_line_and_column(lines.as_ref(), end); - Some(SourceRange::LineColumn(start, end).cell()) + Some(SourceRange::LineColumn(start, end).resolved_cell()) } else { None }, diff --git a/turbopack/crates/turbopack-core/src/issue/resolve.rs b/turbopack/crates/turbopack-core/src/issue/resolve.rs index dd05450798711..c9633312ff28f 100644 --- a/turbopack/crates/turbopack-core/src/issue/resolve.rs +++ b/turbopack/crates/turbopack-core/src/issue/resolve.rs @@ -1,7 +1,7 @@ use std::fmt::Write; use anyhow::Result; -use turbo_tasks::{RcStr, ReadRef, ValueToString, Vc}; +use turbo_tasks::{RcStr, ReadRef, ResolvedVc, ValueToString, Vc}; use turbo_tasks_fs::FileSystemPath; use super::{Issue, IssueSource, IssueStage, OptionIssueSource, OptionStyledString, StyledString}; @@ -22,7 +22,7 @@ pub struct ResolvingIssue { pub file_path: Vc, pub resolve_options: Vc, pub error_message: Option, - pub source: Option>, + pub source: Option>, } #[turbo_tasks::value_impl] diff --git a/turbopack/crates/turbopack-core/src/resolve/mod.rs b/turbopack/crates/turbopack-core/src/resolve/mod.rs index b41cc191bf722..c6d855105c4ad 100644 --- a/turbopack/crates/turbopack-core/src/resolve/mod.rs +++ b/turbopack/crates/turbopack-core/src/resolve/mod.rs @@ -10,8 +10,8 @@ use anyhow::{bail, Result}; use serde::{Deserialize, Serialize}; use tracing::{Instrument, Level}; use turbo_tasks::{ - fxindexmap, fxindexset, trace::TraceRawVcs, FxIndexMap, RcStr, TaskInput, TryJoinIterExt, - Value, ValueToString, Vc, + fxindexmap, fxindexset, trace::TraceRawVcs, FxIndexMap, RcStr, ResolvedVc, TaskInput, + TryJoinIterExt, Value, ValueToString, Vc, }; use turbo_tasks_fs::{ util::normalize_request, FileSystemEntryType, FileSystemPath, RealPathResult, @@ -67,7 +67,7 @@ pub enum ModuleResolveResultItem { OutputAsset(Vc>), External(RcStr, ExternalType), Ignore, - Error(Vc), + Error(ResolvedVc), Empty, Custom(u8), } @@ -675,7 +675,9 @@ impl ResolveResult { } ResolveResultItem::Ignore => ModuleResolveResultItem::Ignore, ResolveResultItem::Empty => ModuleResolveResultItem::Empty, - ResolveResultItem::Error(e) => ModuleResolveResultItem::Error(e), + ResolveResultItem::Error(e) => { + ModuleResolveResultItem::Error(e.to_resolved().await?) + } ResolveResultItem::Custom(u8) => { ModuleResolveResultItem::Custom(u8) } @@ -1202,8 +1204,8 @@ pub async fn find_context_file_or_package_key( #[derive(Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, Debug)] enum FindPackageItem { - PackageDirectory(Vc), - PackageFile(Vc), + PackageDirectory(ResolvedVc), + PackageFile(ResolvedVc), } #[turbo_tasks::value] @@ -1236,7 +1238,9 @@ async fn find_package( if let Some(fs_path) = dir_exists(fs_path, &mut affecting_sources).await? { - packages.push(FindPackageItem::PackageDirectory(fs_path)); + packages.push(FindPackageItem::PackageDirectory( + fs_path.to_resolved().await?, + )); } } } @@ -1259,10 +1263,14 @@ async fn find_package( { match ty { FileSystemEntryType::Directory => { - packages.push(FindPackageItem::PackageDirectory(package_dir)); + packages.push(FindPackageItem::PackageDirectory( + package_dir.to_resolved().await?, + )); } FileSystemEntryType::File => { - packages.push(FindPackageItem::PackageFile(package_dir)); + packages.push(FindPackageItem::PackageFile( + package_dir.to_resolved().await?, + )); } _ => {} } @@ -1274,7 +1282,9 @@ async fn find_package( let package_file = package_dir.append(extension.clone()); if let Some(package_file) = exists(package_file, &mut affecting_sources).await? { - packages.push(FindPackageItem::PackageFile(package_file)); + packages.push(FindPackageItem::PackageFile( + package_file.to_resolved().await?, + )); } } } @@ -1435,7 +1445,7 @@ pub async fn url_resolve( origin: Vc>, request: Vc, reference_type: Value, - issue_source: Option>, + issue_source: Option>, is_optional: bool, ) -> Result> { let resolve_options = origin.resolve_options(reference_type.clone()); @@ -2362,7 +2372,7 @@ async fn resolve_module_request( FindPackageItem::PackageDirectory(package_path) => { results.push(resolve_into_package( Value::new(path.clone()), - package_path, + *package_path, query, fragment, options, @@ -2372,7 +2382,7 @@ async fn resolve_module_request( if path.is_match("") { let resolved = resolved( RequestKey::new(".".into()), - package_path, + *package_path, lookup_path, request, options_value, @@ -2721,7 +2731,7 @@ pub async fn handle_resolve_error( request: Vc, resolve_options: Vc, is_optional: bool, - source: Option>, + source: Option>, ) -> Result> { async fn is_unresolvable(result: Vc) -> Result { Ok(*result.resolve().await?.is_unresolvable().await?) @@ -2765,7 +2775,7 @@ pub async fn handle_resolve_source_error( request: Vc, resolve_options: Vc, is_optional: bool, - source: Option>, + source: Option>, ) -> Result> { async fn is_unresolvable(result: Vc) -> Result { Ok(*result.resolve().await?.is_unresolvable().await?) @@ -2809,7 +2819,7 @@ async fn emit_resolve_error_issue( request: Vc, resolve_options: Vc, err: anyhow::Error, - source: Option>, + source: Option>, ) -> Result<()> { let severity = if is_optional || resolve_options.await?.loose_errors { IssueSeverity::Warning.cell() @@ -2836,7 +2846,7 @@ async fn emit_unresolvable_issue( reference_type: Value, request: Vc, resolve_options: Vc, - source: Option>, + source: Option>, ) -> Result<()> { let severity = if is_optional || resolve_options.await?.loose_errors { IssueSeverity::Warning.cell() @@ -2875,7 +2885,7 @@ pub enum ModulePart { /// all exports are unused. Evaluation, /// Represents an export of a module. - Export(Vc), + Export(ResolvedVc), /// Represents a renamed export of a module. RenamedExport { original_export: Vc, @@ -2902,7 +2912,7 @@ impl ModulePart { } #[turbo_tasks::function] pub fn export(export: RcStr) -> Vc { - ModulePart::Export(Vc::cell(export)).cell() + ModulePart::Export(ResolvedVc::cell(export)).cell() } #[turbo_tasks::function] pub fn renamed_export(original_export: RcStr, export: RcStr) -> Vc { diff --git a/turbopack/crates/turbopack-core/src/resolve/node.rs b/turbopack/crates/turbopack-core/src/resolve/node.rs index efcab014270c6..534e9da2639c5 100644 --- a/turbopack/crates/turbopack-core/src/resolve/node.rs +++ b/turbopack/crates/turbopack-core/src/resolve/node.rs @@ -1,4 +1,4 @@ -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use super::options::{ @@ -7,7 +7,7 @@ use super::options::{ }; #[turbo_tasks::function] -pub fn node_cjs_resolve_options(root: Vc) -> Vc { +pub fn node_cjs_resolve_options(root: ResolvedVc) -> Vc { let conditions: ResolutionConditions = [ ("node".into(), ConditionValue::Set), ("require".into(), ConditionValue::Set), @@ -37,7 +37,7 @@ pub fn node_cjs_resolve_options(root: Vc) -> Vc } #[turbo_tasks::function] -pub fn node_esm_resolve_options(root: Vc) -> Vc { +pub fn node_esm_resolve_options(root: ResolvedVc) -> Vc { let conditions: ResolutionConditions = [ ("node".into(), ConditionValue::Set), ("import".into(), ConditionValue::Set), diff --git a/turbopack/crates/turbopack-core/src/resolve/options.rs b/turbopack/crates/turbopack-core/src/resolve/options.rs index 2662a6257a2c0..762c70b900d1e 100644 --- a/turbopack/crates/turbopack-core/src/resolve/options.rs +++ b/turbopack/crates/turbopack-core/src/resolve/options.rs @@ -3,8 +3,8 @@ use std::{collections::BTreeMap, future::Future, pin::Pin}; use anyhow::{bail, Result}; use serde::{Deserialize, Serialize}; use turbo_tasks::{ - debug::ValueDebugFormat, trace::TraceRawVcs, FxIndexSet, RcStr, TryJoinIterExt, Value, - ValueToString, Vc, + debug::ValueDebugFormat, trace::TraceRawVcs, FxIndexSet, RcStr, ResolvedVc, TryJoinIterExt, + Value, ValueToString, Vc, }; use turbo_tasks_fs::{glob::Glob, FileSystemPath}; @@ -31,7 +31,7 @@ pub struct ExcludedExtensions(pub FxIndexSet); pub enum ResolveModules { /// when inside of path, use the list of directories to /// resolve inside these - Nested(Vc, Vec), + Nested(ResolvedVc, Vec), /// look into that directory, unless the request has an excluded extension Path { dir: Vc, @@ -95,7 +95,7 @@ pub enum ResolveInPackage { pub enum ImportMapping { External(Option, ExternalType), /// An already resolved result that will be returned directly. - Direct(Vc), + Direct(ResolvedVc), /// A request alias that will be resolved first, and fall back to resolving /// the original request if it fails. Useful for the tsconfig.json /// `compilerOptions.paths` option and Next aliases. @@ -152,7 +152,7 @@ impl AliasTemplate for Vc { ImportMapping::PrimaryAlternative(name, context) => { ReplacedImportMapping::PrimaryAlternative((*name).clone().into(), *context) } - ImportMapping::Direct(v) => ReplacedImportMapping::Direct(*v), + ImportMapping::Direct(v) => ReplacedImportMapping::Direct(**v), ImportMapping::Ignore => ReplacedImportMapping::Ignore, ImportMapping::Empty => ReplacedImportMapping::Empty, ImportMapping::Alternatives(alternatives) => ReplacedImportMapping::Alternatives( @@ -189,7 +189,7 @@ impl AliasTemplate for Vc { *context, ) } - ImportMapping::Direct(v) => ReplacedImportMapping::Direct(*v), + ImportMapping::Direct(v) => ReplacedImportMapping::Direct(**v), ImportMapping::Ignore => ReplacedImportMapping::Ignore, ImportMapping::Empty => ReplacedImportMapping::Empty, ImportMapping::Alternatives(alternatives) => ReplacedImportMapping::Alternatives( diff --git a/turbopack/crates/turbopack-css/src/asset.rs b/turbopack/crates/turbopack-css/src/asset.rs index f4b6e8470581b..93b3b005eecaf 100644 --- a/turbopack/crates/turbopack-css/src/asset.rs +++ b/turbopack/crates/turbopack-css/src/asset.rs @@ -238,7 +238,10 @@ impl CssChunkItem for CssModuleChunkItem { if let Some(css_item) = Vc::try_resolve_downcast::>(item).await? { - imports.push(CssImport::Internal(import_ref, css_item)); + imports.push(CssImport::Internal( + import_ref.to_resolved().await?, + css_item, + )); } } } @@ -260,7 +263,7 @@ impl CssChunkItem for CssModuleChunkItem { if let Some(css_item) = Vc::try_resolve_downcast::>(item).await? { - imports.push(CssImport::Composes(css_item)); + imports.push(CssImport::Composes(css_item.to_resolved().await?)); } } } diff --git a/turbopack/crates/turbopack-css/src/chunk/mod.rs b/turbopack/crates/turbopack-css/src/chunk/mod.rs index 9abf43210b9f1..5087e77d5f56e 100644 --- a/turbopack/crates/turbopack-css/src/chunk/mod.rs +++ b/turbopack/crates/turbopack-css/src/chunk/mod.rs @@ -4,7 +4,9 @@ pub mod source_map; use std::fmt::Write; use anyhow::{bail, Result}; -use turbo_tasks::{FxIndexSet, RcStr, TryJoinIterExt, Value, ValueDefault, ValueToString, Vc}; +use turbo_tasks::{ + FxIndexSet, RcStr, ResolvedVc, TryJoinIterExt, Value, ValueDefault, ValueToString, Vc, +}; use turbo_tasks_fs::{rope::Rope, File, FileSystem}; use turbopack_core::{ asset::{Asset, AssetContent}, @@ -350,8 +352,8 @@ pub trait CssChunkPlaceable: ChunkableModule + Module + Asset {} #[turbo_tasks::value(shared)] pub enum CssImport { External(Vc), - Internal(Vc, Vc>), - Composes(Vc>), + Internal(ResolvedVc, Vc>), + Composes(ResolvedVc>), } #[derive(Debug)] diff --git a/turbopack/crates/turbopack-css/src/references/url.rs b/turbopack/crates/turbopack-css/src/references/url.rs index 1448aa693458a..94591797322be 100644 --- a/turbopack/crates/turbopack-css/src/references/url.rs +++ b/turbopack/crates/turbopack-css/src/references/url.rs @@ -10,7 +10,7 @@ use swc_core::css::{ ast::UrlValue, visit::{VisitMut, VisitMutWith}, }; -use turbo_tasks::{debug::ValueDebug, RcStr, Value, ValueToString, Vc}; +use turbo_tasks::{debug::ValueDebug, RcStr, ResolvedVc, Value, ValueToString, Vc}; use turbopack_core::{ chunk::{ ChunkableModule, ChunkableModuleReference, ChunkingContext, ChunkingType, @@ -28,7 +28,7 @@ use crate::{embed::CssEmbed, StyleSheetLike}; #[turbo_tasks::value(into = "new")] pub enum ReferencedAsset { - Some(Vc>), + Some(ResolvedVc>), None, } @@ -68,7 +68,10 @@ impl UrlAssetReference { if let Some(embeddable) = Vc::try_resolve_downcast::>(chunk_item).await? { - return Ok(ReferencedAsset::Some(embeddable.embedded_asset()).into()); + return Ok(ReferencedAsset::Some( + embeddable.embedded_asset().to_resolved().await?, + ) + .into()); } } bail!( diff --git a/turbopack/crates/turbopack-dev-server/src/source/asset_graph.rs b/turbopack/crates/turbopack-dev-server/src/source/asset_graph.rs index cb6afbf7e259a..05ac567d7e614 100644 --- a/turbopack/crates/turbopack-dev-server/src/source/asset_graph.rs +++ b/turbopack/crates/turbopack-dev-server/src/source/asset_graph.rs @@ -5,8 +5,8 @@ use std::{ use anyhow::Result; use turbo_tasks::{ - fxindexset, Completion, FxIndexMap, FxIndexSet, RcStr, State, TryJoinIterExt, Value, - ValueToString, Vc, + fxindexset, Completion, FxIndexMap, FxIndexSet, RcStr, ResolvedVc, State, TryJoinIterExt, + Value, ValueToString, Vc, }; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ @@ -338,7 +338,10 @@ impl Introspectable for AssetGraphContentSource { Ok(Vc::cell( root_asset_children .chain(expanded_asset_children) - .chain(once((expanded_key, Vc::upcast(FullyExpaned(self).cell())))) + .chain(once(( + expanded_key, + Vc::upcast(FullyExpaned(self.to_resolved().await?).cell()), + ))) .collect(), )) } @@ -350,7 +353,7 @@ fn fully_expaned_introspectable_type() -> Vc { } #[turbo_tasks::value] -struct FullyExpaned(Vc); +struct FullyExpaned(ResolvedVc); #[turbo_tasks::value_impl] impl Introspectable for FullyExpaned { diff --git a/turbopack/crates/turbopack-dev-server/src/source/mod.rs b/turbopack/crates/turbopack-dev-server/src/source/mod.rs index 6531bcc6671fa..1e799bb3ef7af 100644 --- a/turbopack/crates/turbopack-dev-server/src/source/mod.rs +++ b/turbopack/crates/turbopack-dev-server/src/source/mod.rs @@ -89,9 +89,9 @@ pub struct StaticContent { /// The content of a result that is returned by a content source. pub enum ContentSourceContent { NotFound, - Static(Vc), - HttpProxy(Vc), - Rewrite(Vc), + Static(ResolvedVc), + HttpProxy(ResolvedVc), + Rewrite(ResolvedVc), /// Continue with the next route Next, } @@ -119,31 +119,33 @@ impl GetContentSourceContent for ContentSourceContent { #[turbo_tasks::value_impl] impl ContentSourceContent { #[turbo_tasks::function] - pub fn static_content(content: Vc>) -> Vc { + pub fn static_content( + content: ResolvedVc>, + ) -> Vc { ContentSourceContent::Static( StaticContent { - content, + content: *content, status_code: 200, headers: HeaderList::empty(), } - .cell(), + .resolved_cell(), ) .cell() } #[turbo_tasks::function] pub fn static_with_headers( - content: Vc>, + content: ResolvedVc>, status_code: u16, - headers: Vc, + headers: ResolvedVc, ) -> Vc { ContentSourceContent::Static( StaticContent { - content, + content: *content, status_code, - headers, + headers: *headers, } - .cell(), + .resolved_cell(), ) .cell() } diff --git a/turbopack/crates/turbopack-dev-server/src/source/resolve.rs b/turbopack/crates/turbopack-dev-server/src/source/resolve.rs index 8b56aa7c6c4e0..0db0873fbbed0 100644 --- a/turbopack/crates/turbopack-dev-server/src/source/resolve.rs +++ b/turbopack/crates/turbopack-dev-server/src/source/resolve.rs @@ -8,7 +8,7 @@ use hyper::{ header::{HeaderName as HyperHeaderName, HeaderValue as HyperHeaderValue}, Uri, }; -use turbo_tasks::{RcStr, TransientInstance, Value, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, TransientInstance, Value, Vc}; use super::{ headers::{HeaderValue, Headers}, @@ -24,7 +24,7 @@ use super::{ #[turbo_tasks::value(serialization = "none")] pub enum ResolveSourceRequestResult { NotFound, - Static(Vc, Vc), + Static(Vc, ResolvedVc), HttpProxy(Vc), } @@ -107,13 +107,15 @@ pub async fn resolve_source_request( } ContentSourceContent::Static(static_content) => { return Ok(ResolveSourceRequestResult::Static( - *static_content, - HeaderList::new(response_header_overwrites), + **static_content, + HeaderList::new(response_header_overwrites) + .to_resolved() + .await?, ) .cell()); } ContentSourceContent::HttpProxy(proxy_result) => { - return Ok(ResolveSourceRequestResult::HttpProxy(*proxy_result).cell()); + return Ok(ResolveSourceRequestResult::HttpProxy(**proxy_result).cell()); } ContentSourceContent::Next => continue, } diff --git a/turbopack/crates/turbopack-dev-server/src/source/wrapping_source.rs b/turbopack/crates/turbopack-dev-server/src/source/wrapping_source.rs index 235c9c2ce0ed3..d0e906d5fc5a8 100644 --- a/turbopack/crates/turbopack-dev-server/src/source/wrapping_source.rs +++ b/turbopack/crates/turbopack-dev-server/src/source/wrapping_source.rs @@ -79,7 +79,7 @@ impl GetContentSourceContent for WrappedGetContentSourceContent { response_headers: rewrite.response_headers, request_headers: rewrite.request_headers, } - .cell(), + .resolved_cell(), ) .cell()); } diff --git a/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs b/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs index 9fe28b18cceb8..8d33649349e30 100644 --- a/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs +++ b/turbopack/crates/turbopack-ecmascript/src/chunk/placeable.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::{TryFlatJoinIterExt, Vc}; +use turbo_tasks::{ResolvedVc, TryFlatJoinIterExt, Vc}; use turbo_tasks_fs::{glob::Glob, FileJsonContent, FileSystemPath}; use turbopack_core::{ asset::Asset, @@ -33,7 +33,7 @@ pub trait EcmascriptChunkPlaceable: ChunkableModule + Module + Asset { enum SideEffectsValue { None, Constant(bool), - Glob(Vc), + Glob(ResolvedVc), } #[turbo_tasks::function] @@ -100,7 +100,7 @@ async fn side_effects_from_package_json( .try_flat_join() .await?; return Ok( - SideEffectsValue::Glob(Glob::alternatives(globs).resolve().await?).cell(), + SideEffectsValue::Glob(Glob::alternatives(globs).to_resolved().await?).cell(), ); } else { SideEffectsInPackageJsonIssue { @@ -190,7 +190,7 @@ pub async fn is_marked_as_side_effect_free( #[turbo_tasks::value(shared)] pub enum EcmascriptExports { - EsmExports(Vc), + EsmExports(ResolvedVc), DynamicNamespace, CommonJs, EmptyCommonJs, 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 7a2d3be26e048..a04089fea5a88 100644 --- a/turbopack/crates/turbopack-ecmascript/src/global_module_id_strategy.rs +++ b/turbopack/crates/turbopack-ecmascript/src/global_module_id_strategy.rs @@ -1,7 +1,7 @@ use anyhow::Result; use turbo_tasks::{ graph::{AdjacencyMap, GraphTraversal}, - FxIndexMap, FxIndexSet, RcStr, TryJoinIterExt, ValueToString, Vc, + FxIndexMap, FxIndexSet, RcStr, ResolvedVc, TryJoinIterExt, ValueToString, Vc, }; use turbo_tasks_hash::hash_xxh3_hash64; use turbopack_core::{ @@ -24,14 +24,14 @@ pub struct PreprocessedChildrenIdents { #[turbo_tasks::value(shared)] pub enum ReferencedModule { Module(Vc>), - AsyncLoaderModule(Vc>), + AsyncLoaderModule(ResolvedVc>), } impl ReferencedModule { fn module(&self) -> Vc> { match *self { ReferencedModule::Module(module) => module, - ReferencedModule::AsyncLoaderModule(module) => module, + ReferencedModule::AsyncLoaderModule(module) => *module, } } } @@ -89,7 +89,10 @@ async fn referenced_modules(module: Vc>) -> Result, options: Vc, compile_time_info: Vc, - inner_assets: Option>, + inner_assets: Option>, } impl EcmascriptModuleAssetBuilder { - pub fn with_inner_assets(mut self, inner_assets: Vc) -> Self { + pub fn with_inner_assets(mut self, inner_assets: ResolvedVc) -> Self { self.inner_assets = Some(inner_assets); self } @@ -219,7 +219,7 @@ impl EcmascriptModuleAssetBuilder { self.transforms, self.options, self.compile_time_info, - inner_assets, + *inner_assets, ) } else { EcmascriptModuleAsset::new( @@ -296,7 +296,7 @@ impl EcmascriptModuleAsset { #[derive(Copy, Clone)] pub(crate) struct ModuleTypeResult { pub module_type: SpecifiedModuleType, - pub referenced_package_json: Option>, + pub referenced_package_json: Option>, } #[turbo_tasks::value_impl] @@ -312,7 +312,7 @@ impl ModuleTypeResult { #[turbo_tasks::function] fn new_with_package_json( module_type: SpecifiedModuleType, - package_json: Vc, + package_json: ResolvedVc, ) -> Vc { Self::cell(ModuleTypeResult { module_type, @@ -526,7 +526,7 @@ impl Module for EcmascriptModuleAsset { ident.add_asset(Vc::cell(name.to_string().into()), asset.ident()); } ident.add_modifier(modifier()); - ident.layer = Some(self.asset_context.layer()); + ident.layer = Some(self.asset_context.layer().to_resolved().await?); Ok(AssetIdent::new(Value::new(ident))) } else { Ok(self diff --git a/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs b/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs index b917c057fe709..b41a16c8b904b 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/esm/base.rs @@ -5,7 +5,7 @@ use swc_core::{ ecma::ast::{Decl, Expr, ExprStmt, Ident, Stmt}, quote, }; -use turbo_tasks::{RcStr, Value, ValueToString, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, Value, ValueToString, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ chunk::{ @@ -40,7 +40,7 @@ use crate::{ #[turbo_tasks::value] pub enum ReferencedAsset { - Some(Vc>), + Some(ResolvedVc>), External(RcStr, ExternalType), None, Unresolvable, @@ -87,7 +87,7 @@ impl ReferencedAsset { Vc::try_resolve_downcast::>(module) .await? { - return Ok(ReferencedAsset::Some(placeable).cell()); + return Ok(ReferencedAsset::Some(placeable.to_resolved().await?).cell()); } } // TODO ignore should probably be handled differently @@ -105,7 +105,7 @@ pub struct EsmAssetReference { pub request: Vc, pub annotations: ImportAnnotations, pub issue_source: Vc, - pub export_name: Option>, + pub export_name: Option>, pub import_externals: bool, } @@ -127,7 +127,7 @@ impl EsmAssetReference { request: Vc, issue_source: Vc, annotations: Value, - export_name: Option>, + export_name: Option>, import_externals: bool, ) -> Vc { Self::cell(EsmAssetReference { @@ -153,7 +153,7 @@ impl ModuleReference for EsmAssetReference { let ty = if matches!(self.annotations.module_type(), Some("json")) { EcmaScriptModulesReferenceSubType::ImportWithType(ImportWithType::Json) } else if let Some(part) = &self.export_name { - EcmaScriptModulesReferenceSubType::ImportPart(*part) + EcmaScriptModulesReferenceSubType::ImportPart(**part) } else { EcmaScriptModulesReferenceSubType::Import }; @@ -167,7 +167,7 @@ impl ModuleReference for EsmAssetReference { .expect("EsmAssetReference origin should be a EcmascriptModuleAsset"); return Ok(ModuleResolveResult::module( - EcmascriptModulePartAsset::select_part(module, part), + EcmascriptModulePartAsset::select_part(module, *part), ) .cell()); } @@ -192,7 +192,7 @@ impl ModuleReference for EsmAssetReference { let export = export_name.await?; if *is_export_missing(module, export.clone_value()).await? { InvalidExport { - export: export_name, + export: *export_name, module, source: self.issue_source, } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/esm/export.rs b/turbopack/crates/turbopack-ecmascript/src/references/esm/export.rs index 498bdb1a04358..62862f5a329d2 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/esm/export.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/esm/export.rs @@ -218,12 +218,12 @@ async fn handle_declared_export( .await? { return Ok(ControlFlow::Break(FollowExportsResult { - module, + module: *module, export_name: Some(name.clone()), ty: FoundExportType::SideEffects, })); } - return Ok(ControlFlow::Continue((module, name.clone()))); + return Ok(ControlFlow::Continue((*module, name.clone()))); } } EsmExport::ImportedNamespace(reference) => { @@ -231,7 +231,7 @@ async fn handle_declared_export( *ReferencedAsset::from_resolve_result(reference.resolve_reference()).await? { return Ok(ControlFlow::Break(FollowExportsResult { - module: m, + module: *m, export_name: None, ty: FoundExportType::Found, })); @@ -290,7 +290,7 @@ async fn get_all_export_names( if let ReferencedAsset::Some(m) = *ReferencedAsset::from_resolve_result(esm_ref.resolve_reference()).await? { - Some(get_all_export_names(m)) + Some(get_all_export_names(*m)) } else { None }, @@ -341,8 +341,8 @@ pub async fn expand_star_exports( if let ReferencedAsset::Some(asset) = &*ReferencedAsset::from_resolve_result(esm_ref.resolve_reference()).await? { - if checked_modules.insert(*asset) { - queue.push((*asset, asset.get_exports())); + if checked_modules.insert(**asset) { + queue.push((**asset, asset.get_exports())); } } } @@ -444,7 +444,7 @@ impl EsmExports { continue; }; - let export_info = expand_star_exports(*asset).await?; + let export_info = expand_star_exports(**asset).await?; for export in &export_info.star_exports { if !exports.contains_key(export) { @@ -456,7 +456,7 @@ impl EsmExports { } if export_info.has_dynamic_exports { - dynamic_exports.push(*asset); + dynamic_exports.push(**asset); } } diff --git a/turbopack/crates/turbopack-ecmascript/src/references/mod.rs b/turbopack/crates/turbopack-ecmascript/src/references/mod.rs index 91f6d931e367a..7c8ceeae06176 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/mod.rs @@ -50,7 +50,9 @@ use swc_core::{ }, }; use tracing::Instrument; -use turbo_tasks::{FxIndexSet, RcStr, TryJoinIterExt, Upcast, Value, ValueToString, Vc}; +use turbo_tasks::{ + FxIndexSet, RcStr, ResolvedVc, TryJoinIterExt, Upcast, Value, ValueToString, Vc, +}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ compile_time_info::{ @@ -168,7 +170,7 @@ pub struct AnalyzeEcmascriptModuleResultBuilder { exports: EcmascriptExports, async_module: Vc, successful: bool, - source_map: Option>, + source_map: Option>, bindings: Vec, } @@ -253,7 +255,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { } /// Sets the analysis result ES export. - pub fn set_source_map(&mut self, source_map: Vc) { + pub fn set_source_map(&mut self, source_map: ResolvedVc) { self.source_map = Some(source_map); } @@ -324,7 +326,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { let source_map = if let Some(source_map) = self.source_map { source_map } else { - OptionSourceMap::none() + OptionSourceMap::none().to_resolved().await? }; Ok(AnalyzeEcmascriptModuleResult::cell( AnalyzeEcmascriptModuleResult { @@ -336,7 +338,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { exports: self.exports.into(), async_module: self.async_module, successful: self.successful, - source_map, + source_map: *source_map, }, )) } @@ -458,7 +460,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( } = *module.determine_module_type().await?; if let Some(package_json) = referenced_package_json { - analysis.add_reference(PackageJsonReference::new(package_json)); + analysis.add_reference(PackageJsonReference::new(*package_json)); } if analyze_types { @@ -546,18 +548,20 @@ 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, - )); + analysis.set_source_map( + convert_to_turbopack_source_map(source_map, source_map_origin) + .to_resolved() + .await?, + ); 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, - )); + analysis.set_source_map( + convert_to_turbopack_source_map(source_map, source_map_origin) + .to_resolved() + .await?, + ); source_map_from_comment = true; } } @@ -566,10 +570,14 @@ pub(crate) async fn analyse_ecmascript_module_internal( Vc::try_resolve_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, - )); + analysis.set_source_map( + convert_to_turbopack_source_map( + generate_source_map.generate_source_map(), + source_map_origin, + ) + .to_resolved() + .await?, + ); } } @@ -761,7 +769,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( } .cell(); - EcmascriptExports::EsmExports(esm_exports) + EcmascriptExports::EsmExports(esm_exports.to_resolved().await?) } else if specified_type == SpecifiedModuleType::EcmaScript { match detect_dynamic_export(program) { DetectedDynamicExportType::CommonJs => { @@ -777,7 +785,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( exports: Default::default(), star_exports: Default::default(), } - .cell(), + .resolved_cell(), ) } DetectedDynamicExportType::Namespace => EcmascriptExports::DynamicNamespace, @@ -788,7 +796,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( exports: Default::default(), star_exports: Default::default(), } - .cell(), + .resolved_cell(), ), } } else { @@ -801,7 +809,7 @@ pub(crate) async fn analyse_ecmascript_module_internal( exports: Default::default(), star_exports: Default::default(), } - .cell(), + .resolved_cell(), ), DetectedDynamicExportType::None => EcmascriptExports::EmptyCommonJs, } @@ -2191,7 +2199,7 @@ async fn handle_free_var_reference( lookup_path.map_or(state.origin, |lookup_path| { Vc::upcast(PlainResolveOrigin::new( state.origin.asset_context(), - lookup_path, + *lookup_path, )) }), Request::parse(Value::new(request.clone().into())), 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 8dcec1e902f94..8fbfcea8b550a 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 @@ -255,7 +255,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule { star_exports, } .cell(); - Ok(EcmascriptExports::EsmExports(exports).cell()) + Ok(EcmascriptExports::EsmExports(exports.to_resolved().await?).cell()) } #[turbo_tasks::function] 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 167108ff51e37..90faab22b121d 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 @@ -94,7 +94,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleLocalsModule { star_exports: vec![], } .cell(); - Ok(EcmascriptExports::EsmExports(exports).cell()) + Ok(EcmascriptExports::EsmExports(exports.to_resolved().await?).cell()) } #[turbo_tasks::function] diff --git a/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/reference.rs b/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/reference.rs index ebb64fedf2d6d..fd07f2d0cefb6 100644 --- a/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/reference.rs +++ b/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/reference.rs @@ -1,6 +1,6 @@ use anyhow::{bail, Context, Result}; use swc_core::{common::DUMMY_SP, ecma::ast::Ident, quote}; -use turbo_tasks::{RcStr, ValueToString, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, ValueToString, Vc}; use turbopack_core::{ chunk::{ ChunkItemExt, ChunkableModule, ChunkableModuleReference, ChunkingContext, ChunkingType, @@ -25,7 +25,7 @@ use crate::{ #[turbo_tasks::value] pub struct EcmascriptModulePartReference { pub module: Vc>, - pub part: Option>, + pub part: Option>, } #[turbo_tasks::value_impl] @@ -33,7 +33,7 @@ impl EcmascriptModulePartReference { #[turbo_tasks::function] pub fn new_part( module: Vc>, - part: Vc, + part: ResolvedVc, ) -> Vc { EcmascriptModulePartReference { module, @@ -77,7 +77,7 @@ impl ModuleReference for EcmascriptModulePartReference { | ModulePart::Facade | ModulePart::RenamedExport { .. } | ModulePart::RenamedNamespace { .. } => { - Vc::upcast(EcmascriptModuleFacadeModule::new(self.module, part)) + Vc::upcast(EcmascriptModuleFacadeModule::new(self.module, *part)) } ModulePart::Export(..) | ModulePart::Internal(..) => { bail!( diff --git a/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs b/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs index 264b011bb74fe..77916db0e27e6 100644 --- a/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/transform/mod.rs @@ -18,7 +18,7 @@ use swc_core::{ }, quote, }; -use turbo_tasks::{RcStr, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ environment::Environment, @@ -30,7 +30,7 @@ use turbopack_core::{ pub enum EcmascriptInputTransform { CommonJs, Plugin(Vc), - PresetEnv(Vc), + PresetEnv(ResolvedVc), React { #[serde(default)] development: bool, diff --git a/turbopack/crates/turbopack-image/src/process/mod.rs b/turbopack/crates/turbopack-image/src/process/mod.rs index 2db40e084f459..cc1c75dc19552 100644 --- a/turbopack/crates/turbopack-image/src/process/mod.rs +++ b/turbopack/crates/turbopack-image/src/process/mod.rs @@ -17,7 +17,7 @@ use image::{ use mime::Mime; use serde::{Deserialize, Serialize}; use serde_with::{serde_as, DisplayFromStr}; -use turbo_tasks::{debug::ValueDebugFormat, trace::TraceRawVcs, Vc}; +use turbo_tasks::{debug::ValueDebugFormat, trace::TraceRawVcs, ResolvedVc, Vc}; use turbo_tasks_fs::{File, FileContent, FileSystemPath}; use turbopack_core::{ error::PrettyPrintError, @@ -170,7 +170,7 @@ fn load_image_internal( .into(), ) .cell(), - title: Some(StyledString::Text("AVIF image not supported".into()).cell()), + title: Some(StyledString::Text("AVIF image not supported".into()).resolved_cell()), issue_severity: Some(IssueSeverity::Warning.into()), } .cell() @@ -188,7 +188,7 @@ fn load_image_internal( .into(), ) .cell(), - title: Some(StyledString::Text("WEBP image not supported".into()).cell()), + title: Some(StyledString::Text("WEBP image not supported".into()).resolved_cell()), issue_severity: Some(IssueSeverity::Warning.into()), } .cell() @@ -479,7 +479,7 @@ pub async fn optimize( struct ImageProcessingIssue { path: Vc, message: Vc, - title: Option>, + title: Option>, issue_severity: Option>, } @@ -502,8 +502,9 @@ impl Issue for ImageProcessingIssue { #[turbo_tasks::function] fn title(&self) -> Vc { - self.title - .unwrap_or(StyledString::Text("Processing image failed".into()).cell()) + *self + .title + .unwrap_or(StyledString::Text("Processing image failed".into()).resolved_cell()) } #[turbo_tasks::function] diff --git a/turbopack/crates/turbopack-node/src/render/node_api_source.rs b/turbopack/crates/turbopack-node/src/render/node_api_source.rs index 6ccbde5786072..697647353d42b 100644 --- a/turbopack/crates/turbopack-node/src/render/node_api_source.rs +++ b/turbopack/crates/turbopack-node/src/render/node_api_source.rs @@ -127,30 +127,34 @@ impl GetContentSourceContent for NodeApiContentSource { return Err(anyhow!("Missing request data")); }; let entry = self.entry.entry(data.clone()).await?; - Ok(ContentSourceContent::HttpProxy(render_proxy( - self.cwd, - self.env, - self.server_root.join(path.clone()), - entry.module, - entry.runtime_entries, - entry.chunking_context, - entry.intermediate_output_path, - entry.output_root, - entry.project_dir, - RenderData { - params: params.clone(), - method: method.clone(), - url: url.clone(), - original_url: original_url.clone(), - raw_query: raw_query.clone(), - raw_headers: raw_headers.clone(), - path: format!("/{}", path).into(), - data: Some(self.render_data.await?), - } - .cell(), - *body, - self.debug, - )) + Ok(ContentSourceContent::HttpProxy( + render_proxy( + self.cwd, + self.env, + self.server_root.join(path.clone()), + entry.module, + entry.runtime_entries, + entry.chunking_context, + entry.intermediate_output_path, + entry.output_root, + entry.project_dir, + RenderData { + params: params.clone(), + method: method.clone(), + url: url.clone(), + original_url: original_url.clone(), + raw_query: raw_query.clone(), + raw_headers: raw_headers.clone(), + path: format!("/{}", path).into(), + data: Some(self.render_data.await?), + } + .cell(), + *body, + self.debug, + ) + .to_resolved() + .await?, + ) .cell()) } } diff --git a/turbopack/crates/turbopack-node/src/render/render_static.rs b/turbopack/crates/turbopack-node/src/render/render_static.rs index 5835cd634a90a..a9053d1c90897 100644 --- a/turbopack/crates/turbopack-node/src/render/render_static.rs +++ b/turbopack/crates/turbopack-node/src/render/render_static.rs @@ -7,8 +7,8 @@ use futures::{ use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use turbo_tasks::{ - duration_span, mark_finished, prevent_gc, util::SharedError, RawVc, TaskInput, ValueToString, - Vc, + duration_span, mark_finished, prevent_gc, util::SharedError, RawVc, ResolvedVc, TaskInput, + ValueToString, Vc, }; use turbo_tasks_bytes::{Bytes, Stream}; use turbo_tasks_env::ProcessEnv; @@ -46,7 +46,7 @@ pub enum StaticResult { headers: Vc, body: Body, }, - Rewrite(Vc), + Rewrite(ResolvedVc), } #[turbo_tasks::value_impl] @@ -66,7 +66,7 @@ impl StaticResult { } #[turbo_tasks::function] - pub fn rewrite(rewrite: Vc) -> Vc { + pub fn rewrite(rewrite: ResolvedVc) -> Vc { StaticResult::Rewrite(rewrite).cell() } } diff --git a/turbopack/crates/turbopack-node/src/render/rendered_source.rs b/turbopack/crates/turbopack-node/src/render/rendered_source.rs index 723307454d3fd..b06a13927e356 100644 --- a/turbopack/crates/turbopack-node/src/render/rendered_source.rs +++ b/turbopack/crates/turbopack-node/src/render/rendered_source.rs @@ -236,10 +236,12 @@ impl GetContentSourceContent for NodeRenderContentSource { headers: headers.await?.clone_value(), body: body.clone(), } - .cell(), + .resolved_cell(), ) .cell(), - StaticResult::Rewrite(rewrite) => ContentSourceContent::Rewrite(rewrite).cell(), + StaticResult::Rewrite(rewrite) => { + ContentSourceContent::Rewrite(rewrite.to_resolved().await?).cell() + } }) } } diff --git a/turbopack/crates/turbopack-node/src/transforms/webpack.rs b/turbopack/crates/turbopack-node/src/transforms/webpack.rs index a3cfdc29afb97..3e3e829d1f6db 100644 --- a/turbopack/crates/turbopack-node/src/transforms/webpack.rs +++ b/turbopack/crates/turbopack-node/src/transforms/webpack.rs @@ -7,7 +7,8 @@ use serde::{Deserialize, Serialize}; use serde_json::{json, Value as JsonValue}; use serde_with::serde_as; use turbo_tasks::{ - trace::TraceRawVcs, Completion, RcStr, TaskInput, TryJoinIterExt, Value, ValueToString, Vc, + trace::TraceRawVcs, Completion, RcStr, ResolvedVc, TaskInput, TryJoinIterExt, Value, + ValueToString, Vc, }; use turbo_tasks_bytes::stream::SingleValue; use turbo_tasks_env::ProcessEnv; @@ -229,7 +230,7 @@ impl WebpackLoadersProcessedAsset { context_ident_for_issue: this.source.ident(), asset_context: evaluate_context, chunking_context, - resolve_options_context: Some(transform.resolve_options_context), + resolve_options_context: Some(transform.resolve_options_context.to_resolved().await?), args: vec![ Vc::cell(content.into()), // We need to pass the query string to the loader @@ -380,7 +381,7 @@ pub struct WebpackLoaderContext { pub context_ident_for_issue: Vc, pub asset_context: Vc>, pub chunking_context: Vc>, - pub resolve_options_context: Option>, + pub resolve_options_context: Option>, pub args: Vec>, pub additional_invalidation: Vc, } @@ -498,7 +499,7 @@ impl EvaluateContext for WebpackLoaderContext { }; let lookup_path = self.cwd.join(lookup_path); let request = Request::parse(Value::new(Pattern::Constant(request))); - let options = resolve_options(lookup_path, resolve_options_context); + let options = resolve_options(lookup_path, *resolve_options_context); let options = apply_webpack_resolve_options(options, webpack_options); diff --git a/turbopack/crates/turbopack-resolve/src/ecmascript.rs b/turbopack/crates/turbopack-resolve/src/ecmascript.rs index d33bfc6180e20..141a16b1c71a1 100644 --- a/turbopack/crates/turbopack-resolve/src/ecmascript.rs +++ b/turbopack/crates/turbopack-resolve/src/ecmascript.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::{Value, Vc}; +use turbo_tasks::{ResolvedVc, Value, Vc}; use turbopack_core::{ issue::IssueSource, reference_type::{CommonJsReferenceSubType, EcmaScriptModulesReferenceSubType, ReferenceType}, @@ -80,7 +80,7 @@ pub async fn esm_resolve( request: Vc, ty: Value, is_optional: bool, - issue_source: Option>, + issue_source: Option>, ) -> Result> { let ty = Value::new(ReferenceType::EcmaScriptModules(ty.into_value())); let options = apply_esm_specific_options(origin.resolve_options(ty.clone()), ty.clone()) @@ -93,7 +93,7 @@ pub async fn esm_resolve( pub async fn cjs_resolve( origin: Vc>, request: Vc, - issue_source: Option>, + issue_source: Option>, is_optional: bool, ) -> Result> { // TODO pass CommonJsReferenceSubType @@ -106,9 +106,9 @@ pub async fn cjs_resolve( #[turbo_tasks::function] pub async fn cjs_resolve_source( - origin: Vc>, - request: Vc, - issue_source: Option>, + origin: ResolvedVc>, + request: ResolvedVc, + issue_source: Option>, is_optional: bool, ) -> Result> { // TODO pass CommonJsReferenceSubType @@ -119,7 +119,7 @@ pub async fn cjs_resolve_source( let result = resolve( origin.origin_path().parent().resolve().await?, ty.clone(), - request, + *request, options, ); @@ -127,7 +127,7 @@ pub async fn cjs_resolve_source( result, ty, origin.origin_path(), - request, + *request, options, is_optional, issue_source, @@ -141,7 +141,7 @@ async fn specific_resolve( options: Vc, reference_type: Value, is_optional: bool, - issue_source: Option>, + issue_source: Option>, ) -> Result> { let result = origin.resolve_asset(request, options, reference_type.clone()); diff --git a/turbopack/crates/turbopack-resolve/src/resolve.rs b/turbopack/crates/turbopack-resolve/src/resolve.rs index 6056066bd0192..bc80594cab50d 100644 --- a/turbopack/crates/turbopack-resolve/src/resolve.rs +++ b/turbopack/crates/turbopack-resolve/src/resolve.rs @@ -213,14 +213,20 @@ async fn base_resolve_options( extensions, modules: if let Some(environment) = emulating { if *environment.resolve_node_modules().await? { - vec![ResolveModules::Nested(root, vec!["node_modules".into()])] + vec![ResolveModules::Nested( + root.to_resolved().await?, + vec!["node_modules".into()], + )] } else { Vec::new() } } else { let mut mods = Vec::new(); if let Some(dir) = opt.enable_node_modules { - mods.push(ResolveModules::Nested(dir, vec!["node_modules".into()])); + mods.push(ResolveModules::Nested( + dir.to_resolved().await?, + vec!["node_modules".into()], + )); } mods }, diff --git a/turbopack/crates/turbopack-tests/tests/execution.rs b/turbopack/crates/turbopack-tests/tests/execution.rs index 43ce9db5ecd9d..d31ed600227bc 100644 --- a/turbopack/crates/turbopack-tests/tests/execution.rs +++ b/turbopack/crates/turbopack-tests/tests/execution.rs @@ -286,7 +286,7 @@ async fn run_test(prepared_test: Vc) -> Result> import_externals: true, ..Default::default() }, - preset_env_versions: Some(env), + preset_env_versions: Some(env.to_resolved().await?), tree_shaking_mode: options.tree_shaking_mode, rules: vec![( ContextCondition::InDirectory("node_modules".into()), diff --git a/turbopack/crates/turbopack-tests/tests/snapshot.rs b/turbopack/crates/turbopack-tests/tests/snapshot.rs index 50ba83a7f424e..c11ab223ac29b 100644 --- a/turbopack/crates/turbopack-tests/tests/snapshot.rs +++ b/turbopack/crates/turbopack-tests/tests/snapshot.rs @@ -278,7 +278,7 @@ async fn run_test(resource: RcStr) -> Result> { use_swc_css: options.use_swc_css, ..Default::default() }, - preset_env_versions: Some(env), + preset_env_versions: Some(env.to_resolved().await?), rules: vec![( ContextCondition::InDirectory("node_modules".into()), ModuleOptionsContext { diff --git a/turbopack/crates/turbopack/src/graph/mod.rs b/turbopack/crates/turbopack/src/graph/mod.rs index 2e2d37535db0d..a096cb0f8a024 100644 --- a/turbopack/crates/turbopack/src/graph/mod.rs +++ b/turbopack/crates/turbopack/src/graph/mod.rs @@ -1,12 +1,12 @@ use std::collections::HashSet; use anyhow::Result; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack_core::output::OutputAsset; #[turbo_tasks::value(shared)] pub enum AggregatedGraph { - Leaf(Vc>), + Leaf(ResolvedVc>), Node { depth: usize, content: HashSet>, @@ -17,7 +17,7 @@ pub enum AggregatedGraph { #[turbo_tasks::value_impl] impl AggregatedGraph { #[turbo_tasks::function] - fn leaf(asset: Vc>) -> Vc { + fn leaf(asset: ResolvedVc>) -> Vc { Self::cell(AggregatedGraph::Leaf(asset)) } } @@ -36,7 +36,7 @@ impl AggregatedGraph { #[turbo_tasks::function] pub async fn content(self: Vc) -> Result> { Ok(match *self.await? { - AggregatedGraph::Leaf(asset) => AggregatedGraphNodeContent::Asset(asset).into(), + AggregatedGraph::Leaf(asset) => AggregatedGraphNodeContent::Asset(*asset).into(), AggregatedGraph::Node { ref content, .. } => { AggregatedGraphNodeContent::Children(content.clone()).into() } @@ -50,7 +50,7 @@ impl AggregatedGraph { let mut refs = HashSet::new(); for reference in asset.references().await?.iter() { let reference = reference.resolve().await?; - if asset != reference { + if asset != reference.to_resolved().await? { refs.insert(AggregatedGraph::leaf(reference)); } } diff --git a/turbopack/crates/turbopack/src/lib.rs b/turbopack/crates/turbopack/src/lib.rs index 0c015f84df556..3dc82e7e63aa1 100644 --- a/turbopack/crates/turbopack/src/lib.rs +++ b/turbopack/crates/turbopack/src/lib.rs @@ -106,7 +106,7 @@ async fn apply_module_type( module_type: Vc, reference_type: Value, part: Option>, - inner_assets: Option>, + inner_assets: Option>, runtime_code: bool, ) -> Result> { let module_type = &*module_type.await?; diff --git a/turbopack/crates/turbopack/src/module_options/mod.rs b/turbopack/crates/turbopack/src/module_options/mod.rs index cfd5753398de8..96a515ba8abd7 100644 --- a/turbopack/crates/turbopack/src/module_options/mod.rs +++ b/turbopack/crates/turbopack/src/module_options/mod.rs @@ -140,7 +140,9 @@ impl ModuleOptions { let ecmascript_options_vc = ecmascript_options.cell(); if let Some(env) = preset_env_versions { - transforms.push(EcmascriptInputTransform::PresetEnv(env)); + transforms.push(EcmascriptInputTransform::PresetEnv( + env.to_resolved().await?, + )); } if let Some(enable_typeof_window_inlining) = enable_typeof_window_inlining { @@ -418,13 +420,13 @@ impl ModuleOptions { vec![ModuleRuleEffect::SourceTransforms(Vc::cell(vec![ Vc::upcast(PostCssTransform::new( node_evaluate_asset_context( - execution_context, + *execution_context, Some(import_map), None, "postcss".into(), true, ), - execution_context, + *execution_context, options.config_location, )), ]))], @@ -562,13 +564,13 @@ impl ModuleOptions { vec![ModuleRuleEffect::SourceTransforms(Vc::cell(vec![ Vc::upcast(WebpackLoaders::new( node_evaluate_asset_context( - execution_context, + *execution_context, Some(import_map), None, "webpack_loaders".into(), false, ), - execution_context, + *execution_context, rule.loaders, rule.rename_as.clone(), resolve_options_context, diff --git a/turbopack/crates/turbopack/src/module_options/module_options_context.rs b/turbopack/crates/turbopack/src/module_options/module_options_context.rs index 7cd69e4c39eff..5c0b8436b9add 100644 --- a/turbopack/crates/turbopack/src/module_options/module_options_context.rs +++ b/turbopack/crates/turbopack/src/module_options/module_options_context.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -use turbo_tasks::{trace::TraceRawVcs, FxIndexMap, RcStr, ValueDefault, Vc}; +use turbo_tasks::{trace::TraceRawVcs, FxIndexMap, RcStr, ResolvedVc, ValueDefault, Vc}; use turbopack_core::{ chunk::MinifyType, condition::ContextCondition, environment::Environment, resolve::options::ImportMapping, @@ -119,8 +119,8 @@ pub struct ModuleOptionsContext { pub enable_mdx: bool, pub enable_mdx_rs: Option>, - pub preset_env_versions: Option>, - pub execution_context: Option>, + pub preset_env_versions: Option>, + pub execution_context: Option>, pub side_effect_free_packages: Vec, pub tree_shaking_mode: Option, @@ -142,7 +142,7 @@ pub struct EcmascriptOptionsContext { /// normal resolution. pub enable_types: bool, pub enable_typescript_transform: Option>, - pub enable_decorators: Option>, + pub enable_decorators: Option>, pub esm_url_rewrite_behavior: Option, /// References to externals from ESM imports should use `import()` and make /// async modules.