Skip to content

Commit

Permalink
fix: update deno_graph to fix importing config as JSON module (denola…
Browse files Browse the repository at this point in the history
…nd#15388)

Ref: denoland/deno_graph#166
  • Loading branch information
kitsonk committed Aug 9, 2022
1 parent 1f54d87 commit 1c2ec1f
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 77 deletions.
57 changes: 22 additions & 35 deletions Cargo.lock

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

18 changes: 9 additions & 9 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ deno_web = { version = "0.95.0", path = "../ext/web" }
deno_webgpu = { version = "0.65.0", path = "../ext/webgpu" }
deno_websocket = { version = "0.69.0", path = "../ext/websocket" }
deno_webstorage = { version = "0.59.0", path = "../ext/webstorage" }
regex = "=1.5.6"
serde = { version = "=1.0.139", features = ["derive"] }
regex = "=1.6.0"
serde = { version = "=1.0.141", features = ["derive"] }
zstd = '=0.11.1'

[target.'cfg(windows)'.build-dependencies]
Expand All @@ -48,9 +48,9 @@ winres = "=0.1.12"
[dependencies]
deno_ast = { version = "0.17.0", features = ["bundler", "cjs", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "transpiling", "typescript", "view", "visit"] }
deno_core = { version = "0.146.0", path = "../core" }
deno_doc = "0.38.0"
deno_emit = "0.4.0"
deno_graph = "0.29.0"
deno_doc = "0.40.0"
deno_emit = "0.5.0"
deno_graph = "0.30.0"
deno_lint = { version = "0.32.0", features = ["docs"] }
deno_runtime = { version = "0.72.0", path = "../runtime" }
deno_task_shell = "0.5.0"
Expand All @@ -69,8 +69,8 @@ dprint-plugin-markdown = "=0.14.0"
dprint-plugin-typescript = "=0.71.2"
encoding_rs = "=0.8.31"
env_logger = "=0.9.0"
eszip = "=0.22.0"
fancy-regex = "=0.9.0"
eszip = "=0.23.0"
fancy-regex = "=0.10.0"
http = "=0.2.6"
import_map = "=0.12.1"
indexmap = "1.8.1"
Expand All @@ -85,13 +85,13 @@ os_pipe = "=1.0.1"
percent-encoding = "=2.1.0"
pin-project = "1.0.11" # don't pin because they yank crates from cargo
rand = { version = "=0.8.5", features = ["small_rng"] }
regex = "=1.5.6"
regex = "=1.6.0"
ring = "=0.16.20"
rustyline = { version = "=10.0.0", default-features = false, features = ["custom-bindings"] }
rustyline-derive = "=0.7.0"
secure_tempfile = { version = "=3.3.0", package = "tempfile" } # different name to discourage use in tests
semver-parser = "=0.10.2"
serde = { version = "=1.0.139", features = ["derive"] }
serde = { version = "=1.0.141", features = ["derive"] }
serde_repr = "=0.1.8"
shell-escape = "=0.1.5"
text-size = "=1.1.0"
Expand Down
42 changes: 21 additions & 21 deletions cli/graph_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@ pub struct GraphData {
impl GraphData {
/// Store data from `graph` into `self`.
pub fn add_graph(&mut self, graph: &ModuleGraph, reload: bool) {
for graph_import in &graph.imports {
let mut dependencies = BTreeMap::new();
for (specifier, dependency) in &graph_import.dependencies {
if !matches!(dependency.maybe_type, Resolved::None) {
dependencies.insert(specifier.clone(), dependency.maybe_type.clone());
if let Resolved::Ok {
specifier, range, ..
} = &dependency.maybe_type
{
let entry = self.referrer_map.entry(specifier.clone());
entry.or_insert_with(|| range.clone());
}
}
}
self.modules.insert(
graph_import.referrer.clone(),
ModuleEntry::Configuration { dependencies },
);
self.configurations.insert(graph_import.referrer.clone());
}

for (specifier, result) in graph.specifiers() {
if !reload && self.modules.contains_key(&specifier) {
continue;
Expand All @@ -82,27 +103,6 @@ impl GraphData {
match result {
Ok((_, _, media_type)) => {
let module = graph.get(&specifier).unwrap();
if module.kind == ModuleKind::Synthetic {
let mut dependencies = BTreeMap::new();
for (specifier, dependency) in &module.dependencies {
if !matches!(dependency.maybe_type, Resolved::None) {
dependencies
.insert(specifier.clone(), dependency.maybe_type.clone());
if let Resolved::Ok {
specifier, range, ..
} = &dependency.maybe_type
{
let entry = self.referrer_map.entry(specifier.clone());
entry.or_insert_with(|| range.clone());
}
}
}
self.modules.insert(
module.specifier.clone(),
ModuleEntry::Configuration { dependencies },
);
self.configurations.insert(module.specifier.clone());
}
let code = match &module.maybe_source {
Some(source) => source.clone(),
None => continue,
Expand Down
12 changes: 6 additions & 6 deletions cli/lsp/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use deno_core::error::AnyError;
use deno_core::parking_lot::Mutex;
use deno_core::url;
use deno_core::ModuleSpecifier;
use deno_graph::Module;
use deno_graph::GraphImport;
use deno_graph::Resolved;
use once_cell::sync::Lazy;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -719,7 +719,7 @@ pub struct Documents {
file_system_docs: Arc<Mutex<FileSystemDocuments>>,
/// Any imports to the context supplied by configuration files. This is like
/// the imports into the a module graph in CLI.
imports: Arc<HashMap<ModuleSpecifier, Module>>,
imports: Arc<HashMap<ModuleSpecifier, GraphImport>>,
/// The optional import map that should be used when resolving dependencies.
maybe_import_map: Option<ImportMapResolver>,
/// The optional JSX resolver, which is used when JSX imports are configured.
Expand Down Expand Up @@ -1035,12 +1035,12 @@ impl Documents {
imports
.into_iter()
.map(|(referrer, dependencies)| {
let module = Module::new_from_type_imports(
let graph_import = GraphImport::new(
referrer.clone(),
dependencies,
self.get_maybe_resolver(),
);
(referrer, module)
(referrer, graph_import)
})
.collect()
} else {
Expand Down Expand Up @@ -1128,8 +1128,8 @@ impl Documents {
&self,
specifier: &str,
) -> Option<&deno_graph::Resolved> {
for module in self.imports.values() {
let maybe_dep = module.dependencies.get(specifier);
for graph_imports in self.imports.values() {
let maybe_dep = graph_imports.dependencies.get(specifier);
if maybe_dep.is_some() {
return maybe_dep.map(|d| &d.maybe_type);
}
Expand Down
3 changes: 3 additions & 0 deletions cli/tests/testdata/035_cached_only_flag.out
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
error: Specifier not found in cache: "https://127.0.0.1:4545/019_media_types.ts", --cached-only is specified.

Caused by:
Specifier not found in cache: "https://127.0.0.1:4545/019_media_types.ts", --cached-only is specified.
3 changes: 3 additions & 0 deletions cli/tests/testdata/052_no_remote_flag.out
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
error: A remote specifier was requested: "https://127.0.0.1:4545/019_media_types.ts", but --no-remote is specified.

Caused by:
A remote specifier was requested: "https://127.0.0.1:4545/019_media_types.ts", but --no-remote is specified.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@ Defined in [WILDCARD]/060_deno_doc_displays_all_overloads_in_details_view.ts:4:2

function test(options: object): void

Defined in [WILDCARD]/060_deno_doc_displays_all_overloads_in_details_view.ts:5:2

function test(name: string | object, fn?: Function): void

2 changes: 1 addition & 1 deletion ops/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ once_cell = "1.10.0"
proc-macro-crate = "1.1.3"
proc-macro2 = "1"
quote = "1"
regex = "1.5.6"
regex = "1.6.0"
syn = { version = "1", features = ["full", "extra-traits"] }
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ lzzzz = '1.0'
netif = "0.1.3"
notify = "=5.0.0-pre.15"
once_cell = "1.10.0"
regex = "1.5.5"
regex = "1.6.0"
ring = "0.16.20"
serde = { version = "1.0.136", features = ["derive"] }
signal-hook-registry = "1.4.0"
Expand Down
2 changes: 1 addition & 1 deletion test_util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ once_cell = "1.10.0"
os_pipe = "1.0.1"
parking_lot = "0.12.0"
pretty_assertions = "=1.2.1"
regex = "1.5.5"
regex = "1.6.0"
rustls-pemfile = "1.0.0"
serde = { version = "1.0.136", features = ["derive"] }
serde_json = "1.0.79"
Expand Down

0 comments on commit 1c2ec1f

Please sign in to comment.