diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-04-24 17:43:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-24 21:43:34 +0000 |
commit | f3284529f1689f1294929eb17c55ddf088f3d3bb (patch) | |
tree | 535046cd96db3a39719f3ca5408bb89d5d0387bf /cli | |
parent | 5a7414e16349d6872a94db38955bf89edf621c30 (diff) |
feat(jsr): support importing from jsr via HTTPS specifiers (except for type checking) (#23513)
Closes https://github.com/jsr-io/jsr/issues/322
Diffstat (limited to 'cli')
-rw-r--r-- | cli/Cargo.toml | 14 | ||||
-rw-r--r-- | cli/graph_util.rs | 4 | ||||
-rw-r--r-- | cli/jsr.rs | 3 | ||||
-rw-r--r-- | cli/lsp/diagnostics.rs | 3 | ||||
-rw-r--r-- | cli/lsp/documents.rs | 16 |
5 files changed, 28 insertions, 12 deletions
diff --git a/cli/Cargo.toml b/cli/Cargo.toml index ecad2c173..ebbfbdb93 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -66,17 +66,17 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposa deno_cache_dir = { workspace = true } deno_config = "=0.16.1" deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] } -deno_doc = { version = "=0.128.0", features = ["html"] } -deno_emit = "=0.40.0" -deno_graph = { version = "=0.73.1", features = ["tokio_executor"] } -deno_lint = { version = "=0.58.3", features = ["docs"] } +deno_doc = { version = "=0.128.1", features = ["html"] } +deno_emit = "=0.40.1" +deno_graph = { version = "=0.74.0", features = ["tokio_executor"] } +deno_lint = { version = "=0.58.4", features = ["docs"] } deno_lockfile.workspace = true -deno_npm = "=0.17.0" +deno_npm = "=0.18.0" deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting"] } deno_semver = "=0.5.4" deno_task_shell = "=0.16.0" deno_terminal.workspace = true -eszip = "=0.68.0" +eszip = "=0.68.2" napi_sym.workspace = true async-trait.workspace = true @@ -98,7 +98,7 @@ dotenvy = "0.15.7" dprint-plugin-json = "=0.19.2" dprint-plugin-jupyter = "=0.1.3" dprint-plugin-markdown = "=0.16.4" -dprint-plugin-typescript = "=0.90.3" +dprint-plugin-typescript = "=0.90.4" env_logger = "=0.10.0" fancy-regex = "=0.10.0" faster-hex.workspace = true diff --git a/cli/graph_util.rs b/cli/graph_util.rs index 8d78da3ed..ac7f8a365 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -611,7 +611,7 @@ impl ModuleGraphBuilder { graph.build_fast_check_type_graph( deno_graph::BuildFastCheckTypeGraphOptions { - jsr_url_provider: Some(&CliJsrUrlProvider), + jsr_url_provider: &CliJsrUrlProvider, fast_check_cache: fast_check_cache.as_ref().map(|c| c as _), fast_check_dts: false, module_parser: Some(&parser), @@ -969,7 +969,7 @@ pub fn format_range_with_colors(range: &deno_graph::Range) -> String { } #[derive(Debug, Default, Clone, Copy)] -struct CliJsrUrlProvider; +pub struct CliJsrUrlProvider; impl deno_graph::source::JsrUrlProvider for CliJsrUrlProvider { fn url(&self) -> &'static ModuleSpecifier { diff --git a/cli/jsr.rs b/cli/jsr.rs index 9a929982a..8b13f5893 100644 --- a/cli/jsr.rs +++ b/cli/jsr.rs @@ -304,6 +304,7 @@ fn partial_jsr_package_version_info_from_slice( .as_object_mut() .and_then(|o| o.remove("exports")) .unwrap_or_default(), - module_graph: None, + module_graph_1: None, + module_graph_2: None, }) } diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index 431cddeb6..b4422d493 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -1010,6 +1010,9 @@ impl DenoDiagnostic { } else { match err { ResolutionError::InvalidDowngrade { .. } => "invalid-downgrade", + ResolutionError::InvalidJsrHttpsTypesImport { .. } => { + "invalid-jsr-https-types-import" + } ResolutionError::InvalidLocalImport { .. } => { "invalid-local-import" } diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs index ac8a6c911..2de2a4406 100644 --- a/cli/lsp/documents.rs +++ b/cli/lsp/documents.rs @@ -12,6 +12,7 @@ use super::tsc::AssetDocument; use crate::args::package_json; use crate::cache::HttpCache; +use crate::graph_util::CliJsrUrlProvider; use crate::jsr::JsrCacheResolver; use crate::lsp::logging::lsp_warn; use crate::npm::CliNpmResolver; @@ -409,13 +410,22 @@ impl Document { .map(|(s, d)| { ( s.clone(), - d.with_new_resolver(s, Some(graph_resolver), Some(npm_resolver)), + d.with_new_resolver( + s, + &CliJsrUrlProvider, + Some(graph_resolver), + Some(npm_resolver), + ), ) }) .collect(), ); maybe_types_dependency = self.maybe_types_dependency.as_ref().map(|d| { - Arc::new(d.with_new_resolver(Some(graph_resolver), Some(npm_resolver))) + Arc::new(d.with_new_resolver( + &CliJsrUrlProvider, + Some(graph_resolver), + Some(npm_resolver), + )) }); maybe_parsed_source = self.maybe_parsed_source(); maybe_test_module_fut = self @@ -1409,6 +1419,7 @@ impl Documents { let graph_import = GraphImport::new( &referrer, imports, + &CliJsrUrlProvider, Some(graph_resolver), Some(npm_resolver), ); @@ -1745,6 +1756,7 @@ fn analyze_module( // use a null file system because there's no need to bother resolving // dynamic imports like import(`./dir/${something}`) in the LSP file_system: &deno_graph::source::NullFileSystem, + jsr_url_provider: &CliJsrUrlProvider, maybe_resolver: Some(resolver.as_graph_resolver()), maybe_npm_resolver: Some(resolver.as_graph_npm_resolver()), }, |