Skip to content

Commit

Permalink
refactor: upgrade to deno_graph 0.62 (#152)
Browse files Browse the repository at this point in the history
dsherret authored Dec 5, 2023
1 parent 10e604f commit cd6282b
Showing 3 changed files with 18 additions and 42 deletions.
36 changes: 5 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rs-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
22 changes: 12 additions & 10 deletions rs-lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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<ModuleSpecifier, ResolveError> {
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())
}
}
}

0 comments on commit cd6282b

Please sign in to comment.