diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-08-07 09:43:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-07 07:43:05 +0000 |
commit | 04473c04ed59cc2a987af3405074591fbc1341a4 (patch) | |
tree | 50d56d1990328a6d32627e74ef73514525d78fde /cli/lsp/jsr.rs | |
parent | 4fa8869f2487749a9f190cb3047f4f3e6d571f27 (diff) |
fix(compile): support workspace members importing other members (#24909)
Diffstat (limited to 'cli/lsp/jsr.rs')
-rw-r--r-- | cli/lsp/jsr.rs | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/cli/lsp/jsr.rs b/cli/lsp/jsr.rs index b02e01fb6..9ffcdf9e6 100644 --- a/cli/lsp/jsr.rs +++ b/cli/lsp/jsr.rs @@ -20,7 +20,6 @@ use deno_semver::package::PackageNv; use deno_semver::package::PackageReq; use deno_semver::Version; use serde::Deserialize; -use std::borrow::Cow; use std::collections::HashMap; use std::sync::Arc; @@ -157,7 +156,7 @@ impl JsrCacheResolver { let maybe_nv = self.req_to_nv(&req); let nv = maybe_nv.as_ref()?; let info = self.package_version_info(nv)?; - let path = info.export(&normalize_export_name(req_ref.sub_path()))?; + let path = info.export(&req_ref.export_name())?; if let Some(workspace_scope) = self.workspace_scope_by_name.get(&nv.name) { workspace_scope.join(path).ok() } else { @@ -267,30 +266,6 @@ fn read_cached_url( .ok()? } -// TODO(nayeemrmn): This is duplicated from a private function in deno_graph -// 0.65.1. Make it public or cleanup otherwise. -fn normalize_export_name(sub_path: Option<&str>) -> Cow<str> { - let Some(sub_path) = sub_path else { - return Cow::Borrowed("."); - }; - if sub_path.is_empty() || matches!(sub_path, "/" | ".") { - Cow::Borrowed(".") - } else { - let sub_path = if sub_path.starts_with('/') { - Cow::Owned(format!(".{}", sub_path)) - } else if !sub_path.starts_with("./") { - Cow::Owned(format!("./{}", sub_path)) - } else { - Cow::Borrowed(sub_path) - }; - if let Some(prefix) = sub_path.strip_suffix('/') { - Cow::Owned(prefix.to_string()) - } else { - sub_path - } - } -} - #[derive(Debug)] pub struct CliJsrSearchApi { file_fetcher: Arc<FileFetcher>, |