diff --git a/crates/next-core/src/next_client/context.rs b/crates/next-core/src/next_client/context.rs index 4113484a989de..5c626435a4656 100644 --- a/crates/next-core/src/next_client/context.rs +++ b/crates/next-core/src/next_client/context.rs @@ -145,13 +145,19 @@ pub async fn get_client_resolve_options_context( execution_context: Vc, ) -> Result> { let next_client_import_map = - get_next_client_import_map(project_path, ty, next_config, execution_context); - let next_client_fallback_import_map = get_next_client_fallback_import_map(ty); + get_next_client_import_map(project_path, ty, next_config, execution_context) + .to_resolved() + .await?; + let next_client_fallback_import_map = get_next_client_fallback_import_map(ty) + .to_resolved() + .await?; let next_client_resolved_map = - get_next_client_resolved_map(project_path, project_path, *mode.await?); + get_next_client_resolved_map(project_path, project_path, *mode.await?) + .to_resolved() + .await?; let custom_conditions = vec![mode.await?.condition().into()]; let module_options_context = ResolveOptionsContext { - enable_node_modules: Some(project_path.root().resolve().await?), + enable_node_modules: Some(project_path.root().to_resolved().await?), custom_conditions, import_map: Some(next_client_import_map), fallback_import_map: Some(next_client_fallback_import_map), @@ -159,13 +165,27 @@ pub async fn get_client_resolve_options_context( browser: true, module: true, before_resolve_plugins: vec![ - Vc::upcast(get_invalid_server_only_resolve_plugin(project_path)), - Vc::upcast(ModuleFeatureReportResolvePlugin::new(project_path)), - Vc::upcast(NextFontLocalResolvePlugin::new(project_path)), + ResolvedVc::upcast( + get_invalid_server_only_resolve_plugin(project_path) + .to_resolved() + .await?, + ), + ResolvedVc::upcast( + ModuleFeatureReportResolvePlugin::new(project_path) + .to_resolved() + .await?, + ), + ResolvedVc::upcast( + NextFontLocalResolvePlugin::new(project_path) + .to_resolved() + .await?, + ), ], - after_resolve_plugins: vec![Vc::upcast(NextSharedRuntimeResolvePlugin::new( - project_path, - ))], + after_resolve_plugins: vec![ResolvedVc::upcast( + NextSharedRuntimeResolvePlugin::new(project_path) + .to_resolved() + .await?, + )], ..Default::default() }; Ok(ResolveOptionsContext { @@ -175,7 +195,7 @@ pub async fn get_client_resolve_options_context( custom_extensions: next_config.resolve_extension().await?.clone_value(), rules: vec![( foreign_code_context_condition(next_config, project_path).await?, - module_options_context.clone().cell(), + module_options_context.clone().resolved_cell(), )], ..module_options_context } diff --git a/crates/next-core/src/next_edge/context.rs b/crates/next-core/src/next_edge/context.rs index e68f79b72393f..f63b10ce8d1d3 100644 --- a/crates/next-core/src/next_edge/context.rs +++ b/crates/next-core/src/next_edge/context.rs @@ -96,20 +96,28 @@ pub async fn get_edge_resolve_options_context( execution_context: Vc, ) -> Result> { let next_edge_import_map = - get_next_edge_import_map(project_path, ty, next_config, execution_context); + get_next_edge_import_map(project_path, ty, next_config, execution_context) + .to_resolved() + .await?; let ty: ServerContextType = ty.into_value(); - let mut before_resolve_plugins = vec![Vc::upcast(ModuleFeatureReportResolvePlugin::new( - project_path, - ))]; + let mut before_resolve_plugins = vec![ResolvedVc::upcast( + ModuleFeatureReportResolvePlugin::new(project_path) + .to_resolved() + .await?, + )]; if matches!( ty, ServerContextType::Pages { .. } | ServerContextType::AppSSR { .. } | ServerContextType::AppRSC { .. } ) { - before_resolve_plugins.push(Vc::upcast(NextFontLocalResolvePlugin::new(project_path))); + before_resolve_plugins.push(ResolvedVc::upcast( + NextFontLocalResolvePlugin::new(project_path) + .to_resolved() + .await?, + )); }; if matches!( @@ -120,17 +128,23 @@ pub async fn get_edge_resolve_options_context( | ServerContextType::Middleware { .. } | ServerContextType::Instrumentation { .. } ) { - before_resolve_plugins.push(Vc::upcast(get_invalid_client_only_resolve_plugin( - project_path, - ))); - before_resolve_plugins.push(Vc::upcast(get_invalid_styled_jsx_resolve_plugin( - project_path, - ))); + before_resolve_plugins.push(ResolvedVc::upcast( + get_invalid_client_only_resolve_plugin(project_path) + .to_resolved() + .await?, + )); + before_resolve_plugins.push(ResolvedVc::upcast( + get_invalid_styled_jsx_resolve_plugin(project_path) + .to_resolved() + .await?, + )); } - let after_resolve_plugins = vec![Vc::upcast(NextSharedRuntimeResolvePlugin::new( - project_path, - ))]; + let after_resolve_plugins = vec![ResolvedVc::upcast( + NextSharedRuntimeResolvePlugin::new(project_path) + .to_resolved() + .await?, + )]; // https://github.com/vercel/next.js/blob/bf52c254973d99fed9d71507a2e818af80b8ade7/packages/next/src/build/webpack-config.ts#L96-L102 let mut custom_conditions = vec![mode.await?.condition().into()]; @@ -147,7 +161,7 @@ pub async fn get_edge_resolve_options_context( }; let resolve_options_context = ResolveOptionsContext { - enable_node_modules: Some(project_path.root().resolve().await?), + enable_node_modules: Some(project_path.root().to_resolved().await?), enable_edge_node_externals: true, custom_conditions, import_map: Some(next_edge_import_map), @@ -166,7 +180,7 @@ pub async fn get_edge_resolve_options_context( custom_extensions: next_config.resolve_extension().await?.clone_value(), rules: vec![( foreign_code_context_condition(next_config, project_path).await?, - resolve_options_context.clone().cell(), + resolve_options_context.clone().resolved_cell(), )], ..resolve_options_context } diff --git a/crates/next-core/src/next_server/context.rs b/crates/next-core/src/next_server/context.rs index c0fb49b2aa6fd..c355f33b69687 100644 --- a/crates/next-core/src/next_server/context.rs +++ b/crates/next-core/src/next_server/context.rs @@ -128,14 +128,22 @@ pub async fn get_server_resolve_options_context( execution_context: Vc, ) -> Result> { let next_server_import_map = - get_next_server_import_map(project_path, ty, next_config, execution_context); + get_next_server_import_map(project_path, ty, next_config, execution_context) + .to_resolved() + .await?; let foreign_code_context_condition = foreign_code_context_condition(next_config, project_path).await?; - let root_dir = project_path.root().resolve().await?; - let module_feature_report_resolve_plugin = ModuleFeatureReportResolvePlugin::new(project_path); - let invalid_client_only_resolve_plugin = get_invalid_client_only_resolve_plugin(project_path); + let root_dir = project_path.root().to_resolved().await?; + let module_feature_report_resolve_plugin = ModuleFeatureReportResolvePlugin::new(project_path) + .to_resolved() + .await?; + let invalid_client_only_resolve_plugin = get_invalid_client_only_resolve_plugin(project_path) + .to_resolved() + .await?; let invalid_styled_jsx_client_only_resolve_plugin = - get_invalid_styled_jsx_resolve_plugin(project_path); + get_invalid_styled_jsx_resolve_plugin(project_path) + .to_resolved() + .await?; // Always load these predefined packages as external. let mut external_packages: Vec = load_next_js_templateon( @@ -181,7 +189,9 @@ pub async fn get_server_resolve_options_context( project_path.root(), ExternalPredicate::Only(ResolvedVc::cell(external_packages)).cell(), *next_config.import_externals().await?, - ); + ) + .to_resolved() + .await?; let mut custom_conditions = vec![mode.await?.condition().to_string().into()]; custom_conditions.extend( @@ -205,19 +215,29 @@ pub async fn get_server_resolve_options_context( ExternalPredicate::AllExcept(ResolvedVc::cell(transpiled_packages)).cell(), *next_config.import_externals().await?, ) + .to_resolved() + .await? }; - let next_external_plugin = NextExternalResolvePlugin::new(project_path); + let next_external_plugin = NextExternalResolvePlugin::new(project_path) + .to_resolved() + .await?; let next_node_shared_runtime_plugin = - NextNodeSharedRuntimeResolvePlugin::new(project_path, Value::new(ty)); + NextNodeSharedRuntimeResolvePlugin::new(project_path, Value::new(ty)) + .to_resolved() + .await?; let mut before_resolve_plugins = match ty { ServerContextType::Pages { .. } | ServerContextType::AppSSR { .. } | ServerContextType::AppRSC { .. } => { vec![ - Vc::upcast(NextFontLocalResolvePlugin::new(project_path)), - Vc::upcast(module_feature_report_resolve_plugin), + ResolvedVc::upcast( + NextFontLocalResolvePlugin::new(project_path) + .to_resolved() + .await?, + ), + ResolvedVc::upcast(module_feature_report_resolve_plugin), ] } ServerContextType::PagesData { .. } @@ -225,7 +245,7 @@ pub async fn get_server_resolve_options_context( | ServerContextType::AppRoute { .. } | ServerContextType::Middleware { .. } | ServerContextType::Instrumentation { .. } => { - vec![Vc::upcast(module_feature_report_resolve_plugin)] + vec![ResolvedVc::upcast(module_feature_report_resolve_plugin)] } }; @@ -234,28 +254,28 @@ pub async fn get_server_resolve_options_context( | ServerContextType::PagesApi { .. } | ServerContextType::PagesData { .. } => { vec![ - Vc::upcast(next_node_shared_runtime_plugin), - Vc::upcast(external_cjs_modules_plugin), - Vc::upcast(next_external_plugin), + ResolvedVc::upcast(next_node_shared_runtime_plugin), + ResolvedVc::upcast(external_cjs_modules_plugin), + ResolvedVc::upcast(next_external_plugin), ] } ServerContextType::AppSSR { .. } | ServerContextType::AppRSC { .. } | ServerContextType::AppRoute { .. } => { vec![ - Vc::upcast(next_node_shared_runtime_plugin), - Vc::upcast(server_external_packages_plugin), - Vc::upcast(next_external_plugin), + ResolvedVc::upcast(next_node_shared_runtime_plugin), + ResolvedVc::upcast(server_external_packages_plugin), + ResolvedVc::upcast(next_external_plugin), ] } ServerContextType::Middleware { .. } => { - vec![Vc::upcast(next_node_shared_runtime_plugin)] + vec![ResolvedVc::upcast(next_node_shared_runtime_plugin)] } ServerContextType::Instrumentation { .. } => { vec![ - Vc::upcast(next_node_shared_runtime_plugin), - Vc::upcast(server_external_packages_plugin), - Vc::upcast(next_external_plugin), + ResolvedVc::upcast(next_node_shared_runtime_plugin), + ResolvedVc::upcast(server_external_packages_plugin), + ResolvedVc::upcast(next_external_plugin), ] } }; @@ -276,8 +296,10 @@ pub async fn get_server_resolve_options_context( | ServerContextType::AppRoute { .. } | ServerContextType::Middleware { .. } | ServerContextType::Instrumentation { .. } => { - before_resolve_plugins.push(Vc::upcast(invalid_client_only_resolve_plugin)); - before_resolve_plugins.push(Vc::upcast(invalid_styled_jsx_client_only_resolve_plugin)); + before_resolve_plugins.push(ResolvedVc::upcast(invalid_client_only_resolve_plugin)); + before_resolve_plugins.push(ResolvedVc::upcast( + invalid_styled_jsx_client_only_resolve_plugin, + )); } ServerContextType::AppSSR { .. } => { //[TODO] Build error in this context makes rsc-build-error.ts fail which expects runtime error code @@ -304,7 +326,7 @@ pub async fn get_server_resolve_options_context( custom_extensions: next_config.resolve_extension().await?.clone_value(), rules: vec![( foreign_code_context_condition, - resolve_options_context.clone().cell(), + resolve_options_context.clone().resolved_cell(), )], ..resolve_options_context } diff --git a/crates/next-core/src/next_shared/transforms/swc_ecma_transform_plugins.rs b/crates/next-core/src/next_shared/transforms/swc_ecma_transform_plugins.rs index 4548ed8570020..d049f44be036c 100644 --- a/crates/next-core/src/next_shared/transforms/swc_ecma_transform_plugins.rs +++ b/crates/next-core/src/next_shared/transforms/swc_ecma_transform_plugins.rs @@ -61,7 +61,7 @@ pub async fn get_swc_ecma_transform_rule_impl( let resolve_options = resolve_options( project_path, ResolveOptionsContext { - enable_node_modules: Some(project_path.root().resolve().await?), + enable_node_modules: Some(project_path.root().to_resolved().await?), enable_node_native_modules: true, ..Default::default() } diff --git a/turbopack/crates/node-file-trace/src/lib.rs b/turbopack/crates/node-file-trace/src/lib.rs index 5f9c7832120ec..83f44464b91eb 100644 --- a/turbopack/crates/node-file-trace/src/lib.rs +++ b/turbopack/crates/node-file-trace/src/lib.rs @@ -609,7 +609,7 @@ async fn create_module_asset( ResolvedMap { by_glob: glob_mappings, } - .cell(), + .resolved_cell(), ); } diff --git a/turbopack/crates/turbopack-cli/src/contexts.rs b/turbopack/crates/turbopack-cli/src/contexts.rs index b8fc3ee26ea47..c64c8aaeb3413 100644 --- a/turbopack/crates/turbopack-cli/src/contexts.rs +++ b/turbopack/crates/turbopack-cli/src/contexts.rs @@ -74,9 +74,9 @@ pub fn get_client_import_map(project_path: Vc) -> Vc pub async fn get_client_resolve_options_context( project_path: Vc, ) -> Result> { - let next_client_import_map = get_client_import_map(project_path); + let next_client_import_map = get_client_import_map(project_path).to_resolved().await?; let module_options_context = ResolveOptionsContext { - enable_node_modules: Some(project_path.root().resolve().await?), + enable_node_modules: Some(project_path.root().to_resolved().await?), custom_conditions: vec!["development".into()], import_map: Some(next_client_import_map), browser: true, @@ -88,7 +88,7 @@ pub async fn get_client_resolve_options_context( enable_react: true, rules: vec![( foreign_code_context_condition().await?, - module_options_context.clone().cell(), + module_options_context.clone().resolved_cell(), )], ..module_options_context } diff --git a/turbopack/crates/turbopack-core/src/issue/resolve.rs b/turbopack/crates/turbopack-core/src/issue/resolve.rs index c9633312ff28f..e6f7061196935 100644 --- a/turbopack/crates/turbopack-core/src/issue/resolve.rs +++ b/turbopack/crates/turbopack-core/src/issue/resolve.rs @@ -72,7 +72,7 @@ impl Issue for ResolvingIssue { if let Some(import_map) = &self.resolve_options.await?.import_map { for request in request_parts { - match lookup_import_map(*import_map, self.file_path, *request).await { + match lookup_import_map(**import_map, self.file_path, *request).await { Ok(None) => {} Ok(Some(str)) => writeln!(description, "Import map: {}", str)?, Err(err) => { diff --git a/turbopack/crates/turbopack-core/src/resolve/options.rs b/turbopack/crates/turbopack-core/src/resolve/options.rs index 9297d235e3f51..b06f3d10171ff 100644 --- a/turbopack/crates/turbopack-core/src/resolve/options.rs +++ b/turbopack/crates/turbopack-core/src/resolve/options.rs @@ -493,12 +493,12 @@ pub struct ResolveOptions { /// The default files to resolve in a folder. pub default_files: Vec, /// An import map to use before resolving a request. - pub import_map: Option>, + pub import_map: Option>, /// An import map to use when a request is otherwise unresolvable. pub fallback_import_map: Option>, - pub resolved_map: Option>, - pub before_resolve_plugins: Vec>>, - pub plugins: Vec>>, + pub resolved_map: Option>, + pub before_resolve_plugins: Vec>>, + pub plugins: Vec>>, /// Support resolving *.js requests to *.ts files pub enable_typescript_with_output_extension: bool, /// Warn instead of error for resolve errors @@ -521,7 +521,9 @@ impl ResolveOptions { resolve_options .import_map .map(|current_import_map| current_import_map.extend(import_map)) - .unwrap_or(import_map), + .unwrap_or(import_map) + .to_resolved() + .await?, ); Ok(resolve_options.into()) } diff --git a/turbopack/crates/turbopack-resolve/src/resolve.rs b/turbopack/crates/turbopack-resolve/src/resolve.rs index 767ce02167f67..03b122b171e45 100644 --- a/turbopack/crates/turbopack-resolve/src/resolve.rs +++ b/turbopack/crates/turbopack-resolve/src/resolve.rs @@ -133,7 +133,7 @@ async fn base_resolve_options( let additional_import_map = additional_import_map.await?; import_map.extend_ref(&additional_import_map); } - let import_map = import_map.cell(); + let import_map = import_map.resolved_cell(); let plugins = opt.after_resolve_plugins.clone(); @@ -281,7 +281,7 @@ pub async fn resolve_options( let context_value = &*resolve_path.await?; for (condition, new_options_context) in options_context_value.rules.iter() { if condition.matches(context_value).await? { - return Ok(resolve_options(resolve_path, *new_options_context)); + return Ok(resolve_options(resolve_path, **new_options_context)); } } } @@ -304,13 +304,13 @@ pub async fn resolve_options( // overwrites any other mappings. let resolve_options = options_context_value .import_map - .map(|import_map| resolve_options.with_extended_import_map(import_map)) + .map(|import_map| resolve_options.with_extended_import_map(*import_map)) .unwrap_or(resolve_options); // And the same for the fallback_import_map let resolve_options = options_context_value .fallback_import_map .map(|fallback_import_map| { - resolve_options.with_extended_fallback_import_map(fallback_import_map) + resolve_options.with_extended_fallback_import_map(*fallback_import_map) }) .unwrap_or(resolve_options); diff --git a/turbopack/crates/turbopack-resolve/src/resolve_options_context.rs b/turbopack/crates/turbopack-resolve/src/resolve_options_context.rs index 6efa18a592e76..979b1e099e167 100644 --- a/turbopack/crates/turbopack-resolve/src/resolve_options_context.rs +++ b/turbopack/crates/turbopack-resolve/src/resolve_options_context.rs @@ -29,7 +29,7 @@ pub struct ResolveOptionsContext { #[serde(default)] /// Enable resolving of the node_modules folder when within the provided /// directory - pub enable_node_modules: Option>, + pub enable_node_modules: Option>, #[serde(default)] /// Mark well-known Node.js modules as external imports and load them using /// native `require`. e.g. url, querystring, os @@ -53,25 +53,25 @@ pub struct ResolveOptionsContext { /// If set, this import map will be applied to `ResolveOption::import_map`. /// It is always applied last, so any mapping defined within will take /// precedence over any other (e.g. tsconfig.json `compilerOptions.paths`). - pub import_map: Option>, + pub import_map: Option>, #[serde(default)] /// An import map to fall back to when a request could not be resolved. /// /// If set, this import map will be applied to /// `ResolveOption::fallback_import_map`. It is always applied last, so /// any mapping defined within will take precedence over any other. - pub fallback_import_map: Option>, + pub fallback_import_map: Option>, #[serde(default)] /// An additional resolved map to use after modules have been resolved. - pub resolved_map: Option>, + pub resolved_map: Option>, #[serde(default)] /// A list of rules to use a different resolve option context for certain /// context paths. The first matching is used. - pub rules: Vec<(ContextCondition, Vc)>, + pub rules: Vec<(ContextCondition, ResolvedVc)>, #[serde(default)] /// Plugins which get applied before and after resolving. - pub after_resolve_plugins: Vec>>, - pub before_resolve_plugins: Vec>>, + pub after_resolve_plugins: Vec>>, + pub before_resolve_plugins: Vec>>, /// Warn instead of error for resolve errors pub loose_errors: bool, @@ -101,7 +101,9 @@ impl ResolveOptionsContext { resolve_options_context .import_map .map(|current_import_map| current_import_map.extend(import_map)) - .unwrap_or(import_map), + .unwrap_or(import_map) + .to_resolved() + .await?, ); Ok(resolve_options_context.into()) } @@ -120,7 +122,9 @@ impl ResolveOptionsContext { .map(|current_fallback_import_map| { current_fallback_import_map.extend(fallback_import_map) }) - .unwrap_or(fallback_import_map), + .unwrap_or(fallback_import_map) + .to_resolved() + .await?, ); Ok(resolve_options_context.into()) } diff --git a/turbopack/crates/turbopack-resolve/src/typescript.rs b/turbopack/crates/turbopack-resolve/src/typescript.rs index c518af8f70db0..6176314f1cfdb 100644 --- a/turbopack/crates/turbopack-resolve/src/typescript.rs +++ b/turbopack/crates/turbopack-resolve/src/typescript.rs @@ -2,7 +2,7 @@ use std::{collections::HashMap, fmt::Write, mem::take}; use anyhow::Result; use serde_json::Value as JsonValue; -use turbo_tasks::{fxindexset, RcStr, Value, ValueDefault, Vc}; +use turbo_tasks::{fxindexset, RcStr, ResolvedVc, Value, ValueDefault, Vc}; use turbo_tasks_fs::{FileContent, FileJsonContent, FileSystemPath}; use turbopack_core::{ asset::Asset, @@ -30,8 +30,8 @@ use crate::ecmascript::get_condition_maps; #[turbo_tasks::value(shared)] pub struct TsConfigIssue { - pub severity: Vc, - pub source_ident: Vc, + pub severity: ResolvedVc, + pub source_ident: ResolvedVc, pub message: RcStr, } @@ -71,8 +71,8 @@ pub async fn read_tsconfigs( write!(message, "{}", e)?; } TsConfigIssue { - severity: IssueSeverity::Error.into(), - source_ident: tsconfig.ident(), + severity: IssueSeverity::Error.resolved_cell(), + source_ident: tsconfig.ident().to_resolved().await?, message: message.into(), } .cell() @@ -80,8 +80,8 @@ pub async fn read_tsconfigs( } FileJsonContent::NotFound => { TsConfigIssue { - severity: IssueSeverity::Error.into(), - source_ident: tsconfig.ident(), + severity: IssueSeverity::Error.resolved_cell(), + source_ident: tsconfig.ident().to_resolved().await?, message: "tsconfig not found".into(), } .cell() @@ -97,8 +97,8 @@ pub async fn read_tsconfigs( continue; } else { TsConfigIssue { - severity: IssueSeverity::Error.into(), - source_ident: tsconfig.ident(), + severity: IssueSeverity::Error.resolved_cell(), + source_ident: tsconfig.ident().to_resolved().await?, message: format!("extends: \"{}\" doesn't resolve correctly", extends) .into(), } @@ -220,8 +220,8 @@ pub async fn read_from_tsconfigs( #[turbo_tasks::value] #[derive(Default)] pub struct TsConfigResolveOptions { - base_url: Option>, - import_map: Option>, + base_url: Option>, + import_map: Option>, is_module_resolution_nodenext: bool, } @@ -298,8 +298,8 @@ pub async fn tsconfig_resolve_options( ); } else { TsConfigIssue { - severity: IssueSeverity::Warning.cell(), - source_ident: source.ident(), + severity: IssueSeverity::Warning.resolved_cell(), + source_ident: source.ident().to_resolved().await?, message: format!( "compilerOptions.paths[{key}] doesn't contains an array as \ expected\n{key}: {value:#}", @@ -321,7 +321,7 @@ pub async fn tsconfig_resolve_options( for (key, value) in all_paths { import_map.insert_alias(AliasPattern::parse(key), value.into()); } - Some(import_map.cell()) + Some(import_map.resolved_cell()) } else { None }; @@ -335,7 +335,7 @@ pub async fn tsconfig_resolve_options( .unwrap_or_default(); Ok(TsConfigResolveOptions { - base_url: base_url.as_deref().copied(), + base_url, import_map, is_module_resolution_nodenext, } @@ -360,7 +360,7 @@ pub async fn apply_tsconfig_resolve_options( resolve_options.modules.insert( 0, ResolveModules::Path { - dir: base_url, + dir: *base_url, // tsconfig basepath doesn't apply to json requests excluded_extensions: Vc::cell(fxindexset![".json".into()]), }, @@ -370,8 +370,10 @@ pub async fn apply_tsconfig_resolve_options( resolve_options.import_map = Some( resolve_options .import_map - .map(|import_map| import_map.extend(tsconfig_import_map)) - .unwrap_or(tsconfig_import_map), + .map(|import_map| import_map.extend(*tsconfig_import_map)) + .unwrap_or(*tsconfig_import_map) + .to_resolved() + .await?, ); } resolve_options.enable_typescript_with_output_extension = @@ -514,7 +516,7 @@ async fn apply_typescript_types_options( impl Issue for TsConfigIssue { #[turbo_tasks::function] fn severity(&self) -> Vc { - self.severity + *self.severity } #[turbo_tasks::function] diff --git a/turbopack/crates/turbopack-tests/tests/execution.rs b/turbopack/crates/turbopack-tests/tests/execution.rs index c07130b033f36..e79da8497b0ef 100644 --- a/turbopack/crates/turbopack-tests/tests/execution.rs +++ b/turbopack/crates/turbopack-tests/tests/execution.rs @@ -11,8 +11,8 @@ use anyhow::{Context, Result}; use dunce::canonicalize; use serde::{Deserialize, Serialize}; use turbo_tasks::{ - debug::ValueDebugFormat, fxindexmap, trace::TraceRawVcs, Completion, RcStr, TryJoinIterExt, - TurboTasks, Value, Vc, + debug::ValueDebugFormat, fxindexmap, trace::TraceRawVcs, Completion, RcStr, ResolvedVc, + TryJoinIterExt, TurboTasks, Value, Vc, }; use turbo_tasks_bytes::stream::SingleValue; use turbo_tasks_env::CommandLineProcessEnv; @@ -190,7 +190,7 @@ struct PreparedTest { path: Vc, project_path: Vc, tests_path: Vc, - project_root: Vc, + project_root: ResolvedVc, options: TestOptions, } @@ -206,7 +206,7 @@ async fn prepare_test(resource: RcStr) -> Result> { let root_fs = DiskFileSystem::new("workspace".into(), REPO_ROOT.clone(), vec![]); let project_fs = DiskFileSystem::new("project".into(), REPO_ROOT.clone(), vec![]); - let project_root = project_fs.root(); + let project_root = project_fs.root().to_resolved().await?; let relative_path = resource_path.strip_prefix(&*REPO_ROOT).context(format!( "stripping repo root {:?} from resource path {:?}", @@ -311,11 +311,11 @@ async fn run_test(prepared_test: Vc) -> Result> browser: true, ..Default::default() } - .cell(), + .resolved_cell(), )], browser: true, module: true, - import_map: Some(import_map.cell()), + import_map: Some(import_map.resolved_cell()), ..Default::default() } .cell(), @@ -323,7 +323,7 @@ async fn run_test(prepared_test: Vc) -> Result> )); let chunking_context = NodeJsChunkingContext::builder( - project_root, + *project_root, chunk_root_path, static_root_path, chunk_root_path, diff --git a/turbopack/crates/turbopack-tests/tests/snapshot.rs b/turbopack/crates/turbopack-tests/tests/snapshot.rs index c11ab223ac29b..84ca7095cb41a 100644 --- a/turbopack/crates/turbopack-tests/tests/snapshot.rs +++ b/turbopack/crates/turbopack-tests/tests/snapshot.rs @@ -196,7 +196,7 @@ async fn run_test(resource: RcStr) -> Result> { }; let root_fs = DiskFileSystem::new("workspace".into(), REPO_ROOT.clone(), vec![]); let project_fs = DiskFileSystem::new("project".into(), REPO_ROOT.clone(), vec![]); - let project_root = project_fs.root(); + let project_root = project_fs.root().to_resolved().await?; let relative_path = test_path.strip_prefix(&*REPO_ROOT)?; let relative_path: RcStr = sys_to_unix(relative_path.to_str().unwrap()).into(); @@ -307,7 +307,7 @@ async fn run_test(resource: RcStr) -> Result> { custom_conditions: vec!["development".into()], ..Default::default() } - .cell(), + .resolved_cell(), )], ..Default::default() } @@ -325,7 +325,7 @@ async fn run_test(resource: RcStr) -> Result> { let chunking_context: Vc> = match options.runtime { Runtime::Browser => Vc::upcast( BrowserChunkingContext::builder( - project_root, + *project_root, path, path, chunk_root_path, @@ -337,7 +337,7 @@ async fn run_test(resource: RcStr) -> Result> { ), Runtime::NodeJs => Vc::upcast( NodeJsChunkingContext::builder( - project_root, + *project_root, path, path, chunk_root_path, diff --git a/turbopack/crates/turbopack/examples/turbopack.rs b/turbopack/crates/turbopack/examples/turbopack.rs index 81d1b12bac23c..611fc9e5fddc2 100644 --- a/turbopack/crates/turbopack/examples/turbopack.rs +++ b/turbopack/crates/turbopack/examples/turbopack.rs @@ -52,7 +52,7 @@ async fn main() -> Result<()> { ResolveOptionsContext { enable_typescript: true, enable_react: true, - enable_node_modules: Some(fs.root()), + enable_node_modules: Some(fs.root().to_resolved().await?), custom_conditions: vec!["development".into()], ..Default::default() } @@ -68,7 +68,7 @@ async fn main() -> Result<()> { let rebased = RebasedAsset::new(module, input, output); emit_with_completion(Vc::upcast(rebased), output).await?; - Ok::, _>(Default::default()) + anyhow::Ok::>(Default::default()) }) }); spawn({ diff --git a/turbopack/crates/turbopack/src/evaluate_context.rs b/turbopack/crates/turbopack/src/evaluate_context.rs index 0483254a3ec55..0d784863e1f87 100644 --- a/turbopack/crates/turbopack/src/evaluate_context.rs +++ b/turbopack/crates/turbopack/src/evaluate_context.rs @@ -48,7 +48,7 @@ pub async fn node_evaluate_asset_context( ) .cell(), ); - let import_map = import_map.cell(); + let import_map = import_map.resolved_cell(); let node_env: RcStr = if let Some(node_env) = &*execution_context.env().read("NODE_ENV".into()).await? { node_env.as_str().into() @@ -59,7 +59,13 @@ pub async fn node_evaluate_asset_context( // base context used for node_modules (and context for app code will be derived // from this) let resolve_options_context = ResolveOptionsContext { - enable_node_modules: Some(execution_context.project_path().root().resolve().await?), + enable_node_modules: Some( + execution_context + .project_path() + .root() + .to_resolved() + .await?, + ), enable_node_externals: true, enable_node_native_modules: true, custom_conditions: vec![node_env.clone(), "node".into()], @@ -71,7 +77,7 @@ pub async fn node_evaluate_asset_context( import_map: Some(import_map), rules: vec![( ContextCondition::InDirectory("node_modules".to_string()), - resolve_options_context.clone().cell(), + resolve_options_context.clone().resolved_cell(), )], ..resolve_options_context } diff --git a/turbopack/crates/turbopack/tests/node-file-trace.rs b/turbopack/crates/turbopack/tests/node-file-trace.rs index 7778b5419955f..0b0f141b44c79 100644 --- a/turbopack/crates/turbopack/tests/node-file-trace.rs +++ b/turbopack/crates/turbopack/tests/node-file-trace.rs @@ -410,7 +410,7 @@ fn node_file_trace( package_root.clone(), vec![], )); - let input_dir = workspace_fs.root(); + let input_dir = workspace_fs.root().to_resolved().await?; let input = input_dir.join(format!("tests/{input_string}").into()); #[cfg(not(feature = "bench_against_node_nft"))] @@ -452,7 +452,7 @@ fn node_file_trace( let module = module_asset_context .process(Vc::upcast(source), Value::new(ReferenceType::Undefined)) .module(); - let rebased = RebasedAsset::new(Vc::upcast(module), input_dir, output_dir); + let rebased = RebasedAsset::new(Vc::upcast(module), *input_dir, output_dir); #[cfg(not(feature = "bench_against_node_nft"))] let output_path = rebased.ident().path();