Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: upgrade to deno_graph 0.62 #152

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Up @@ -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"
Expand Down
22 changes: 12 additions & 10 deletions rs-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
}
}
}