summaryrefslogtreecommitdiff
path: root/cli/node.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-11-14 15:24:25 -0500
committerGitHub <noreply@github.com>2024-11-14 15:24:25 -0500
commit617350e79c58b6e01984e3d7c7436d243d0e5cff (patch)
treedadb3c7675d1d49952a30c525bbc6ee3086a78e3 /cli/node.rs
parentde34c7ed29bcce8b46a65f5effe45090b8493ba5 (diff)
refactor(resolver): move more resolution code into deno_resolver (#26873)
Follow-up to cjs refactor. This moves most of the resolution code into the deno_resolver crate. Still pending is the npm resolution code.
Diffstat (limited to 'cli/node.rs')
-rw-r--r--cli/node.rs13
1 files changed, 3 insertions, 10 deletions
diff --git a/cli/node.rs b/cli/node.rs
index 8235745a9..bc39cdbde 100644
--- a/cli/node.rs
+++ b/cli/node.rs
@@ -7,8 +7,6 @@ use deno_ast::MediaType;
use deno_ast::ModuleSpecifier;
use deno_core::error::AnyError;
use deno_graph::ParsedSourceStore;
-use deno_path_util::url_from_file_path;
-use deno_path_util::url_to_file_path;
use deno_runtime::deno_fs;
use deno_runtime::deno_node::DenoFsNodeResolverEnv;
use node_resolver::analyze::CjsAnalysis as ExtNodeCjsAnalysis;
@@ -22,7 +20,6 @@ use crate::cache::CacheDBHash;
use crate::cache::NodeAnalysisCache;
use crate::cache::ParsedSourceCache;
use crate::resolver::CjsTracker;
-use crate::util::fs::canonicalize_path_maybe_not_exists_with_fs;
pub type CliNodeCodeTranslator =
NodeCodeTranslator<CliCjsCodeAnalyzer, DenoFsNodeResolverEnv>;
@@ -37,13 +34,9 @@ pub fn resolve_specifier_into_node_modules(
specifier: &ModuleSpecifier,
fs: &dyn deno_fs::FileSystem,
) -> ModuleSpecifier {
- url_to_file_path(specifier)
- .ok()
- // this path might not exist at the time the graph is being created
- // because the node_modules folder might not yet exist
- .and_then(|path| canonicalize_path_maybe_not_exists_with_fs(&path, fs).ok())
- .and_then(|path| url_from_file_path(&path).ok())
- .unwrap_or_else(|| specifier.clone())
+ node_resolver::resolve_specifier_into_node_modules(specifier, &|path| {
+ fs.realpath_sync(path).map_err(|err| err.into_io_error())
+ })
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]