From 1ec642539f8d1fd0d2581f76c2d7c77baa148552 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 4 Dec 2023 19:46:26 -0500 Subject: [PATCH] refactor: upgrade to deno_graph 0.62 --- Cargo.lock | 36 +++++------------------------------- rs-lib/Cargo.toml | 2 +- rs-lib/src/lib.rs | 22 ++++++++++++---------- 3 files changed, 18 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3cadc67..b5c6115 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -250,7 +250,6 @@ dependencies = [ "swc_ecma_ast", "swc_ecma_codegen", "swc_ecma_codegen_macros", - "swc_ecma_dep_graph", "swc_ecma_loader", "swc_ecma_parser", "swc_ecma_transforms_base", @@ -281,7 +280,7 @@ dependencies = [ "deno_graph", "escape8259", "futures", - "import_map 0.18.0", + "import_map", "parking_lot 0.11.2", "pretty_assertions", "tokio", @@ -305,9 +304,9 @@ dependencies = [ [[package]] name = "deno_graph" -version = "0.61.0" +version = "0.62.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bd6700dd3cec2a7763760168c952cc632246a1ae0fc52d6f297e2802b994e69" +checksum = "2b0c15558cd72b534064bf7ae07e0fc99e0693915a4552f67558cc0b2b09c287" dependencies = [ "anyhow", "async-trait", @@ -315,8 +314,9 @@ dependencies = [ "deno_ast", "deno_semver", "futures", - "import_map 0.15.0", + "import_map", "indexmap 2.1.0", + "log", "monch", "once_cell", "parking_lot 0.12.1", @@ -583,20 +583,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" -[[package]] -name = "import_map" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632089ec08bd62e807311104122fb26d5c911ab172e2b9864be154a575979e29" -dependencies = [ - "cfg-if", - "indexmap 1.9.3", - "log", - "serde", - "serde_json", - "url", -] - [[package]] name = "import_map" version = "0.18.0" @@ -1423,18 +1409,6 @@ dependencies = [ "syn 2.0.39", ] -[[package]] -name = "swc_ecma_dep_graph" -version = "0.113.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59fc6ac1a84afe910182dcda33d70a16545e6058529d51afb63bd6be8764370f" -dependencies = [ - "swc_atoms", - "swc_common", - "swc_ecma_ast", - "swc_ecma_visit", -] - [[package]] name = "swc_ecma_loader" version = "0.45.10" diff --git a/rs-lib/Cargo.toml b/rs-lib/Cargo.toml index 575eabe..a67c12e 100644 --- a/rs-lib/Cargo.toml +++ b/rs-lib/Cargo.toml @@ -12,7 +12,7 @@ license = "MIT" anyhow = "1.0.44" base64 = "0.13.0" deno_ast = { version = "0.31.5", features = ["bundler", "codegen", "module_specifier", "proposal", "react", "sourcemap", "transforms", "typescript", "visit", "transpiling"] } -deno_graph = "0.61.0" +deno_graph = "0.62.0" escape8259 = "0.5.2" futures = "0.3.17" import_map = "0.18.0" diff --git a/rs-lib/src/lib.rs b/rs-lib/src/lib.rs index 74f647f..2452cbb 100644 --- a/rs-lib/src/lib.rs +++ b/rs-lib/src/lib.rs @@ -12,6 +12,7 @@ use deno_graph::CapturingModuleAnalyzer; use deno_graph::GraphKind; use deno_graph::ModuleGraph; use deno_graph::ParsedSourceStore; +use deno_graph::Range; use import_map::ImportMap; use std::collections::HashMap; use url::Url; @@ -163,24 +164,25 @@ impl deno_graph::source::Resolver for ImportMapResolver { fn resolve( &self, specifier: &str, - referrer: &ModuleSpecifier, + referrer_range: &Range, _mode: deno_graph::source::ResolutionMode, ) -> Result { let maybe_import_map = &self.0; - let maybe_import_map_err = match maybe_import_map - .as_ref() - .map(|import_map| import_map.resolve(specifier, referrer)) - { - Some(Ok(value)) => return Ok(value), - Some(Err(err)) => Some(err), - None => None, - }; + let maybe_import_map_err = + match maybe_import_map.as_ref().map(|import_map| { + import_map.resolve(specifier, &referrer_range.specifier) + }) { + Some(Ok(value)) => return Ok(value), + Some(Err(err)) => Some(err), + None => None, + }; if let Some(err) = maybe_import_map_err { Err(ResolveError::Other(err.into())) } else { - deno_graph::resolve_import(specifier, referrer).map_err(|err| err.into()) + deno_graph::resolve_import(specifier, &referrer_range.specifier) + .map_err(|err| err.into()) } } }