diff --git a/cli/factory.rs b/cli/factory.rs index aa82165ce3063e..fcb4b9f45fef99 100644 --- a/cli/factory.rs +++ b/cli/factory.rs @@ -673,7 +673,7 @@ impl CliFactory { self.pkg_json_resolver().clone(), self.sys(), node_resolver::ConditionsFromResolutionMode::new( - &node_resolver::deno_conditions_from_resolution_mode, + node_resolver::deno_conditions_from_resolution_mode, ), ))) } diff --git a/cli/lsp/resolver.rs b/cli/lsp/resolver.rs index 04d355f74e83dc..0eeca5b538da22 100644 --- a/cli/lsp/resolver.rs +++ b/cli/lsp/resolver.rs @@ -784,7 +784,7 @@ impl<'a> ResolverFactory<'a> { self.pkg_json_resolver.clone(), self.sys.clone(), node_resolver::ConditionsFromResolutionMode::new( - &node_resolver::deno_conditions_from_resolution_mode, + node_resolver::deno_conditions_from_resolution_mode, ), ))) }) diff --git a/cli/standalone/mod.rs b/cli/standalone/mod.rs index 7906a101b1aac8..19259d6c76b84d 100644 --- a/cli/standalone/mod.rs +++ b/cli/standalone/mod.rs @@ -834,7 +834,7 @@ pub async fn run( pkg_json_resolver.clone(), sys.clone(), node_resolver::ConditionsFromResolutionMode::new( - &node_resolver::deno_conditions_from_resolution_mode, + node_resolver::deno_conditions_from_resolution_mode, ), )); let cjs_tracker = Arc::new(CjsTracker::new( diff --git a/resolvers/node/resolution.rs b/resolvers/node/resolution.rs index b286d413b5fa7a..668c15ef0ec1ad 100644 --- a/resolvers/node/resolution.rs +++ b/resolvers/node/resolution.rs @@ -1,10 +1,10 @@ // Copyright 2018-2025 the Deno authors. MIT license. +use crate::sync::MaybeArc; use std::borrow::Cow; use std::fmt::Debug; use std::path::Path; use std::path::PathBuf; -use std::sync::Arc; use anyhow::bail; use anyhow::Error as AnyError; @@ -66,7 +66,7 @@ pub fn deno_conditions_from_resolution_mode( } pub struct ConditionsFromResolutionMode { - pub func: Arc &'static [&'static str]>, + pub func: MaybeArc &'static [&'static str]>, } impl Debug for ConditionsFromResolutionMode { @@ -76,10 +76,10 @@ impl Debug for ConditionsFromResolutionMode { } impl ConditionsFromResolutionMode { - pub fn new( - func: Arc &'static [&'static str]>, - ) -> Self { - Self { func } + pub fn new(func: dyn Fn(ResolutionMode) -> &'static [&'static str]) -> Self { + Self { + func: MaybeArc::new(func), + } } }