diff --git a/crates/next-api/src/app.rs b/crates/next-api/src/app.rs index 90faffb314d26..6ca29b1acd412 100644 --- a/crates/next-api/src/app.rs +++ b/crates/next-api/src/app.rs @@ -309,24 +309,32 @@ impl AppProject { } #[turbo_tasks::function] - fn rsc_module_context(self: Vc) -> Vc { + async fn rsc_module_context(self: Vc) -> Result> { let transitions = [ ( ECMASCRIPT_CLIENT_TRANSITION_NAME.into(), - self.client_reference_transition(), + self.client_reference_transition().to_resolved().await?, ), ( "next-dynamic".into(), - Vc::upcast(NextDynamicTransition::new(Vc::upcast( - self.client_transition(), - ))), + ResolvedVc::upcast( + NextDynamicTransition::new(Vc::upcast(self.client_transition())) + .to_resolved() + .await?, + ), + ), + ( + "next-ssr".into(), + ResolvedVc::upcast(self.ssr_transition().to_resolved().await?), + ), + ( + "next-shared".into(), + ResolvedVc::upcast(self.shared_transition().to_resolved().await?), ), - ("next-ssr".into(), Vc::upcast(self.ssr_transition())), - ("next-shared".into(), Vc::upcast(self.shared_transition())), ] .into_iter() .collect(); - ModuleAssetContext::new( + Ok(ModuleAssetContext::new( TransitionOptions { named_transitions: transitions, transition_rules: vec![TransitionRule::new( @@ -340,31 +348,38 @@ impl AppProject { self.rsc_module_options_context(), self.rsc_resolve_options_context(), Vc::cell("app-rsc".into()), - ) + )) } #[turbo_tasks::function] - fn edge_rsc_module_context(self: Vc) -> Vc { + async fn edge_rsc_module_context(self: Vc) -> Result> { let transitions = [ ( ECMASCRIPT_CLIENT_TRANSITION_NAME.into(), - self.edge_client_reference_transition(), + self.edge_client_reference_transition() + .to_resolved() + .await?, ), ( "next-dynamic".into(), - Vc::upcast(NextDynamicTransition::new(Vc::upcast( - self.client_transition(), - ))), + ResolvedVc::upcast( + NextDynamicTransition::new(Vc::upcast(self.client_transition())) + .to_resolved() + .await?, + ), + ), + ( + "next-ssr".into(), + ResolvedVc::upcast(self.edge_ssr_transition().to_resolved().await?), ), - ("next-ssr".into(), Vc::upcast(self.edge_ssr_transition())), ( "next-shared".into(), - Vc::upcast(self.edge_shared_transition()), + ResolvedVc::upcast(self.edge_shared_transition().to_resolved().await?), ), ] .into_iter() .collect(); - ModuleAssetContext::new( + Ok(ModuleAssetContext::new( TransitionOptions { named_transitions: transitions, transition_rules: vec![TransitionRule::new( @@ -378,29 +393,37 @@ impl AppProject { self.edge_rsc_module_options_context(), self.edge_rsc_resolve_options_context(), Vc::cell("app-edge-rsc".into()), - ) + )) } #[turbo_tasks::function] - fn route_module_context(self: Vc) -> Vc { + async fn route_module_context(self: Vc) -> Result> { let transitions = [ ( ECMASCRIPT_CLIENT_TRANSITION_NAME.into(), - self.client_reference_transition(), + self.client_reference_transition().to_resolved().await?, ), ( "next-dynamic".into(), - Vc::upcast(NextDynamicTransition::new(Vc::upcast( - self.client_transition(), - ))), + ResolvedVc::upcast( + NextDynamicTransition::new(Vc::upcast(self.client_transition())) + .to_resolved() + .await?, + ), + ), + ( + "next-ssr".into(), + ResolvedVc::upcast(self.ssr_transition().to_resolved().await?), + ), + ( + "next-shared".into(), + ResolvedVc::upcast(self.shared_transition().to_resolved().await?), ), - ("next-ssr".into(), Vc::upcast(self.ssr_transition())), - ("next-shared".into(), Vc::upcast(self.shared_transition())), ] .into_iter() .collect(); - ModuleAssetContext::new( + Ok(ModuleAssetContext::new( TransitionOptions { named_transitions: transitions, ..Default::default() @@ -410,31 +433,38 @@ impl AppProject { self.route_module_options_context(), self.route_resolve_options_context(), Vc::cell("app-route".into()), - ) + )) } #[turbo_tasks::function] - fn edge_route_module_context(self: Vc) -> Vc { + async fn edge_route_module_context(self: Vc) -> Result> { let transitions = [ ( ECMASCRIPT_CLIENT_TRANSITION_NAME.into(), - self.edge_client_reference_transition(), + self.edge_client_reference_transition() + .to_resolved() + .await?, ), ( "next-dynamic".into(), - Vc::upcast(NextDynamicTransition::new(Vc::upcast( - self.client_transition(), - ))), + ResolvedVc::upcast( + NextDynamicTransition::new(Vc::upcast(self.client_transition())) + .to_resolved() + .await?, + ), + ), + ( + "next-ssr".into(), + ResolvedVc::upcast(self.edge_ssr_transition().to_resolved().await?), ), - ("next-ssr".into(), Vc::upcast(self.ssr_transition())), ( "next-shared".into(), - Vc::upcast(self.edge_shared_transition()), + ResolvedVc::upcast(self.edge_shared_transition().to_resolved().await?), ), ] .into_iter() .collect(); - ModuleAssetContext::new( + Ok(ModuleAssetContext::new( TransitionOptions { named_transitions: transitions, ..Default::default() @@ -444,7 +474,7 @@ impl AppProject { self.edge_route_module_options_context(), self.edge_route_resolve_options_context(), Vc::cell("app-edge-route".into()), - ) + )) } #[turbo_tasks::function] diff --git a/crates/next-api/src/pages.rs b/crates/next-api/src/pages.rs index a7f2cda638fa3..7d2ed05c20892 100644 --- a/crates/next-api/src/pages.rs +++ b/crates/next-api/src/pages.rs @@ -256,19 +256,21 @@ impl PagesProject { } #[turbo_tasks::function] - fn transitions(self: Vc) -> Vc { - TransitionOptions { + async fn transitions(self: Vc) -> Result> { + Ok(TransitionOptions { named_transitions: [( "next-dynamic".into(), - Vc::upcast(NextDynamicTransition::new(Vc::upcast( - self.client_transition(), - ))), + ResolvedVc::upcast( + NextDynamicTransition::new(Vc::upcast(self.client_transition())) + .to_resolved() + .await?, + ), )] .into_iter() .collect(), ..Default::default() } - .cell() + .cell()) } #[turbo_tasks::function] diff --git a/crates/next-api/src/project.rs b/crates/next-api/src/project.rs index cdc7ab4a99a16..5f18177b2cc03 100644 --- a/crates/next-api/src/project.rs +++ b/crates/next-api/src/project.rs @@ -944,7 +944,10 @@ impl Project { if let Some(app_project) = app_project { transitions.push(( ECMASCRIPT_CLIENT_TRANSITION_NAME.into(), - app_project.edge_client_reference_transition(), + app_project + .edge_client_reference_transition() + .to_resolved() + .await?, )); } @@ -1025,7 +1028,10 @@ impl Project { if let Some(app_project) = app_project { transitions.push(( ECMASCRIPT_CLIENT_TRANSITION_NAME.into(), - app_project.client_reference_transition(), + app_project + .client_reference_transition() + .to_resolved() + .await?, )); } @@ -1075,7 +1081,10 @@ impl Project { if let Some(app_project) = app_project { transitions.push(( ECMASCRIPT_CLIENT_TRANSITION_NAME.into(), - app_project.edge_client_reference_transition(), + app_project + .edge_client_reference_transition() + .to_resolved() + .await?, )); } diff --git a/crates/next-core/src/next_client/context.rs b/crates/next-core/src/next_client/context.rs index f81837fcbf49b..97d27e84ca444 100644 --- a/crates/next-core/src/next_client/context.rs +++ b/crates/next-core/src/next_client/context.rs @@ -142,21 +142,21 @@ pub enum ClientContextType { #[turbo_tasks::function] pub async fn get_client_resolve_options_context( - project_path: Vc, + project_path: ResolvedVc, ty: Value, mode: Vc, next_config: Vc, execution_context: Vc, ) -> Result> { let next_client_import_map = - get_next_client_import_map(project_path, ty, next_config, execution_context) + 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()]; @@ -175,18 +175,18 @@ pub async fn get_client_resolve_options_context( .await?, ), ResolvedVc::upcast( - ModuleFeatureReportResolvePlugin::new(project_path) + ModuleFeatureReportResolvePlugin::new(*project_path) .to_resolved() .await?, ), ResolvedVc::upcast( - NextFontLocalResolvePlugin::new(project_path) + NextFontLocalResolvePlugin::new(*project_path) .to_resolved() .await?, ), ], after_resolve_plugins: vec![ResolvedVc::upcast( - NextSharedRuntimeResolvePlugin::new(project_path) + NextSharedRuntimeResolvePlugin::new(*project_path) .to_resolved() .await?, )], @@ -216,7 +216,7 @@ fn internal_assets_conditions() -> ContextCondition { #[turbo_tasks::function] pub async fn get_client_module_options_context( - project_path: Vc, + project_path: ResolvedVc, execution_context: ResolvedVc, env: ResolvedVc, ty: Value, @@ -224,19 +224,28 @@ pub async fn get_client_module_options_context( next_config: Vc, ) -> Result> { let next_mode = mode.await?; - let resolve_options_context = - get_client_resolve_options_context(project_path, ty, mode, next_config, *execution_context); + let resolve_options_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); + let tsconfig = get_typescript_transform_options(*project_path) + .to_resolved() + .await?; + let decorators_options = get_decorators_transform_options(*project_path); let enable_mdx_rs = *next_config.mdx_rs().await?; let jsx_runtime_options = get_jsx_transform_options( - project_path, + *project_path, mode, Some(resolve_options_context), false, next_config, - ); + ) + .to_resolved() + .await?; // A separate webpack rules will be applied to codes matching // foreign_code_context_condition. This allows to import codes from @@ -288,7 +297,7 @@ pub async fn get_client_module_options_context( let postcss_transform_options = PostCssTransformOptions { postcss_package: Some( - get_postcss_package_mapping(project_path) + get_postcss_package_mapping(*project_path) .to_resolved() .await?, ), @@ -301,8 +310,8 @@ pub async fn get_client_module_options_context( config_location: PostCssConfigLocation::ProjectPath, ..postcss_transform_options.clone() }; - let enable_postcss_transform = Some(postcss_transform_options.cell()); - let enable_foreign_postcss_transform = Some(postcss_foreign_transform_options.cell()); + let enable_postcss_transform = Some(postcss_transform_options.resolved_cell()); + let enable_foreign_postcss_transform = Some(postcss_foreign_transform_options.resolved_cell()); let module_options_context = ModuleOptionsContext { ecmascript: EcmascriptOptionsContext { @@ -333,8 +342,10 @@ pub async fn get_client_module_options_context( let internal_context = ModuleOptionsContext { ecmascript: EcmascriptOptionsContext { - enable_typescript_transform: Some(TypescriptTransformOptions::default().cell()), - enable_jsx: Some(JsxTransformOptions::default().cell()), + enable_typescript_transform: Some( + TypescriptTransformOptions::default().resolved_cell(), + ), + enable_jsx: Some(JsxTransformOptions::default().resolved_cell()), ..module_options_context.ecmascript.clone() }, enable_postcss_transform: None, @@ -364,9 +375,12 @@ pub async fn get_client_module_options_context( rules: vec![ ( foreign_code_context_condition(next_config, project_path).await?, - foreign_codes_options_context.cell(), + foreign_codes_options_context.resolved_cell(), + ), + ( + internal_assets_conditions(), + internal_context.resolved_cell(), ), - (internal_assets_conditions(), internal_context.cell()), ], module_rules: next_client_rules, ..module_options_context diff --git a/crates/next-core/src/next_client/transforms.rs b/crates/next-core/src/next_client/transforms.rs index 3f2f9f8276e31..67dec64380538 100644 --- a/crates/next-core/src/next_client/transforms.rs +++ b/crates/next-core/src/next_client/transforms.rs @@ -93,7 +93,7 @@ pub async fn get_next_client_transforms_rules( get_next_dynamic_transform_rule(false, false, is_app_dir, mode, enable_mdx_rs).await?, ); - rules.push(get_next_image_rule()); + rules.push(get_next_image_rule().await?); rules.push(get_next_page_static_info_assert_rule( enable_mdx_rs, None, diff --git a/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_transition.rs b/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_transition.rs index 347e80f46427c..4096364afccf0 100644 --- a/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_transition.rs +++ b/crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_transition.rs @@ -116,11 +116,11 @@ impl Transition for NextEcmascriptClientReferenceTransition { // the context. let module_asset_context = module_asset_context.await?; let server_context = ModuleAssetContext::new( - module_asset_context.transitions, - module_asset_context.compile_time_info, - module_asset_context.module_options_context, - module_asset_context.resolve_options_context, - module_asset_context.layer, + *module_asset_context.transitions, + *module_asset_context.compile_time_info, + *module_asset_context.module_options_context, + *module_asset_context.resolve_options_context, + *module_asset_context.layer, ); Ok(ProcessResult::Module(ResolvedVc::upcast( diff --git a/crates/next-core/src/next_config.rs b/crates/next-core/src/next_config.rs index b7a41570a3958..ba271446d2aba 100644 --- a/crates/next-core/src/next_config.rs +++ b/crates/next-core/src/next_config.rs @@ -829,7 +829,7 @@ impl RemoveConsoleConfig { pub struct ResolveExtensions(Option>); #[turbo_tasks::value(transparent)] -pub struct OptionalMdxTransformOptions(Option>); +pub struct OptionalMdxTransformOptions(Option>); #[turbo_tasks::value_impl] impl NextConfig { @@ -921,8 +921,8 @@ impl NextConfig { let active_conditions = active_conditions.into_iter().collect::>(); let mut rules = FxIndexMap::default(); for (ext, rule) in turbo_rules.iter() { - fn transform_loaders(loaders: &[LoaderItem]) -> Vc { - Vc::cell( + fn transform_loaders(loaders: &[LoaderItem]) -> ResolvedVc { + ResolvedVc::cell( loaders .iter() .map(|item| match item { @@ -990,7 +990,7 @@ impl NextConfig { } } } - Vc::cell(Some(Vc::cell(rules))) + Vc::cell(Some(ResolvedVc::cell(rules))) } #[turbo_tasks::function] @@ -1039,7 +1039,7 @@ impl NextConfig { provider_import_source: Some(mdx_import_source_file()), ..Default::default() } - .cell(), + .resolved_cell(), )), Some(MdxRsOptions::Option(options)) => OptionalMdxTransformOptions(Some( MdxTransformOptions { @@ -1051,7 +1051,7 @@ impl NextConfig { ), ..options.clone() } - .cell(), + .resolved_cell(), )), _ => OptionalMdxTransformOptions(None), }; diff --git a/crates/next-core/src/next_edge/context.rs b/crates/next-core/src/next_edge/context.rs index 78e62bd229e74..bab4981138dc3 100644 --- a/crates/next-core/src/next_edge/context.rs +++ b/crates/next-core/src/next_edge/context.rs @@ -89,21 +89,21 @@ pub fn get_edge_compile_time_info( #[turbo_tasks::function] pub async fn get_edge_resolve_options_context( - project_path: Vc, + project_path: ResolvedVc, ty: Value, mode: Vc, next_config: Vc, 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![ResolvedVc::upcast( - ModuleFeatureReportResolvePlugin::new(project_path) + ModuleFeatureReportResolvePlugin::new(*project_path) .to_resolved() .await?, )]; @@ -114,7 +114,7 @@ pub async fn get_edge_resolve_options_context( | ServerContextType::AppRSC { .. } ) { before_resolve_plugins.push(ResolvedVc::upcast( - NextFontLocalResolvePlugin::new(project_path) + NextFontLocalResolvePlugin::new(*project_path) .to_resolved() .await?, )); @@ -141,7 +141,7 @@ pub async fn get_edge_resolve_options_context( } let after_resolve_plugins = vec![ResolvedVc::upcast( - NextSharedRuntimeResolvePlugin::new(project_path) + NextSharedRuntimeResolvePlugin::new(*project_path) .to_resolved() .await?, )]; diff --git a/crates/next-core/src/next_font/google/font_fallback.rs b/crates/next-core/src/next_font/google/font_fallback.rs index eb27e6f278862..356c8cc64cad0 100644 --- a/crates/next-core/src/next_font/google/font_fallback.rs +++ b/crates/next-core/src/next_font/google/font_fallback.rs @@ -4,7 +4,7 @@ use anyhow::{Context, Result}; use once_cell::sync::Lazy; use regex::Regex; use serde::{Deserialize, Serialize}; -use turbo_tasks::{trace::TraceRawVcs, RcStr, Vc}; +use turbo_tasks::{trace::TraceRawVcs, RcStr, ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::issue::{IssueExt, IssueSeverity, StyledString}; @@ -44,7 +44,7 @@ struct Fallback { #[turbo_tasks::function] pub(super) async fn get_font_fallback( - lookup_path: Vc, + lookup_path: ResolvedVc, options_vc: Vc, ) -> Result> { let options = options_vc.await?; @@ -74,7 +74,7 @@ pub(super) async fn get_font_fallback( .cell(), Err(_) => { NextFontIssue { - path: lookup_path, + path: *lookup_path, title: StyledString::Text( format!( "Failed to find font override values for font `{}`", diff --git a/crates/next-core/src/next_font/google/mod.rs b/crates/next-core/src/next_font/google/mod.rs index c9f1b26bfa286..f2922f64f9d45 100644 --- a/crates/next-core/src/next_font/google/mod.rs +++ b/crates/next-core/src/next_font/google/mod.rs @@ -398,7 +398,7 @@ impl ImportMappingReplacement for NextFontGoogleFontFileReplacer { } #[turbo_tasks::function] -async fn load_font_data(project_root: Vc) -> Result> { +async fn load_font_data(project_root: ResolvedVc) -> Result> { let data: FontData = load_next_js_templateon( project_root, "dist/compiled/@next/font/dist/google/font-data.json".into(), diff --git a/crates/next-core/src/next_import_map.rs b/crates/next-core/src/next_import_map.rs index df1c325eaca4d..4f4dd5b8ef33a 100644 --- a/crates/next-core/src/next_import_map.rs +++ b/crates/next-core/src/next_import_map.rs @@ -516,7 +516,7 @@ async fn insert_unsupported_node_internal_aliases( pub fn get_next_client_resolved_map( _context: Vc, - _root: Vc, + _root: ResolvedVc, _mode: NextMode, ) -> Vc { let glob_mappings = vec![]; diff --git a/crates/next-core/src/next_server/context.rs b/crates/next-core/src/next_server/context.rs index 546bf5ccadfcc..7404f8f38f8cf 100644 --- a/crates/next-core/src/next_server/context.rs +++ b/crates/next-core/src/next_server/context.rs @@ -121,20 +121,20 @@ impl ServerContextType { #[turbo_tasks::function] pub async fn get_server_resolve_options_context( - project_path: Vc, + project_path: ResolvedVc, ty: Value, mode: Vc, next_config: Vc, 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().to_resolved().await?; - let module_feature_report_resolve_plugin = ModuleFeatureReportResolvePlugin::new(project_path) + 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) @@ -152,7 +152,7 @@ pub async fn get_server_resolve_options_context( ) .await?; - let mut transpiled_packages = get_transpiled_packages(next_config, project_path) + let mut transpiled_packages = get_transpiled_packages(next_config, *project_path) .await? .clone_value(); @@ -185,7 +185,7 @@ pub async fn get_server_resolve_options_context( let ty = ty.into_value(); let server_external_packages_plugin = ExternalCjsModulesResolvePlugin::new( - project_path, + *project_path, project_path.root(), ExternalPredicate::Only(ResolvedVc::cell(external_packages)).cell(), *next_config.import_externals().await?, @@ -210,7 +210,7 @@ pub async fn get_server_resolve_options_context( server_external_packages_plugin } else { ExternalCjsModulesResolvePlugin::new( - project_path, + *project_path, project_path.root(), ExternalPredicate::AllExcept(ResolvedVc::cell(transpiled_packages)).cell(), *next_config.import_externals().await?, @@ -219,11 +219,11 @@ pub async fn get_server_resolve_options_context( .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?; @@ -233,7 +233,7 @@ pub async fn get_server_resolve_options_context( | ServerContextType::AppRSC { .. } => { vec![ ResolvedVc::upcast( - NextFontLocalResolvePlugin::new(project_path) + NextFontLocalResolvePlugin::new(*project_path) .to_resolved() .await?, ), @@ -396,7 +396,7 @@ fn internal_assets_conditions() -> ContextCondition { #[turbo_tasks::function] pub async fn get_server_module_options_context( - project_path: Vc, + project_path: ResolvedVc, execution_context: ResolvedVc, ty: Value, mode: Vc, @@ -420,7 +420,7 @@ pub async fn get_server_module_options_context( foreign_code_context_condition(next_config, project_path).await?; let postcss_transform_options = PostCssTransformOptions { postcss_package: Some( - get_postcss_package_mapping(project_path) + get_postcss_package_mapping(*project_path) .to_resolved() .await?, ), @@ -434,8 +434,8 @@ pub async fn get_server_module_options_context( config_location: PostCssConfigLocation::ProjectPath, ..postcss_transform_options.clone() }; - let enable_postcss_transform = Some(postcss_transform_options.cell()); - let enable_foreign_postcss_transform = Some(postcss_foreign_transform_options.cell()); + let enable_postcss_transform = Some(postcss_transform_options.resolved_cell()); + let enable_foreign_postcss_transform = Some(postcss_foreign_transform_options.resolved_cell()); let mut conditions = vec![mode.await?.condition().into()]; conditions.extend( @@ -475,8 +475,10 @@ pub async fn get_server_module_options_context( let versions = RuntimeVersions(Default::default()).cell(); // ModuleOptionsContext related options - let tsconfig = get_typescript_transform_options(project_path); - let decorators_options = get_decorators_transform_options(project_path); + let tsconfig = get_typescript_transform_options(*project_path) + .to_resolved() + .await?; + let decorators_options = get_decorators_transform_options(*project_path); let enable_mdx_rs = *next_config.mdx_rs().await?; // Get the jsx transform options for the `client` side. @@ -487,9 +489,13 @@ pub async fn get_server_module_options_context( // This enables correct emotion transform and other hydration between server and // client bundles. ref: https://github.com/vercel/next.js/blob/4bbf9b6c70d2aa4237defe2bebfa790cdb7e334e/packages/next/src/build/webpack-config.ts#L1421-L1426 let jsx_runtime_options = - get_jsx_transform_options(project_path, mode, None, false, next_config); + get_jsx_transform_options(*project_path, mode, None, false, next_config) + .to_resolved() + .await?; let rsc_jsx_runtime_options = - get_jsx_transform_options(project_path, mode, None, true, next_config); + get_jsx_transform_options(*project_path, mode, None, true, next_config) + .to_resolved() + .await?; // A set of custom ecma transform rules being applied to server context. let source_transform_rules: Vec = vec![ @@ -586,8 +592,10 @@ pub async fn get_server_module_options_context( let internal_module_options_context = ModuleOptionsContext { ecmascript: EcmascriptOptionsContext { - enable_typescript_transform: Some(TypescriptTransformOptions::default().cell()), - enable_jsx: Some(JsxTransformOptions::default().cell()), + enable_typescript_transform: Some( + TypescriptTransformOptions::default().resolved_cell(), + ), + enable_jsx: Some(JsxTransformOptions::default().resolved_cell()), ..module_options_context.ecmascript.clone() }, module_rules: foreign_next_server_rules, @@ -607,11 +615,11 @@ pub async fn get_server_module_options_context( rules: vec![ ( foreign_code_context_condition, - foreign_code_module_options_context.cell(), + foreign_code_module_options_context.resolved_cell(), ), ( internal_assets_conditions(), - internal_module_options_context.cell(), + internal_module_options_context.resolved_cell(), ), ], module_rules: next_server_rules, @@ -650,7 +658,9 @@ pub async fn get_server_module_options_context( }; let internal_module_options_context = ModuleOptionsContext { ecmascript: EcmascriptOptionsContext { - enable_typescript_transform: Some(TypescriptTransformOptions::default().cell()), + enable_typescript_transform: Some( + TypescriptTransformOptions::default().resolved_cell(), + ), ..module_options_context.ecmascript.clone() }, module_rules: foreign_next_server_rules, @@ -670,11 +680,11 @@ pub async fn get_server_module_options_context( rules: vec![ ( foreign_code_context_condition, - foreign_code_module_options_context.cell(), + foreign_code_module_options_context.resolved_cell(), ), ( internal_assets_conditions(), - internal_module_options_context.cell(), + internal_module_options_context.resolved_cell(), ), ], module_rules: next_server_rules, @@ -725,7 +735,9 @@ pub async fn get_server_module_options_context( }; let internal_module_options_context = ModuleOptionsContext { ecmascript: EcmascriptOptionsContext { - enable_typescript_transform: Some(TypescriptTransformOptions::default().cell()), + enable_typescript_transform: Some( + TypescriptTransformOptions::default().resolved_cell(), + ), ..module_options_context.ecmascript.clone() }, module_rules: foreign_next_server_rules, @@ -744,11 +756,11 @@ pub async fn get_server_module_options_context( rules: vec![ ( foreign_code_context_condition, - foreign_code_module_options_context.cell(), + foreign_code_module_options_context.resolved_cell(), ), ( internal_assets_conditions(), - internal_module_options_context.cell(), + internal_module_options_context.resolved_cell(), ), ], module_rules: next_server_rules, @@ -798,7 +810,9 @@ pub async fn get_server_module_options_context( }; let internal_module_options_context = ModuleOptionsContext { ecmascript: EcmascriptOptionsContext { - enable_typescript_transform: Some(TypescriptTransformOptions::default().cell()), + enable_typescript_transform: Some( + TypescriptTransformOptions::default().resolved_cell(), + ), ..module_options_context.ecmascript.clone() }, module_rules: internal_custom_rules, @@ -817,11 +831,11 @@ pub async fn get_server_module_options_context( rules: vec![ ( foreign_code_context_condition, - foreign_code_module_options_context.cell(), + foreign_code_module_options_context.resolved_cell(), ), ( internal_assets_conditions(), - internal_module_options_context.cell(), + internal_module_options_context.resolved_cell(), ), ], module_rules: next_server_rules, @@ -893,7 +907,9 @@ pub async fn get_server_module_options_context( }; let internal_module_options_context = ModuleOptionsContext { ecmascript: EcmascriptOptionsContext { - enable_typescript_transform: Some(TypescriptTransformOptions::default().cell()), + enable_typescript_transform: Some( + TypescriptTransformOptions::default().resolved_cell(), + ), ..module_options_context.ecmascript.clone() }, module_rules: internal_custom_rules, @@ -912,11 +928,11 @@ pub async fn get_server_module_options_context( rules: vec![ ( foreign_code_context_condition, - foreign_code_module_options_context.cell(), + foreign_code_module_options_context.resolved_cell(), ), ( internal_assets_conditions(), - internal_module_options_context.cell(), + internal_module_options_context.resolved_cell(), ), ], module_rules: next_server_rules, diff --git a/crates/next-core/src/next_server/transforms.rs b/crates/next-core/src/next_server/transforms.rs index bc7cf0da2626d..b37be21a37f83 100644 --- a/crates/next-core/src/next_server/transforms.rs +++ b/crates/next-core/src/next_server/transforms.rs @@ -142,7 +142,7 @@ pub async fn get_next_server_transforms_rules( // rules.push(get_next_optimize_server_react_rule(enable_mdx_rs, // optimize_use_state)) - rules.push(get_next_image_rule()); + rules.push(get_next_image_rule().await?); } if let NextRuntime::Edge = next_runtime { diff --git a/crates/next-core/src/next_shared/resolve.rs b/crates/next-core/src/next_shared/resolve.rs index 329a5c32cdf84..ea4b935127747 100644 --- a/crates/next-core/src/next_shared/resolve.rs +++ b/crates/next-core/src/next_shared/resolve.rs @@ -153,10 +153,10 @@ impl BeforeResolvePlugin for InvalidImportResolvePlugin { /// Only the contexts that alises `client-only` to /// `next/dist/compiled/client-only/error` should use this. pub(crate) fn get_invalid_client_only_resolve_plugin( - root: Vc, + root: ResolvedVc, ) -> Vc { InvalidImportResolvePlugin::new( - root, + *root, "client-only".into(), vec![ "'client-only' cannot be imported from a Server Component module. It should only be \ @@ -170,10 +170,10 @@ pub(crate) fn get_invalid_client_only_resolve_plugin( /// Only the contexts that alises `server-only` to /// `next/dist/compiled/server-only/index` should use this. pub(crate) fn get_invalid_server_only_resolve_plugin( - root: Vc, + root: ResolvedVc, ) -> Vc { InvalidImportResolvePlugin::new( - root, + *root, "server-only".into(), vec![ "'server-only' cannot be imported from a Client Component module. It should only be \ @@ -185,10 +185,10 @@ pub(crate) fn get_invalid_server_only_resolve_plugin( /// Returns a resolve plugin if context have imports to `styled-jsx`. pub(crate) fn get_invalid_styled_jsx_resolve_plugin( - root: Vc, + root: ResolvedVc, ) -> Vc { InvalidImportResolvePlugin::new( - root, + *root, "styled-jsx".into(), vec![ "'client-only' cannot be imported from a Server Component module. It should only be \ diff --git a/crates/next-core/src/next_shared/transforms/debug_fn_name.rs b/crates/next-core/src/next_shared/transforms/debug_fn_name.rs index e9f350824f4cc..7ae0b5e7b849e 100644 --- a/crates/next-core/src/next_shared/transforms/debug_fn_name.rs +++ b/crates/next-core/src/next_shared/transforms/debug_fn_name.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::debug_fn_name::debug_fn_name; use swc_core::ecma::{ast::Program, visit::VisitMutWith}; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -15,8 +15,8 @@ pub fn get_debug_fn_name_rule(enable_mdx_rs: bool) -> ModuleRule { ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![debug_fn_name_transform]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![debug_fn_name_transform]), }], ) } diff --git a/crates/next-core/src/next_shared/transforms/mod.rs b/crates/next-core/src/next_shared/transforms/mod.rs index a70d2b9c3f652..307d4ab5d33b0 100644 --- a/crates/next-core/src/next_shared/transforms/mod.rs +++ b/crates/next-core/src/next_shared/transforms/mod.rs @@ -24,13 +24,14 @@ pub(crate) mod styled_components; pub(crate) mod styled_jsx; pub(crate) mod swc_ecma_transform_plugins; +use anyhow::Result; pub use modularize_imports::{get_next_modularize_imports_rule, ModularizeImportPackageConfig}; pub use next_dynamic::get_next_dynamic_transform_rule; pub use next_font::get_next_font_transform_rule; pub use next_lint::get_next_lint_transform_rule; pub use next_strip_page_exports::get_next_pages_transforms_rule; pub use server_actions::get_server_actions_transform_rule; -use turbo_tasks::{ReadRef, Value, Vc}; +use turbo_tasks::{ReadRef, ResolvedVc, Value, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack::module_options::{ModuleRule, ModuleRuleEffect, ModuleType, RuleCondition}; use turbopack_core::reference_type::{ReferenceType, UrlReferenceSubType}; @@ -38,8 +39,8 @@ use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform}; use crate::next_image::{module::BlurPlaceholderMode, StructuredImageModuleType}; -pub fn get_next_image_rule() -> ModuleRule { - ModuleRule::new( +pub async fn get_next_image_rule() -> Result { + Ok(ModuleRule::new( RuleCondition::All(vec![ // avoid urlAssetReference to be affected by this rule, since urlAssetReference // requires raw module to have its paths in the export @@ -63,11 +64,13 @@ pub fn get_next_image_rule() -> ModuleRule { ]), ]), vec![ModuleRuleEffect::ModuleType(ModuleType::Custom( - Vc::upcast(StructuredImageModuleType::new(Value::new( - BlurPlaceholderMode::DataUrl, - ))), + ResolvedVc::upcast( + StructuredImageModuleType::new(Value::new(BlurPlaceholderMode::DataUrl)) + .to_resolved() + .await?, + ), ))], - ) + )) } fn match_js_extension(enable_mdx_rs: bool) -> Vec { @@ -135,9 +138,15 @@ pub(crate) fn get_ecma_transform_rule( ) -> ModuleRule { let transformer = EcmascriptInputTransform::Plugin(Vc::cell(transformer as _)); let (prepend, append) = if prepend { - (Vc::cell(vec![transformer]), Vc::cell(vec![])) + ( + ResolvedVc::cell(vec![transformer]), + ResolvedVc::cell(vec![]), + ) } else { - (Vc::cell(vec![]), Vc::cell(vec![transformer])) + ( + ResolvedVc::cell(vec![]), + ResolvedVc::cell(vec![transformer]), + ) }; ModuleRule::new( diff --git a/crates/next-core/src/next_shared/transforms/modularize_imports.rs b/crates/next-core/src/next_shared/transforms/modularize_imports.rs index 74152ed10df23..413fb96d58dad 100644 --- a/crates/next-core/src/next_shared/transforms/modularize_imports.rs +++ b/crates/next-core/src/next_shared/transforms/modularize_imports.rs @@ -5,7 +5,7 @@ use async_trait::async_trait; use modularize_imports::{modularize_imports, PackageConfig}; use serde::{Deserialize, Serialize}; use swc_core::ecma::ast::Program; -use turbo_tasks::{trace::TraceRawVcs, FxIndexMap, Vc}; +use turbo_tasks::{trace::TraceRawVcs, FxIndexMap, ResolvedVc, Vc}; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -41,8 +41,8 @@ pub fn get_next_modularize_imports_rule( ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![transformer]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![transformer]), }], ) } diff --git a/crates/next-core/src/next_shared/transforms/next_amp_attributes.rs b/crates/next-core/src/next_shared/transforms/next_amp_attributes.rs index 8d65e63b505fb..1f9ff2298f280 100644 --- a/crates/next-core/src/next_shared/transforms/next_amp_attributes.rs +++ b/crates/next-core/src/next_shared/transforms/next_amp_attributes.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::amp_attributes::amp_attributes; use swc_core::ecma::ast::*; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -14,8 +14,8 @@ pub fn get_next_amp_attr_rule(enable_mdx_rs: bool) -> ModuleRule { ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![transformer]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![transformer]), }], ) } diff --git a/crates/next-core/src/next_shared/transforms/next_cjs_optimizer.rs b/crates/next-core/src/next_shared/transforms/next_cjs_optimizer.rs index e727f3b9a1a0c..e8c65150b6e00 100644 --- a/crates/next-core/src/next_shared/transforms/next_cjs_optimizer.rs +++ b/crates/next-core/src/next_shared/transforms/next_cjs_optimizer.rs @@ -6,7 +6,7 @@ use swc_core::{ common::SyntaxContext, ecma::{ast::*, visit::VisitMutWith}, }; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -52,8 +52,8 @@ pub fn get_next_cjs_optimizer_rule(enable_mdx_rs: bool) -> ModuleRule { ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![transformer]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![transformer]), }], ) } diff --git a/crates/next-core/src/next_shared/transforms/next_disallow_re_export_all_in_page.rs b/crates/next-core/src/next_shared/transforms/next_disallow_re_export_all_in_page.rs index e674c4401a880..c7ff8ae07f0a6 100644 --- a/crates/next-core/src/next_shared/transforms/next_disallow_re_export_all_in_page.rs +++ b/crates/next-core/src/next_shared/transforms/next_disallow_re_export_all_in_page.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::disallow_re_export_all_in_page::disallow_re_export_all_in_page; use swc_core::ecma::ast::*; -use turbo_tasks::{ReadRef, Vc}; +use turbo_tasks::{ReadRef, ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -18,8 +18,8 @@ pub fn get_next_disallow_export_all_in_page_rule( ModuleRule::new( module_rule_match_pages_page_file(enable_mdx_rs, pages_dir), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![transformer]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![transformer]), }], ) } diff --git a/crates/next-core/src/next_shared/transforms/next_dynamic.rs b/crates/next-core/src/next_shared/transforms/next_dynamic.rs index f78ae131b7037..b993f8e3a18ad 100644 --- a/crates/next-core/src/next_shared/transforms/next_dynamic.rs +++ b/crates/next-core/src/next_shared/transforms/next_dynamic.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::dynamic::{next_dynamic, NextDynamicMode}; use swc_core::{common::FileName, ecma::ast::Program}; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -26,8 +26,8 @@ pub async fn get_next_dynamic_transform_rule( Ok(ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![dynamic_transform]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![dynamic_transform]), }], )) } diff --git a/crates/next-core/src/next_shared/transforms/next_edge_node_api_assert.rs b/crates/next-core/src/next_shared/transforms/next_edge_node_api_assert.rs index cb688b15ef9d9..cfdf6013c80d5 100644 --- a/crates/next-core/src/next_shared/transforms/next_edge_node_api_assert.rs +++ b/crates/next-core/src/next_shared/transforms/next_edge_node_api_assert.rs @@ -5,7 +5,7 @@ use swc_core::{ common::SyntaxContext, ecma::{ast::*, utils::ExprCtx, visit::VisitWith}, }; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -23,8 +23,8 @@ pub fn next_edge_node_api_assert( ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![transformer]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![transformer]), }], ) } diff --git a/crates/next-core/src/next_shared/transforms/next_font.rs b/crates/next-core/src/next_shared/transforms/next_font.rs index b3f1dc3d0c8a3..3bcf54b84f88e 100644 --- a/crates/next-core/src/next_shared/transforms/next_font.rs +++ b/crates/next-core/src/next_shared/transforms/next_font.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::fonts::*; use swc_core::ecma::{ast::Program, atoms::JsWord, visit::VisitMutWith}; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -23,8 +23,8 @@ pub fn get_next_font_transform_rule(enable_mdx_rs: bool) -> ModuleRule { // TODO: Only match in pages (not pages/api), app/, etc. module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![transformer]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![transformer]), }], ) } diff --git a/crates/next-core/src/next_shared/transforms/next_middleware_dynamic_assert.rs b/crates/next-core/src/next_shared/transforms/next_middleware_dynamic_assert.rs index fd17112dada9e..bb46d47b32660 100644 --- a/crates/next-core/src/next_shared/transforms/next_middleware_dynamic_assert.rs +++ b/crates/next-core/src/next_shared/transforms/next_middleware_dynamic_assert.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::middleware_dynamic::next_middleware_dynamic; use swc_core::ecma::{ast::*, visit::VisitMutWith}; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -14,8 +14,8 @@ pub fn get_middleware_dynamic_assert_rule(enable_mdx_rs: bool) -> ModuleRule { ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![transformer]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![transformer]), }], ) } diff --git a/crates/next-core/src/next_shared/transforms/next_optimize_server_react.rs b/crates/next-core/src/next_shared/transforms/next_optimize_server_react.rs index 6f7278b31ce75..f48f525138f10 100644 --- a/crates/next-core/src/next_shared/transforms/next_optimize_server_react.rs +++ b/crates/next-core/src/next_shared/transforms/next_optimize_server_react.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::optimize_server_react::{optimize_server_react, Config}; use swc_core::ecma::ast::*; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -20,8 +20,8 @@ pub fn get_next_optimize_server_react_rule( ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![transformer]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![transformer]), }], ) } diff --git a/crates/next-core/src/next_shared/transforms/next_page_config.rs b/crates/next-core/src/next_shared/transforms/next_page_config.rs index deed8c9c741d9..9e39cd4a66233 100644 --- a/crates/next-core/src/next_shared/transforms/next_page_config.rs +++ b/crates/next-core/src/next_shared/transforms/next_page_config.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::page_config::page_config; use swc_core::ecma::ast::*; -use turbo_tasks::{ReadRef, Vc}; +use turbo_tasks::{ReadRef, ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -20,8 +20,8 @@ pub fn get_next_page_config_rule( ModuleRule::new( module_rule_match_pages_page_file(enable_mdx_rs, pages_dir), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![transformer]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![transformer]), }], ) } diff --git a/crates/next-core/src/next_shared/transforms/next_page_static_info.rs b/crates/next-core/src/next_shared/transforms/next_page_static_info.rs index 16202e9e2b469..e26864de8cca7 100644 --- a/crates/next-core/src/next_shared/transforms/next_page_static_info.rs +++ b/crates/next-core/src/next_shared/transforms/next_page_static_info.rs @@ -5,7 +5,7 @@ use next_custom_transforms::transforms::page_static_info::{ }; use serde_json::Value; use swc_core::ecma::ast::Program; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_core::issue::{ @@ -32,8 +32,8 @@ pub fn get_next_page_static_info_assert_rule( ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![transformer]), - append: Vc::cell(vec![]), + prepend: ResolvedVc::cell(vec![transformer]), + append: ResolvedVc::cell(vec![]), }], ) } diff --git a/crates/next-core/src/next_shared/transforms/next_pure.rs b/crates/next-core/src/next_shared/transforms/next_pure.rs index dbc24f95ee64c..033d7d02ef592 100644 --- a/crates/next-core/src/next_shared/transforms/next_pure.rs +++ b/crates/next-core/src/next_shared/transforms/next_pure.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::pure::pure_magic; use swc_core::ecma::{ast::*, visit::VisitMutWith}; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -13,8 +13,8 @@ pub fn get_next_pure_rule(enable_mdx_rs: bool) -> ModuleRule { ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![transformer]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![transformer]), }], ) } diff --git a/crates/next-core/src/next_shared/transforms/next_shake_exports.rs b/crates/next-core/src/next_shared/transforms/next_shake_exports.rs index c1ef20b94d561..6e86422b84648 100644 --- a/crates/next-core/src/next_shared/transforms/next_shake_exports.rs +++ b/crates/next-core/src/next_shared/transforms/next_shake_exports.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::shake_exports::{shake_exports, Config}; use swc_core::ecma::ast::*; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -15,8 +15,8 @@ pub fn get_next_shake_exports_rule(enable_mdx_rs: bool, ignore: Vec) -> ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![transformer]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![transformer]), }], ) } diff --git a/crates/next-core/src/next_shared/transforms/next_strip_page_exports.rs b/crates/next-core/src/next_shared/transforms/next_strip_page_exports.rs index 1a7ee5874cf59..e6ccc13443ecc 100644 --- a/crates/next-core/src/next_shared/transforms/next_strip_page_exports.rs +++ b/crates/next-core/src/next_shared/transforms/next_strip_page_exports.rs @@ -4,7 +4,7 @@ use next_custom_transforms::transforms::strip_page_exports::{ next_transform_strip_page_exports, ExportFilter, }; use swc_core::ecma::ast::Program; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack::module_options::{ModuleRule, ModuleRuleEffect, RuleCondition}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -43,8 +43,8 @@ pub async fn get_next_pages_transforms_rule( module_rule_match_js_no_url(enable_mdx_rs), ]), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![strip_transform]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![strip_transform]), }], )) } diff --git a/crates/next-core/src/next_shared/transforms/relay.rs b/crates/next-core/src/next_shared/transforms/relay.rs index 4f78b10b7facf..186a1319aedc8 100644 --- a/crates/next-core/src/next_shared/transforms/relay.rs +++ b/crates/next-core/src/next_shared/transforms/relay.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack::module_options::ModuleRule; use turbopack_ecmascript_plugins::transform::relay::RelayTransformer; @@ -10,7 +10,7 @@ use crate::next_config::NextConfig; /// Returns a transform rule for the relay graphql transform. pub async fn get_relay_transform_rule( next_config: Vc, - project_path: Vc, + project_path: ResolvedVc, ) -> Result> { let enable_mdx_rs = next_config.mdx_rs().await?.is_some(); let project_path = &*project_path.await?; diff --git a/crates/next-core/src/next_shared/transforms/server_actions.rs b/crates/next-core/src/next_shared/transforms/server_actions.rs index fce9dfe18c658..f584f4bd8c480 100644 --- a/crates/next-core/src/next_shared/transforms/server_actions.rs +++ b/crates/next-core/src/next_shared/transforms/server_actions.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use next_custom_transforms::transforms::server_actions::{server_actions, Config}; use swc_core::{common::FileName, ecma::ast::Program}; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack::module_options::{ModuleRule, ModuleRuleEffect}; use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext}; @@ -27,8 +27,8 @@ pub fn get_server_actions_transform_rule( ModuleRule::new( module_rule_match_js_no_url(enable_mdx_rs), vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![]), - append: Vc::cell(vec![transformer]), + prepend: ResolvedVc::cell(vec![]), + append: ResolvedVc::cell(vec![transformer]), }], ) } 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 d049f44be036c..8f6651449052e 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 @@ -1,7 +1,7 @@ use anyhow::Result; #[allow(unused_imports)] use turbo_tasks::RcStr; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack::module_options::ModuleRule; @@ -9,7 +9,7 @@ use crate::next_config::NextConfig; pub async fn get_swc_ecma_transform_plugin_rule( next_config: Vc, - project_path: Vc, + project_path: ResolvedVc, ) -> Result> { match next_config.experimental().await?.swc_plugins.as_ref() { Some(plugin_configs) if !plugin_configs.is_empty() => { @@ -31,7 +31,7 @@ pub async fn get_swc_ecma_transform_plugin_rule( #[cfg(feature = "plugin")] pub async fn get_swc_ecma_transform_rule_impl( - project_path: Vc, + project_path: ResolvedVc, plugin_configs: &[(RcStr, serde_json::Value)], enable_mdx_rs: bool, ) -> Result> { @@ -59,7 +59,7 @@ pub async fn get_swc_ecma_transform_rule_impl( // Current resolve will fail with latter. let request = Request::parse(Value::new(Pattern::Constant(name.as_str().into()))); let resolve_options = resolve_options( - project_path, + *project_path, ResolveOptionsContext { enable_node_modules: Some(project_path.root().to_resolved().await?), enable_node_native_modules: true, @@ -70,14 +70,14 @@ pub async fn get_swc_ecma_transform_rule_impl( let plugin_wasm_module_resolve_result = handle_resolve_error( resolve( - project_path, + *project_path, Value::new(ReferenceType::CommonJs(CommonJsReferenceSubType::Undefined)), request, resolve_options, ) .as_raw_module_result(), Value::new(ReferenceType::CommonJs(CommonJsReferenceSubType::Undefined)), - project_path, + *project_path, request, resolve_options, false, diff --git a/crates/next-core/src/next_shared/webpack_rules/babel.rs b/crates/next-core/src/next_shared/webpack_rules/babel.rs index 127aba3667e5e..25aee501f2bae 100644 --- a/crates/next-core/src/next_shared/webpack_rules/babel.rs +++ b/crates/next-core/src/next_shared/webpack_rules/babel.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::{Value, Vc}; +use turbo_tasks::{ResolvedVc, Value, Vc}; use turbo_tasks_fs::{self, FileSystemEntryType, FileSystemPath}; use turbopack::module_options::{LoaderRuleItem, OptionWebpackRules, WebpackRules}; use turbopack_core::{ @@ -27,7 +27,7 @@ const BABEL_CONFIG_FILES: &[&str] = &[ #[turbo_tasks::function] pub async fn maybe_add_babel_loader( project_root: Vc, - webpack_rules: Option>, + webpack_rules: Option>, ) -> Result> { let has_babel_config = { let mut has_babel_config = false; @@ -89,12 +89,12 @@ pub async fn maybe_add_babel_loader( if let Some(rule) = rule { let mut loaders = rule.loaders.await?.clone_value(); loaders.push(loader); - rule.loaders = Vc::cell(loaders); + rule.loaders = ResolvedVc::cell(loaders); } else { rules.insert( pattern.into(), LoaderRuleItem { - loaders: Vc::cell(vec![loader]), + loaders: ResolvedVc::cell(vec![loader]), rename_as: Some("*".into()), }, ); @@ -104,7 +104,7 @@ pub async fn maybe_add_babel_loader( } if has_changed { - return Ok(Vc::cell(Some(Vc::cell(rules)))); + return Ok(Vc::cell(Some(ResolvedVc::cell(rules)))); } } Ok(Vc::cell(webpack_rules)) diff --git a/crates/next-core/src/next_shared/webpack_rules/mod.rs b/crates/next-core/src/next_shared/webpack_rules/mod.rs index 3efc4f554a84e..eda92a6e58a52 100644 --- a/crates/next-core/src/next_shared/webpack_rules/mod.rs +++ b/crates/next-core/src/next_shared/webpack_rules/mod.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use turbo_tasks::{RcStr, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack::module_options::WebpackLoadersOptions; use turbopack_core::resolve::options::ImportMapping; @@ -11,25 +11,29 @@ pub(crate) mod babel; pub(crate) mod sass; pub async fn webpack_loader_options( - project_path: Vc, + project_path: ResolvedVc, next_config: Vc, foreign: bool, conditions: Vec, -) -> Result>> { +) -> Result>> { let rules = *next_config.webpack_rules(conditions).await?; - let rules = *maybe_add_sass_loader(next_config.sass_config(), rules).await?; + let rules = *maybe_add_sass_loader(next_config.sass_config(), rules.map(|v| *v)).await?; let rules = if foreign { rules } else { - *maybe_add_babel_loader(project_path, rules).await? + *maybe_add_babel_loader(*project_path, rules.map(|v| *v)).await? }; - Ok(rules.map(|rules| { - WebpackLoadersOptions { - rules, - loader_runner_package: Some(loader_runner_package_mapping()), - } - .cell() - })) + Ok(if let Some(rules) = rules { + Some( + WebpackLoadersOptions { + rules, + loader_runner_package: Some(loader_runner_package_mapping().to_resolved().await?), + } + .resolved_cell(), + ) + } else { + None + }) } #[turbo_tasks::function] diff --git a/crates/next-core/src/next_shared/webpack_rules/sass.rs b/crates/next-core/src/next_shared/webpack_rules/sass.rs index da6d47a8e6934..296142d0f49ba 100644 --- a/crates/next-core/src/next_shared/webpack_rules/sass.rs +++ b/crates/next-core/src/next_shared/webpack_rules/sass.rs @@ -2,7 +2,7 @@ use std::mem::take; use anyhow::{bail, Result}; use serde_json::Value as JsonValue; -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use turbopack::module_options::{LoaderRuleItem, OptionWebpackRules, WebpackRules}; use turbopack_node::transforms::webpack::WebpackLoaderItem; @@ -76,17 +76,17 @@ pub async fn maybe_add_sass_loader( let mut loaders = rule.loaders.await?.clone_value(); loaders.push(resolve_url_loader); loaders.push(sass_loader); - rule.loaders = Vc::cell(loaders); + rule.loaders = ResolvedVc::cell(loaders); } else { rules.insert( pattern.into(), LoaderRuleItem { - loaders: Vc::cell(vec![resolve_url_loader, sass_loader]), + loaders: ResolvedVc::cell(vec![resolve_url_loader, sass_loader]), rename_as: Some(format!("*{rename}").into()), }, ); } } - Ok(Vc::cell(Some(Vc::cell(rules)))) + Ok(Vc::cell(Some(ResolvedVc::cell(rules)))) } diff --git a/crates/next-core/src/util.rs b/crates/next-core/src/util.rs index 76551718ba746..93bed88bd40a7 100644 --- a/crates/next-core/src/util.rs +++ b/crates/next-core/src/util.rs @@ -5,7 +5,8 @@ use swc_core::{ ecma::ast::{Expr, Lit, Program}, }; use turbo_tasks::{ - trace::TraceRawVcs, FxIndexMap, FxIndexSet, RcStr, TaskInput, ValueDefault, ValueToString, Vc, + trace::TraceRawVcs, FxIndexMap, FxIndexSet, RcStr, ResolvedVc, TaskInput, ValueDefault, + ValueToString, Vc, }; use turbo_tasks_fs::{ self, json::parse_json_rope_with_source_context, rope::Rope, util::join_path, File, @@ -91,7 +92,7 @@ pub fn get_asset_path_from_pathname(pathname: &str, ext: &str) -> String { #[turbo_tasks::function] pub async fn get_transpiled_packages( next_config: Vc, - project_path: Vc, + project_path: ResolvedVc, ) -> Result>> { let mut transpile_packages: Vec = next_config.transpile_packages().await?.clone_value(); @@ -108,16 +109,16 @@ pub async fn get_transpiled_packages( pub async fn foreign_code_context_condition( next_config: Vc, - project_path: Vc, + project_path: ResolvedVc, ) -> Result { - let transpiled_packages = get_transpiled_packages(next_config, project_path).await?; + let transpiled_packages = get_transpiled_packages(next_config, *project_path).await?; // The next template files are allowed to import the user's code via import // mapping, and imports must use the project-level [ResolveOptions] instead // of the `node_modules` specific resolve options (the template files are // technically node module files). let not_next_template_dir = ContextCondition::not(ContextCondition::InPath( - get_next_package(project_path).join(NEXT_TEMPLATE_PATH.into()), + get_next_package(*project_path).join(NEXT_TEMPLATE_PATH.into()), )); let result = ContextCondition::all(vec![ @@ -860,10 +861,10 @@ pub fn virtual_next_js_template_path( } pub async fn load_next_js_templateon( - project_path: Vc, + project_path: ResolvedVc, path: RcStr, ) -> Result { - let file_path = get_next_package(project_path).join(path.clone()); + let file_path = get_next_package(*project_path).join(path.clone()); let content = &*file_path.read().await?; diff --git a/turbopack/crates/turbopack-cli/src/contexts.rs b/turbopack/crates/turbopack-cli/src/contexts.rs index 76b3b6f4f3254..5365b47132425 100644 --- a/turbopack/crates/turbopack-cli/src/contexts.rs +++ b/turbopack/crates/turbopack-cli/src/contexts.rs @@ -7,7 +7,7 @@ use turbopack::{ ecmascript::{EcmascriptInputTransform, TreeShakingMode}, module_options::{ EcmascriptOptionsContext, JsxTransformOptions, ModuleOptionsContext, ModuleRule, - ModuleRuleEffect, RuleCondition, + ModuleRuleEffect, RuleCondition, TypescriptTransformOptions, }, ModuleAssetContext, }; @@ -128,7 +128,7 @@ async fn get_client_module_options_context( react_refresh: enable_react_refresh, ..Default::default() } - .cell(), + .resolved_cell(), ); let versions = *env.runtime_versions().await?; @@ -143,7 +143,7 @@ async fn get_client_module_options_context( let module_rules = ModuleRule::new( conditions, vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![ + prepend: ResolvedVc::cell(vec![ EcmascriptInputTransform::Plugin(Vc::cell(Box::new( EmotionTransformer::new(&EmotionTransformConfig::default()) .expect("Should be able to create emotion transformer"), @@ -155,20 +155,22 @@ async fn get_client_module_options_context( versions, )) as _)), ]), - append: Vc::cell(vec![]), + append: ResolvedVc::cell(vec![]), }], ); let module_options_context = ModuleOptionsContext { ecmascript: EcmascriptOptionsContext { enable_jsx, - enable_typescript_transform: Some(Default::default()), + enable_typescript_transform: Some( + TypescriptTransformOptions::default().resolved_cell(), + ), ..Default::default() }, - enable_postcss_transform: Some(PostCssTransformOptions::default().cell()), + enable_postcss_transform: Some(PostCssTransformOptions::default().resolved_cell()), rules: vec![( foreign_code_context_condition().await?, - module_options_context.clone().cell(), + module_options_context.clone().resolved_cell(), )], module_rules: vec![module_rules], ..module_options_context diff --git a/turbopack/crates/turbopack-ecmascript-runtime/src/asset_context.rs b/turbopack/crates/turbopack-ecmascript-runtime/src/asset_context.rs index 5a44d60221a6b..820ddfe73a3a5 100644 --- a/turbopack/crates/turbopack-ecmascript-runtime/src/asset_context.rs +++ b/turbopack/crates/turbopack-ecmascript-runtime/src/asset_context.rs @@ -12,7 +12,9 @@ use turbopack_ecmascript::TreeShakingMode; pub fn get_runtime_asset_context(environment: Vc) -> Vc> { let module_options_context = ModuleOptionsContext { ecmascript: EcmascriptOptionsContext { - enable_typescript_transform: Some(TypescriptTransformOptions::default().cell()), + enable_typescript_transform: Some( + TypescriptTransformOptions::default().resolved_cell(), + ), ..Default::default() }, // TODO: Somehow this fails to compile when enabled. diff --git a/turbopack/crates/turbopack-tests/tests/execution.rs b/turbopack/crates/turbopack-tests/tests/execution.rs index 2d3b674ab7c39..88c7b06cfd879 100644 --- a/turbopack/crates/turbopack-tests/tests/execution.rs +++ b/turbopack/crates/turbopack-tests/tests/execution.rs @@ -23,7 +23,7 @@ use turbo_tasks_fs::{ use turbo_tasks_memory::MemoryBackend; use turbopack::{ ecmascript::TreeShakingMode, - module_options::{EcmascriptOptionsContext, ModuleOptionsContext}, + module_options::{EcmascriptOptionsContext, ModuleOptionsContext, TypescriptTransformOptions}, ModuleAssetContext, }; use turbopack_core::{ @@ -282,7 +282,9 @@ async fn run_test(prepared_test: Vc) -> Result> compile_time_info, ModuleOptionsContext { ecmascript: EcmascriptOptionsContext { - enable_typescript_transform: Some(Default::default()), + enable_typescript_transform: Some( + TypescriptTransformOptions::default().resolved_cell(), + ), import_externals: true, ..Default::default() }, @@ -294,7 +296,7 @@ async fn run_test(prepared_test: Vc) -> Result> tree_shaking_mode: options.tree_shaking_mode, ..Default::default() } - .cell(), + .resolved_cell(), )], ..Default::default() } diff --git a/turbopack/crates/turbopack-tests/tests/snapshot.rs b/turbopack/crates/turbopack-tests/tests/snapshot.rs index c3070a976f6fa..abc4622c808da 100644 --- a/turbopack/crates/turbopack-tests/tests/snapshot.rs +++ b/turbopack/crates/turbopack-tests/tests/snapshot.rs @@ -248,7 +248,7 @@ async fn run_test(resource: RcStr) -> Result> { let module_rules = ModuleRule::new( conditions, vec![ModuleRuleEffect::ExtendEcmascriptTransforms { - prepend: Vc::cell(vec![ + prepend: ResolvedVc::cell(vec![ EcmascriptInputTransform::Plugin(Vc::cell(Box::new( EmotionTransformer::new(&EmotionTransformConfig::default()) .expect("Should be able to create emotion transformer"), @@ -257,7 +257,7 @@ async fn run_test(resource: RcStr) -> Result> { StyledComponentsTransformer::new(&StyledComponentsTransformConfig::default()), ) as _)), ]), - append: Vc::cell(vec![]), + append: ResolvedVc::cell(vec![]), }], ); let asset_context: Vc> = Vc::upcast(ModuleAssetContext::new( @@ -265,7 +265,7 @@ async fn run_test(resource: RcStr) -> Result> { compile_time_info, ModuleOptionsContext { ecmascript: EcmascriptOptionsContext { - enable_jsx: Some(JsxTransformOptions::cell(JsxTransformOptions { + enable_jsx: Some(JsxTransformOptions::resolved_cell(JsxTransformOptions { development: true, ..Default::default() })), @@ -284,7 +284,7 @@ async fn run_test(resource: RcStr) -> Result> { }, ..Default::default() } - .cell(), + .resolved_cell(), )], module_rules: vec![module_rules], tree_shaking_mode: options.tree_shaking_mode, diff --git a/turbopack/crates/turbopack/src/evaluate_context.rs b/turbopack/crates/turbopack/src/evaluate_context.rs index 62abc6f7778a2..927d95a4421af 100644 --- a/turbopack/crates/turbopack/src/evaluate_context.rs +++ b/turbopack/crates/turbopack/src/evaluate_context.rs @@ -15,7 +15,7 @@ use turbopack_node::execution_context::ExecutionContext; use turbopack_resolve::resolve_options_context::ResolveOptionsContext; use crate::{ - module_options::{EcmascriptOptionsContext, ModuleOptionsContext}, + module_options::{EcmascriptOptionsContext, ModuleOptionsContext, TypescriptTransformOptions}, transition::TransitionOptions, ModuleAssetContext, }; @@ -103,7 +103,9 @@ pub async fn node_evaluate_asset_context( ModuleOptionsContext { tree_shaking_mode: Some(TreeShakingMode::ReexportsOnly), ecmascript: EcmascriptOptionsContext { - enable_typescript_transform: Some(Default::default()), + enable_typescript_transform: Some( + TypescriptTransformOptions::default().resolved_cell(), + ), ignore_dynamic_requests, ..Default::default() }, diff --git a/turbopack/crates/turbopack/src/graph/mod.rs b/turbopack/crates/turbopack/src/graph/mod.rs index 18d8e3fa1878d..dd1afba0bd13c 100644 --- a/turbopack/crates/turbopack/src/graph/mod.rs +++ b/turbopack/crates/turbopack/src/graph/mod.rs @@ -9,8 +9,8 @@ pub enum AggregatedGraph { Leaf(ResolvedVc>), Node { depth: usize, - content: HashSet>, - references: HashSet>, + content: HashSet>, + references: HashSet>, }, } @@ -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() } @@ -60,7 +60,7 @@ impl AggregatedGraph { let mut set = HashSet::new(); for item in references .iter() - .map(|&reference| aggregate_more(reference)) + .map(|&reference| aggregate_more(*reference)) .collect::>() .into_iter() { @@ -129,7 +129,7 @@ pub async fn aggregate(asset: Vc>) -> Result) -> Result> { +async fn aggregate_more(node: ResolvedVc) -> Result> { let node_data = node.await?; let depth = node_data.depth(); let mut in_progress = HashSet::new(); @@ -152,20 +152,20 @@ async fn aggregate_more(node: Vc) -> Result for valued_refs in valued_refs { let valued_refs = valued_refs.await?; for &reference in valued_refs.inner.iter() { - content.insert(*reference); + content.insert(reference); } for &reference in valued_refs.references.iter() { if content.contains(&reference) { continue; } - references.insert(*reference); + references.insert(reference); } for &reference in valued_refs.outer.iter() { if content.contains(&reference) { continue; } references.remove(&reference); - in_progress.insert(*reference); + in_progress.insert(reference); } } } @@ -187,8 +187,8 @@ struct AggregatedGraphsSet { #[turbo_tasks::value(shared)] pub enum AggregatedGraphNodeContent { - Asset(Vc>), - Children(HashSet>), + Asset(ResolvedVc>), + Children(HashSet>), } #[turbo_tasks::value(shared)] diff --git a/turbopack/crates/turbopack/src/lib.rs b/turbopack/crates/turbopack/src/lib.rs index c5c0d44330e53..5af7ce5fa0ca7 100644 --- a/turbopack/crates/turbopack/src/lib.rs +++ b/turbopack/crates/turbopack/src/lib.rs @@ -63,10 +63,8 @@ use turbopack_resolve::{resolve_options_context::ResolveOptionsContext, typescri use turbopack_static::StaticModuleAsset; use turbopack_wasm::{module_asset::WebAssemblyModuleAsset, source::WebAssemblySource}; -use self::{ - module_options::CustomModuleType, - transition::{Transition, TransitionOptions}, -}; +use self::transition::{Transition, TransitionOptions}; +use crate::module_options::CustomModuleType; #[turbo_tasks::function] async fn apply_module_type( @@ -107,7 +105,7 @@ async fn apply_module_type( source, Vc::upcast(context_for_module), *transforms, - *options, + **options, module_asset_context.compile_time_info(), ); match module_type { @@ -312,11 +310,11 @@ async fn apply_reexport_tree_shaking( #[turbo_tasks::value] #[derive(Debug)] pub struct ModuleAssetContext { - pub transitions: Vc, - pub compile_time_info: Vc, - pub module_options_context: Vc, - pub resolve_options_context: Vc, - pub layer: Vc, + pub transitions: ResolvedVc, + pub compile_time_info: ResolvedVc, + pub module_options_context: ResolvedVc, + pub resolve_options_context: ResolvedVc, + pub layer: ResolvedVc, transition: Option>>, /// Whether to replace external resolutions with CachedExternalModules. Used with /// ModuleOptionsContext.enable_externals_tracing to handle transitive external dependencies. @@ -327,11 +325,11 @@ pub struct ModuleAssetContext { impl ModuleAssetContext { #[turbo_tasks::function] pub fn new( - transitions: Vc, - compile_time_info: Vc, - module_options_context: Vc, - resolve_options_context: Vc, - layer: Vc, + transitions: ResolvedVc, + compile_time_info: ResolvedVc, + module_options_context: ResolvedVc, + resolve_options_context: ResolvedVc, + layer: ResolvedVc, ) -> Vc { Self::cell(ModuleAssetContext { transitions, @@ -346,11 +344,11 @@ impl ModuleAssetContext { #[turbo_tasks::function] pub fn new_transition( - transitions: Vc, - compile_time_info: Vc, - module_options_context: Vc, - resolve_options_context: Vc, - layer: Vc, + transitions: ResolvedVc, + compile_time_info: ResolvedVc, + module_options_context: ResolvedVc, + resolve_options_context: ResolvedVc, + layer: ResolvedVc, transition: ResolvedVc>, ) -> Vc { Self::cell(ModuleAssetContext { @@ -366,11 +364,11 @@ impl ModuleAssetContext { #[turbo_tasks::function] fn new_without_replace_externals( - transitions: Vc, - compile_time_info: Vc, - module_options_context: Vc, - resolve_options_context: Vc, - layer: Vc, + transitions: ResolvedVc, + compile_time_info: ResolvedVc, + module_options_context: ResolvedVc, + resolve_options_context: ResolvedVc, + layer: ResolvedVc, ) -> Vc { Self::cell(ModuleAssetContext { transitions, @@ -385,12 +383,12 @@ impl ModuleAssetContext { #[turbo_tasks::function] pub fn module_options_context(&self) -> Vc { - self.module_options_context + *self.module_options_context } #[turbo_tasks::function] pub fn resolve_options_context(&self) -> Vc { - self.resolve_options_context + *self.resolve_options_context } #[turbo_tasks::function] @@ -414,11 +412,11 @@ impl ModuleAssetContext { .await?; Ok(ModuleAssetContext::new( - this.transitions, - this.compile_time_info, - this.module_options_context, + *this.transitions, + *this.compile_time_info, + *this.module_options_context, resolve_options_context, - this.layer, + *this.layer, )) } @@ -563,7 +561,7 @@ async fn process_default_internal( transforms, options, }) => Some(ModuleType::Ecmascript { - transforms: prepend.extend(transforms).extend(*append), + transforms: prepend.extend(transforms).extend(**append), options, }), Some(ModuleType::Typescript { @@ -572,7 +570,7 @@ async fn process_default_internal( analyze_types, options, }) => Some(ModuleType::Typescript { - transforms: prepend.extend(transforms).extend(*append), + transforms: prepend.extend(transforms).extend(**append), tsx, analyze_types, options, @@ -633,12 +631,12 @@ async fn process_default_internal( impl AssetContext for ModuleAssetContext { #[turbo_tasks::function] fn compile_time_info(&self) -> Vc { - self.compile_time_info + *self.compile_time_info } #[turbo_tasks::function] fn layer(&self) -> Vc { - self.layer + *self.layer } #[turbo_tasks::function] @@ -656,7 +654,7 @@ impl AssetContext for ModuleAssetContext { // TODO move `apply_commonjs/esm_resolve_options` etc. to here Ok(resolve_options( origin_path.parent().resolve().await?, - module_asset_context.await?.resolve_options_context, + *module_asset_context.await?.resolve_options_context, )) } @@ -747,21 +745,21 @@ impl AssetContext for ModuleAssetContext { Ok( if let Some(transition) = self.transitions.await?.get_named(transition) { Vc::upcast(ModuleAssetContext::new_transition( - self.transitions, - self.compile_time_info, - self.module_options_context, - self.resolve_options_context, - self.layer, - transition, + *self.transitions, + *self.compile_time_info, + *self.module_options_context, + *self.resolve_options_context, + *self.layer, + *transition, )) } else { // TODO report issue Vc::upcast(ModuleAssetContext::new( - self.transitions, - self.compile_time_info, - self.module_options_context, - self.resolve_options_context, - self.layer, + *self.transitions, + *self.compile_time_info, + *self.module_options_context, + *self.resolve_options_context, + *self.layer, )) }, ) @@ -804,10 +802,10 @@ async fn emit_aggregated_assets( output_dir: Vc, ) -> Result> { Ok(match &*aggregated.content().await? { - AggregatedGraphNodeContent::Asset(asset) => emit_asset_into_dir(*asset, output_dir), + AggregatedGraphNodeContent::Asset(asset) => emit_asset_into_dir(**asset, output_dir), AggregatedGraphNodeContent::Children(children) => { for aggregated in children { - emit_aggregated_assets(*aggregated, output_dir).await?; + emit_aggregated_assets(**aggregated, output_dir).await?; } Completion::new() } @@ -840,15 +838,14 @@ struct ReferencesList { } #[turbo_tasks::function] -async fn compute_back_references(aggregated: Vc) -> Result> { +async fn compute_back_references( + aggregated: ResolvedVc, +) -> Result> { Ok(match &*aggregated.content().await? { &AggregatedGraphNodeContent::Asset(asset) => { let mut referenced_by = HashMap::new(); - for reference in asset.references().await?.iter() { - referenced_by.insert( - reference.to_resolved().await?, - [asset].into_iter().collect(), - ); + for &reference in asset.references().await?.iter() { + referenced_by.insert(reference, [*asset].into_iter().collect()); } ReferencesList { referenced_by }.into() } @@ -857,7 +854,7 @@ async fn compute_back_references(aggregated: Vc) -> Result>, OutputAssetSet>::new(); let lists = children .iter() - .map(|child| compute_back_references(*child)) + .map(|child| compute_back_references(**child)) .collect::>(); for list in lists { for (key, values) in list.await?.referenced_by.iter() { diff --git a/turbopack/crates/turbopack/src/module_options/mod.rs b/turbopack/crates/turbopack/src/module_options/mod.rs index ab29f0fc2f4c0..115c913ac1d1a 100644 --- a/turbopack/crates/turbopack/src/module_options/mod.rs +++ b/turbopack/crates/turbopack/src/module_options/mod.rs @@ -98,7 +98,7 @@ impl ModuleOptions { if condition.matches(&path_value).await? { return Ok(ModuleOptions::new( path, - *new_context, + **new_context, resolve_options_context, )); } @@ -132,7 +132,7 @@ impl ModuleOptions { refresh, ..Default::default() }; - let ecmascript_options_vc = ecmascript_options.cell(); + let ecmascript_options_vc = ecmascript_options.resolved_cell(); if let Some(env) = preset_env_versions { transforms.push(EcmascriptInputTransform::PresetEnv( @@ -234,7 +234,7 @@ impl ModuleOptions { specified_module_type: SpecifiedModuleType::EcmaScript, ..ecmascript_options } - .into(), + .resolved_cell(), })], ), ModuleRule::new_all( @@ -245,7 +245,7 @@ impl ModuleOptions { specified_module_type: SpecifiedModuleType::CommonJs, ..ecmascript_options } - .into(), + .resolved_cell(), })], ), ModuleRule::new_all( @@ -276,7 +276,7 @@ impl ModuleOptions { specified_module_type: SpecifiedModuleType::EcmaScript, ..ecmascript_options } - .into(), + .resolved_cell(), })], ), ModuleRule::new_all( @@ -289,7 +289,7 @@ impl ModuleOptions { specified_module_type: SpecifiedModuleType::EcmaScript, ..ecmascript_options } - .into(), + .resolved_cell(), })], ), ModuleRule::new_all( @@ -302,7 +302,7 @@ impl ModuleOptions { specified_module_type: SpecifiedModuleType::CommonJs, ..ecmascript_options } - .into(), + .resolved_cell(), })], ), ModuleRule::new_all( @@ -315,7 +315,7 @@ impl ModuleOptions { specified_module_type: SpecifiedModuleType::CommonJs, ..ecmascript_options } - .into(), + .resolved_cell(), })], ), ModuleRule::new( @@ -410,7 +410,7 @@ impl ModuleOptions { rules.push(ModuleRule::new( RuleCondition::ResourcePathEndsWith(".css".to_string()), - vec![ModuleRuleEffect::SourceTransforms(Vc::cell(vec![ + vec![ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![ Vc::upcast(PostCssTransform::new( node_evaluate_asset_context( *execution_context, @@ -501,7 +501,9 @@ impl ModuleOptions { (None, None, false) }; - let mdx_options = &*enable_mdx_rs.unwrap_or(Default::default()).await?; + let mdx_options = &*enable_mdx_rs + .unwrap_or_else(|| MdxTransformOptions::default().resolved_cell()) + .await?; let mdx_transform_options = (MdxTransformOptions { development: Some(development), @@ -517,7 +519,7 @@ impl ModuleOptions { RuleCondition::ResourcePathEndsWith(".md".to_string()), RuleCondition::ResourcePathEndsWith(".mdx".to_string()), ]), - vec![ModuleRuleEffect::SourceTransforms(Vc::cell(vec![ + vec![ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![ Vc::upcast(MdxTransform::new(mdx_transform_options)), ]))], )); @@ -532,7 +534,7 @@ impl ModuleOptions { { package_import_map_from_import_mapping( "loader-runner".into(), - loader_runner_package, + *loader_runner_package, ) } else { package_import_map_from_context("loader-runner".into(), path) @@ -550,7 +552,7 @@ impl ModuleOptions { }, RuleCondition::not(RuleCondition::ResourceIsVirtualSource), ]), - vec![ModuleRuleEffect::SourceTransforms(Vc::cell(vec![ + vec![ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![ Vc::upcast(WebpackLoaders::new( node_evaluate_asset_context( *execution_context, @@ -560,7 +562,7 @@ impl ModuleOptions { false, ), *execution_context, - rule.loaders, + *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 b185780eb5032..a92f8d77129ff 100644 --- a/turbopack/crates/turbopack/src/module_options/module_options_context.rs +++ b/turbopack/crates/turbopack/src/module_options/module_options_context.rs @@ -16,7 +16,7 @@ use super::ModuleRule; #[derive(Clone, PartialEq, Eq, Debug, TraceRawVcs, Serialize, Deserialize)] pub struct LoaderRuleItem { - pub loaders: Vc, + pub loaders: ResolvedVc, pub rename_as: Option, } @@ -26,13 +26,13 @@ pub struct WebpackRules(FxIndexMap); #[derive(Default)] #[turbo_tasks::value(transparent)] -pub struct OptionWebpackRules(Option>); +pub struct OptionWebpackRules(Option>); #[turbo_tasks::value(shared)] #[derive(Clone, Debug)] pub struct WebpackLoadersOptions { - pub rules: Vc, - pub loader_runner_package: Option>, + pub rules: ResolvedVc, + pub loader_runner_package: Option>, } /// The kind of decorators transform to use. @@ -113,12 +113,12 @@ pub struct ModuleOptionsContext { pub ecmascript: EcmascriptOptionsContext, pub css: CssOptionsContext, - pub enable_postcss_transform: Option>, - pub enable_webpack_loaders: Option>, + pub enable_postcss_transform: Option>, + pub enable_webpack_loaders: Option>, // [Note]: currently mdx, and mdx_rs have different configuration entrypoint from next.config.js, // however we might want to unify them in the future. pub enable_mdx: bool, - pub enable_mdx_rs: Option>, + pub enable_mdx_rs: Option>, pub preset_env_versions: Option>, pub execution_context: Option>, @@ -130,13 +130,13 @@ pub struct ModuleOptionsContext { /// /// The filepath is the directory from which the bundled files will require the externals at /// runtime. - pub enable_externals_tracing: Option>, + pub enable_externals_tracing: Option>, /// Custom rules to be applied after all default rules. pub module_rules: Vec, /// A list of rules to use a different module option context for certain /// context paths. The first matching is used. - pub rules: Vec<(ContextCondition, Vc)>, + pub rules: Vec<(ContextCondition, ResolvedVc)>, pub placeholder_for_future_extensions: (), } @@ -145,11 +145,11 @@ pub struct ModuleOptionsContext { #[serde(default)] pub struct EcmascriptOptionsContext { pub enable_typeof_window_inlining: Option, - pub enable_jsx: Option>, + pub enable_jsx: Option>, /// Follow type references and resolve declaration files in additional to /// normal resolution. pub enable_types: bool, - pub enable_typescript_transform: Option>, + pub enable_typescript_transform: Option>, pub enable_decorators: Option>, pub esm_url_rewrite_behavior: Option, /// References to externals from ESM imports should use `import()` and make diff --git a/turbopack/crates/turbopack/src/module_options/module_rule.rs b/turbopack/crates/turbopack/src/module_options/module_rule.rs index 6a9e41046949a..8fd7ea7081398 100644 --- a/turbopack/crates/turbopack/src/module_options/module_rule.rs +++ b/turbopack/crates/turbopack/src/module_options/module_rule.rs @@ -1,6 +1,6 @@ use anyhow::Result; use serde::{Deserialize, Serialize}; -use turbo_tasks::{trace::TraceRawVcs, Vc}; +use turbo_tasks::{trace::TraceRawVcs, ResolvedVc, Vc}; use turbo_tasks_fs::FileSystemPath; use turbopack_core::{ reference_type::ReferenceType, source::Source, source_transform::SourceTransforms, @@ -69,10 +69,10 @@ pub enum ModuleRuleEffect { /// transforms. First argument will prepend the existing transforms, and /// the second argument will append the new transforms. ExtendEcmascriptTransforms { - prepend: Vc, - append: Vc, + prepend: ResolvedVc, + append: ResolvedVc, }, - SourceTransforms(Vc), + SourceTransforms(ResolvedVc), } #[turbo_tasks::value(serialization = "auto_for_input", shared)] @@ -81,7 +81,7 @@ pub enum ModuleType { Ecmascript { transforms: Vc, #[turbo_tasks(trace_ignore)] - options: Vc, + options: ResolvedVc, }, Typescript { transforms: Vc, @@ -90,12 +90,12 @@ pub enum ModuleType { // follow references to imported types. analyze_types: bool, #[turbo_tasks(trace_ignore)] - options: Vc, + options: ResolvedVc, }, TypescriptDeclaration { transforms: Vc, #[turbo_tasks(trace_ignore)] - options: Vc, + options: ResolvedVc, }, Json, Raw, @@ -108,5 +108,5 @@ pub enum ModuleType { WebAssembly { source_ty: WebAssemblySourceType, }, - Custom(Vc>), + Custom(ResolvedVc>), } diff --git a/turbopack/crates/turbopack/src/rebase/mod.rs b/turbopack/crates/turbopack/src/rebase/mod.rs index c334652fc9693..a6451f1b2e71a 100644 --- a/turbopack/crates/turbopack/src/rebase/mod.rs +++ b/turbopack/crates/turbopack/src/rebase/mod.rs @@ -16,18 +16,18 @@ use turbopack_core::{ #[turbo_tasks::value] #[derive(Hash)] pub struct RebasedAsset { - source: Vc>, - input_dir: Vc, - output_dir: Vc, + source: ResolvedVc>, + input_dir: ResolvedVc, + output_dir: ResolvedVc, } #[turbo_tasks::value_impl] impl RebasedAsset { #[turbo_tasks::function] pub fn new( - source: Vc>, - input_dir: Vc, - output_dir: Vc, + source: ResolvedVc>, + input_dir: ResolvedVc, + output_dir: ResolvedVc, ) -> Vc { Self::cell(RebasedAsset { source, @@ -43,20 +43,20 @@ impl OutputAsset for RebasedAsset { fn ident(&self) -> Vc { AssetIdent::from_path(FileSystemPath::rebase( self.source.ident().path(), - self.input_dir, - self.output_dir, + *self.input_dir, + *self.output_dir, )) } #[turbo_tasks::function] async fn references(&self) -> Result> { let mut references = Vec::new(); - for &module in referenced_modules_and_affecting_sources(self.source) + for &module in referenced_modules_and_affecting_sources(*self.source) .await? .iter() { references.push(ResolvedVc::upcast( - RebasedAsset::new(*module, self.input_dir, self.output_dir) + RebasedAsset::new(*module, *self.input_dir, *self.output_dir) .to_resolved() .await?, )); diff --git a/turbopack/crates/turbopack/src/transition/context_transition.rs b/turbopack/crates/turbopack/src/transition/context_transition.rs index 111423d70380e..3fc3a0ba82553 100644 --- a/turbopack/crates/turbopack/src/transition/context_transition.rs +++ b/turbopack/crates/turbopack/src/transition/context_transition.rs @@ -1,4 +1,4 @@ -use turbo_tasks::{RcStr, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, Vc}; use turbopack_core::compile_time_info::CompileTimeInfo; use turbopack_resolve::resolve_options_context::ResolveOptionsContext; @@ -7,20 +7,20 @@ use crate::{module_options::ModuleOptionsContext, transition::Transition}; /// A transition that only affects the asset context. #[turbo_tasks::value(shared)] pub struct ContextTransition { - compile_time_info: Vc, - module_options_context: Vc, - resolve_options_context: Vc, - layer: Vc, + compile_time_info: ResolvedVc, + module_options_context: ResolvedVc, + resolve_options_context: ResolvedVc, + layer: ResolvedVc, } #[turbo_tasks::value_impl] impl ContextTransition { #[turbo_tasks::function] pub fn new( - compile_time_info: Vc, - module_options_context: Vc, - resolve_options_context: Vc, - layer: Vc, + compile_time_info: ResolvedVc, + module_options_context: ResolvedVc, + resolve_options_context: ResolvedVc, + layer: ResolvedVc, ) -> Vc { ContextTransition { module_options_context, @@ -39,12 +39,12 @@ impl Transition for ContextTransition { &self, _compile_time_info: Vc, ) -> Vc { - self.compile_time_info + *self.compile_time_info } #[turbo_tasks::function] fn process_layer(&self, _layer: Vc) -> Vc { - self.layer + *self.layer } #[turbo_tasks::function] @@ -52,7 +52,7 @@ impl Transition for ContextTransition { &self, _context: Vc, ) -> Vc { - self.module_options_context + *self.module_options_context } #[turbo_tasks::function] @@ -60,6 +60,6 @@ impl Transition for ContextTransition { &self, _context: Vc, ) -> Vc { - self.resolve_options_context + *self.resolve_options_context } } diff --git a/turbopack/crates/turbopack/src/transition/full_context_transition.rs b/turbopack/crates/turbopack/src/transition/full_context_transition.rs index a1a183bb6b566..4c7d20d3c561a 100644 --- a/turbopack/crates/turbopack/src/transition/full_context_transition.rs +++ b/turbopack/crates/turbopack/src/transition/full_context_transition.rs @@ -1,17 +1,17 @@ -use turbo_tasks::Vc; +use turbo_tasks::{ResolvedVc, Vc}; use crate::{transition::Transition, ModuleAssetContext}; /// A transition that only affects the asset context. #[turbo_tasks::value(shared)] pub struct FullContextTransition { - module_context: Vc, + module_context: ResolvedVc, } #[turbo_tasks::value_impl] impl FullContextTransition { #[turbo_tasks::function] - pub fn new(module_context: Vc) -> Vc { + pub fn new(module_context: ResolvedVc) -> Vc { FullContextTransition { module_context }.cell() } } @@ -23,6 +23,6 @@ impl Transition for FullContextTransition { &self, _module_asset_context: Vc, ) -> Vc { - self.module_context + *self.module_context } } diff --git a/turbopack/crates/turbopack/src/transition/mod.rs b/turbopack/crates/turbopack/src/transition/mod.rs index b5c9849156f83..3aef90ec89133 100644 --- a/turbopack/crates/turbopack/src/transition/mod.rs +++ b/turbopack/crates/turbopack/src/transition/mod.rs @@ -6,7 +6,7 @@ use std::collections::HashMap; use anyhow::Result; pub use context_transition::ContextTransition; pub use full_context_transition::FullContextTransition; -use turbo_tasks::{RcStr, Value, ValueDefault, Vc}; +use turbo_tasks::{RcStr, ResolvedVc, Value, ValueDefault, Vc}; use turbopack_core::{ compile_time_info::CompileTimeInfo, context::ProcessResult, module::Module, reference_type::ReferenceType, source::Source, @@ -67,14 +67,14 @@ pub trait Transition { ) -> Result> { let module_asset_context = module_asset_context.await?; let compile_time_info = - self.process_compile_time_info(module_asset_context.compile_time_info); + self.process_compile_time_info(*module_asset_context.compile_time_info); let module_options_context = - self.process_module_options_context(module_asset_context.module_options_context); + self.process_module_options_context(*module_asset_context.module_options_context); let resolve_options_context = - self.process_resolve_options_context(module_asset_context.resolve_options_context); - let layer = self.process_layer(module_asset_context.layer); + self.process_resolve_options_context(*module_asset_context.resolve_options_context); + let layer = self.process_layer(*module_asset_context.layer); let module_asset_context = ModuleAssetContext::new( - module_asset_context.transitions, + *module_asset_context.transitions, compile_time_info, module_options_context, resolve_options_context, @@ -111,7 +111,7 @@ pub trait Transition { #[turbo_tasks::value(shared)] #[derive(Default)] pub struct TransitionOptions { - pub named_transitions: HashMap>>, + pub named_transitions: HashMap>>, pub transition_rules: Vec, pub placeholder_for_future_extensions: (), } @@ -125,7 +125,7 @@ impl ValueDefault for TransitionOptions { } impl TransitionOptions { - pub fn get_named(&self, name: RcStr) -> Option>> { + pub fn get_named(&self, name: RcStr) -> Option>> { self.named_transitions.get(&name).copied() } diff --git a/turbopack/crates/turbopack/src/unsupported_sass.rs b/turbopack/crates/turbopack/src/unsupported_sass.rs index 52ead7bfe6d7a..5f6d6d0e310ca 100644 --- a/turbopack/crates/turbopack/src/unsupported_sass.rs +++ b/turbopack/crates/turbopack/src/unsupported_sass.rs @@ -1,7 +1,7 @@ //! TODO(WEB-741) Remove this file once Sass is supported. use anyhow::Result; -use turbo_tasks::{Value, Vc}; +use turbo_tasks::{ResolvedVc, Value, Vc}; use turbo_tasks_fs::{glob::Glob, FileSystemPath}; use turbopack_core::{ issue::{Issue, IssueExt, IssueSeverity, IssueStage, OptionStyledString, StyledString}, @@ -16,13 +16,13 @@ use turbopack_core::{ /// Resolve plugins that warns when importing a sass file. #[turbo_tasks::value] pub(crate) struct UnsupportedSassResolvePlugin { - root: Vc, + root: ResolvedVc, } #[turbo_tasks::value_impl] impl UnsupportedSassResolvePlugin { #[turbo_tasks::function] - pub fn new(root: Vc) -> Vc { + pub fn new(root: ResolvedVc) -> Vc { UnsupportedSassResolvePlugin { root }.cell() } } @@ -37,10 +37,10 @@ impl AfterResolvePlugin for UnsupportedSassResolvePlugin { #[turbo_tasks::function] async fn after_resolve( &self, - fs_path: Vc, - lookup_path: Vc, + fs_path: ResolvedVc, + lookup_path: ResolvedVc, _reference_type: Value, - request: Vc, + request: ResolvedVc, ) -> Result> { let extension = fs_path.extension().await?; if ["sass", "scss"].iter().any(|ext| *ext == &**extension) { @@ -58,8 +58,8 @@ impl AfterResolvePlugin for UnsupportedSassResolvePlugin { #[turbo_tasks::value(shared)] struct UnsupportedSassModuleIssue { - file_path: Vc, - request: Vc, + file_path: ResolvedVc, + request: ResolvedVc, } #[turbo_tasks::value_impl] @@ -83,7 +83,7 @@ impl Issue for UnsupportedSassModuleIssue { #[turbo_tasks::function] fn file_path(&self) -> Vc { - self.file_path + *self.file_path } #[turbo_tasks::function]