mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 16:49:18 -05:00
refactor(deno_graph): remove unused Resolved::Ok#kind usage (#17504)
See https://github.com/denoland/deno_graph/pull/205 for more details.
This commit is contained in:
parent
0d1471282b
commit
654e177c91
20 changed files with 75 additions and 172 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -972,9 +972,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deno_doc"
|
name = "deno_doc"
|
||||||
version = "0.52.0"
|
version = "0.53.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5a4d646da7094c8c4005c1ecfeb9649a1f3875e5e964a1ecf6d44899c5692ebb"
|
checksum = "9d792edabc692d89ab24cb4fa0f24cd8d71288669962e867b4634a28d04935bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"deno_ast",
|
"deno_ast",
|
||||||
|
@ -990,9 +990,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deno_emit"
|
name = "deno_emit"
|
||||||
version = "0.13.0"
|
version = "0.14.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "33d7152339bef69b44316be53d6b34cf40718c3084a22565d729b4131c53f462"
|
checksum = "9abbf7099beedb52d5d84cef071825f1abf75234d48c820b15dbd4e47576b64c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64",
|
"base64",
|
||||||
|
@ -1054,9 +1054,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deno_graph"
|
name = "deno_graph"
|
||||||
version = "0.41.0"
|
version = "0.42.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "88980ad969ef1922782f4b19159bb3c46919e883292f1c71ddc3bcd8ba1a5a46"
|
checksum = "f469b4a0694cb7e7fd512f23bc10d32398d7228cd2581a262109359c8e263940"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
@ -1657,9 +1657,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "eszip"
|
name = "eszip"
|
||||||
version = "0.32.0"
|
version = "0.33.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "584906c722ca9751a4e1dd1fde7ca3387e2af2b4b3608e8d44bd29f22095a4a2"
|
checksum = "98d6b4f119df606d3cdce5b251b326b6f5cc9a5c59054d701ca973c23f90f7b4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64",
|
"base64",
|
||||||
|
|
|
@ -44,9 +44,9 @@ winres.workspace = true
|
||||||
[dependencies]
|
[dependencies]
|
||||||
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
|
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
|
||||||
deno_core.workspace = true
|
deno_core.workspace = true
|
||||||
deno_doc = "0.52.0"
|
deno_doc = "0.53.0"
|
||||||
deno_emit = "0.13.0"
|
deno_emit = "0.14.0"
|
||||||
deno_graph = "0.41.0"
|
deno_graph = "0.42.0"
|
||||||
deno_lint = { version = "0.37.0", features = ["docs"] }
|
deno_lint = { version = "0.37.0", features = ["docs"] }
|
||||||
deno_lockfile.workspace = true
|
deno_lockfile.workspace = true
|
||||||
deno_runtime.workspace = true
|
deno_runtime.workspace = true
|
||||||
|
@ -69,7 +69,7 @@ dprint-plugin-markdown = "=0.15.2"
|
||||||
dprint-plugin-typescript = "=0.80.2"
|
dprint-plugin-typescript = "=0.80.2"
|
||||||
encoding_rs.workspace = true
|
encoding_rs.workspace = true
|
||||||
env_logger = "=0.9.0"
|
env_logger = "=0.9.0"
|
||||||
eszip = "=0.32.0"
|
eszip = "=0.33.0"
|
||||||
fancy-regex = "=0.10.0"
|
fancy-regex = "=0.10.0"
|
||||||
flate2.workspace = true
|
flate2.workspace = true
|
||||||
http.workspace = true
|
http.workspace = true
|
||||||
|
|
|
@ -25,7 +25,6 @@ use deno_graph::GraphImport;
|
||||||
use deno_graph::MediaType;
|
use deno_graph::MediaType;
|
||||||
use deno_graph::ModuleGraph;
|
use deno_graph::ModuleGraph;
|
||||||
use deno_graph::ModuleGraphError;
|
use deno_graph::ModuleGraphError;
|
||||||
use deno_graph::ModuleKind;
|
|
||||||
use deno_graph::Range;
|
use deno_graph::Range;
|
||||||
use deno_graph::Resolved;
|
use deno_graph::Resolved;
|
||||||
use deno_runtime::permissions::PermissionsContainer;
|
use deno_runtime::permissions::PermissionsContainer;
|
||||||
|
@ -35,13 +34,6 @@ use std::collections::HashSet;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub fn contains_specifier(
|
|
||||||
v: &[(ModuleSpecifier, ModuleKind)],
|
|
||||||
specifier: &ModuleSpecifier,
|
|
||||||
) -> bool {
|
|
||||||
v.iter().any(|(s, _)| s == specifier)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum ModuleEntry {
|
pub enum ModuleEntry {
|
||||||
|
@ -175,7 +167,7 @@ impl GraphData {
|
||||||
/// Return `None` if any modules are not known.
|
/// Return `None` if any modules are not known.
|
||||||
pub fn walk<'a>(
|
pub fn walk<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
roots: &[(ModuleSpecifier, ModuleKind)],
|
roots: &[ModuleSpecifier],
|
||||||
follow_dynamic: bool,
|
follow_dynamic: bool,
|
||||||
follow_type_only: bool,
|
follow_type_only: bool,
|
||||||
check_js: bool,
|
check_js: bool,
|
||||||
|
@ -183,7 +175,7 @@ impl GraphData {
|
||||||
let mut result = HashMap::<&'a ModuleSpecifier, &'a ModuleEntry>::new();
|
let mut result = HashMap::<&'a ModuleSpecifier, &'a ModuleEntry>::new();
|
||||||
let mut seen = HashSet::<&ModuleSpecifier>::new();
|
let mut seen = HashSet::<&ModuleSpecifier>::new();
|
||||||
let mut visiting = VecDeque::<&ModuleSpecifier>::new();
|
let mut visiting = VecDeque::<&ModuleSpecifier>::new();
|
||||||
for (root, _) in roots {
|
for root in roots {
|
||||||
seen.insert(root);
|
seen.insert(root);
|
||||||
visiting.push_back(root);
|
visiting.push_back(root);
|
||||||
}
|
}
|
||||||
|
@ -274,10 +266,7 @@ impl GraphData {
|
||||||
|
|
||||||
/// Clone part of `self`, containing only modules which are dependencies of
|
/// Clone part of `self`, containing only modules which are dependencies of
|
||||||
/// `roots`. Returns `None` if any roots are not known.
|
/// `roots`. Returns `None` if any roots are not known.
|
||||||
pub fn graph_segment(
|
pub fn graph_segment(&self, roots: &[ModuleSpecifier]) -> Option<Self> {
|
||||||
&self,
|
|
||||||
roots: &[(ModuleSpecifier, ModuleKind)],
|
|
||||||
) -> Option<Self> {
|
|
||||||
let mut modules = HashMap::new();
|
let mut modules = HashMap::new();
|
||||||
let mut referrer_map = HashMap::new();
|
let mut referrer_map = HashMap::new();
|
||||||
let entries = match self.walk(roots, true, true, true) {
|
let entries = match self.walk(roots, true, true, true) {
|
||||||
|
@ -305,7 +294,7 @@ impl GraphData {
|
||||||
/// not known.
|
/// not known.
|
||||||
pub fn check(
|
pub fn check(
|
||||||
&self,
|
&self,
|
||||||
roots: &[(ModuleSpecifier, ModuleKind)],
|
roots: &[ModuleSpecifier],
|
||||||
follow_type_only: bool,
|
follow_type_only: bool,
|
||||||
check_js: bool,
|
check_js: bool,
|
||||||
) -> Option<Result<(), AnyError>> {
|
) -> Option<Result<(), AnyError>> {
|
||||||
|
@ -365,7 +354,7 @@ impl GraphData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ModuleEntry::Error(error) => {
|
ModuleEntry::Error(error) => {
|
||||||
if !contains_specifier(roots, specifier) {
|
if !roots.contains(specifier) {
|
||||||
if let Some(range) = self.referrer_map.get(specifier) {
|
if let Some(range) = self.referrer_map.get(specifier) {
|
||||||
if !range.specifier.as_str().contains("$deno") {
|
if !range.specifier.as_str().contains("$deno") {
|
||||||
let message = error.to_string();
|
let message = error.to_string();
|
||||||
|
@ -388,7 +377,7 @@ impl GraphData {
|
||||||
/// Assumes that all of those modules are known.
|
/// Assumes that all of those modules are known.
|
||||||
pub fn set_type_checked(
|
pub fn set_type_checked(
|
||||||
&mut self,
|
&mut self,
|
||||||
roots: &[(ModuleSpecifier, ModuleKind)],
|
roots: &[ModuleSpecifier],
|
||||||
lib: TsTypeLib,
|
lib: TsTypeLib,
|
||||||
) {
|
) {
|
||||||
let specifiers: Vec<ModuleSpecifier> =
|
let specifiers: Vec<ModuleSpecifier> =
|
||||||
|
@ -408,10 +397,10 @@ impl GraphData {
|
||||||
/// Check if `roots` are all marked as type checked under `lib`.
|
/// Check if `roots` are all marked as type checked under `lib`.
|
||||||
pub fn is_type_checked(
|
pub fn is_type_checked(
|
||||||
&self,
|
&self,
|
||||||
roots: &[(ModuleSpecifier, ModuleKind)],
|
roots: &[ModuleSpecifier],
|
||||||
lib: &TsTypeLib,
|
lib: &TsTypeLib,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
roots.iter().all(|(r, _)| {
|
roots.iter().all(|r| {
|
||||||
let found = self.follow_redirect(r);
|
let found = self.follow_redirect(r);
|
||||||
match self.modules.get(&found) {
|
match self.modules.get(&found) {
|
||||||
Some(ModuleEntry::Module { checked_libs, .. }) => {
|
Some(ModuleEntry::Module { checked_libs, .. }) => {
|
||||||
|
@ -527,7 +516,7 @@ pub async fn create_graph_and_maybe_check(
|
||||||
let analyzer = ps.parsed_source_cache.as_analyzer();
|
let analyzer = ps.parsed_source_cache.as_analyzer();
|
||||||
let graph = Arc::new(
|
let graph = Arc::new(
|
||||||
deno_graph::create_graph(
|
deno_graph::create_graph(
|
||||||
vec![(root, deno_graph::ModuleKind::Esm)],
|
vec![root],
|
||||||
&mut cache,
|
&mut cache,
|
||||||
deno_graph::GraphOptions {
|
deno_graph::GraphOptions {
|
||||||
is_dynamic: false,
|
is_dynamic: false,
|
||||||
|
|
|
@ -876,7 +876,7 @@ impl Documents {
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let maybe_resolver = self.get_maybe_resolver();
|
let maybe_resolver = self.get_maybe_resolver();
|
||||||
let maybe_specifier = if let Some(resolver) = maybe_resolver {
|
let maybe_specifier = if let Some(resolver) = maybe_resolver {
|
||||||
resolver.resolve(specifier, referrer).to_result().ok()
|
resolver.resolve(specifier, referrer).ok()
|
||||||
} else {
|
} else {
|
||||||
deno_core::resolve_import(specifier, referrer.as_str()).ok()
|
deno_core::resolve_import(specifier, referrer.as_str()).ok()
|
||||||
};
|
};
|
||||||
|
@ -1318,7 +1318,7 @@ fn lsp_deno_graph_analyze(
|
||||||
specifier,
|
specifier,
|
||||||
maybe_headers,
|
maybe_headers,
|
||||||
content,
|
content,
|
||||||
Some(&deno_graph::ModuleKind::Esm),
|
Some(deno_graph::ModuleKind::Esm),
|
||||||
maybe_resolver,
|
maybe_resolver,
|
||||||
Some(&analyzer),
|
Some(&analyzer),
|
||||||
),
|
),
|
||||||
|
|
|
@ -8,7 +8,6 @@ use deno_core::serde_json;
|
||||||
use deno_core::serde_json::json;
|
use deno_core::serde_json::json;
|
||||||
use deno_core::serde_json::Value;
|
use deno_core::serde_json::Value;
|
||||||
use deno_core::ModuleSpecifier;
|
use deno_core::ModuleSpecifier;
|
||||||
use deno_graph::ModuleKind;
|
|
||||||
use import_map::ImportMap;
|
use import_map::ImportMap;
|
||||||
use log::error;
|
use log::error;
|
||||||
use log::warn;
|
use log::warn;
|
||||||
|
@ -158,7 +157,7 @@ impl LanguageServer {
|
||||||
) -> LspResult<Option<Value>> {
|
) -> LspResult<Option<Value>> {
|
||||||
async fn create_graph_for_caching(
|
async fn create_graph_for_caching(
|
||||||
cli_options: CliOptions,
|
cli_options: CliOptions,
|
||||||
roots: Vec<(ModuleSpecifier, ModuleKind)>,
|
roots: Vec<ModuleSpecifier>,
|
||||||
open_docs: Vec<Document>,
|
open_docs: Vec<Document>,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let open_docs = open_docs
|
let open_docs = open_docs
|
||||||
|
@ -2917,7 +2916,7 @@ impl tower_lsp::LanguageServer for LanguageServer {
|
||||||
|
|
||||||
struct PrepareCacheResult {
|
struct PrepareCacheResult {
|
||||||
cli_options: CliOptions,
|
cli_options: CliOptions,
|
||||||
roots: Vec<(ModuleSpecifier, ModuleKind)>,
|
roots: Vec<ModuleSpecifier>,
|
||||||
open_docs: Vec<Document>,
|
open_docs: Vec<Document>,
|
||||||
mark: PerformanceMark,
|
mark: PerformanceMark,
|
||||||
}
|
}
|
||||||
|
@ -2938,15 +2937,10 @@ impl Inner {
|
||||||
params
|
params
|
||||||
.uris
|
.uris
|
||||||
.iter()
|
.iter()
|
||||||
.map(|t| {
|
.map(|t| self.url_map.normalize_url(&t.uri))
|
||||||
(
|
|
||||||
self.url_map.normalize_url(&t.uri),
|
|
||||||
deno_graph::ModuleKind::Esm,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect()
|
.collect()
|
||||||
} else {
|
} else {
|
||||||
vec![(referrer, deno_graph::ModuleKind::Esm)]
|
vec![referrer]
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut cli_options = CliOptions::new(
|
let mut cli_options = CliOptions::new(
|
||||||
|
|
|
@ -280,7 +280,7 @@ pub fn resolve_npm_package_reqs(graph: &ModuleGraph) -> Vec<NpmPackageReq> {
|
||||||
let root_specifiers = graph
|
let root_specifiers = graph
|
||||||
.roots
|
.roots
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(url, _)| graph.resolve(url))
|
.map(|url| graph.resolve(url))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let mut seen = HashSet::new();
|
let mut seen = HashSet::new();
|
||||||
let mut specifier_graph = SpecifierTree::default();
|
let mut specifier_graph = SpecifierTree::default();
|
||||||
|
@ -551,7 +551,6 @@ fn cmp_package_req(a: &NpmPackageReq, b: &NpmPackageReq) -> Ordering {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use deno_graph::ModuleKind;
|
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -965,16 +964,10 @@ mod tests {
|
||||||
let analyzer = deno_graph::CapturingModuleAnalyzer::default();
|
let analyzer = deno_graph::CapturingModuleAnalyzer::default();
|
||||||
let graph = deno_graph::create_graph(
|
let graph = deno_graph::create_graph(
|
||||||
vec![
|
vec![
|
||||||
(
|
|
||||||
ModuleSpecifier::parse("file:///dev/local_module_a/mod.ts").unwrap(),
|
ModuleSpecifier::parse("file:///dev/local_module_a/mod.ts").unwrap(),
|
||||||
ModuleKind::Esm,
|
|
||||||
),
|
|
||||||
(
|
|
||||||
// test redirect at root
|
// test redirect at root
|
||||||
ModuleSpecifier::parse("https://deno.land/x/module_redirect/mod.ts")
|
ModuleSpecifier::parse("https://deno.land/x/module_redirect/mod.ts")
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
ModuleKind::Esm,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
&mut loader,
|
&mut loader,
|
||||||
deno_graph::GraphOptions {
|
deno_graph::GraphOptions {
|
||||||
|
|
|
@ -52,7 +52,6 @@ use deno_graph::source::CacheInfo;
|
||||||
use deno_graph::source::LoadFuture;
|
use deno_graph::source::LoadFuture;
|
||||||
use deno_graph::source::Loader;
|
use deno_graph::source::Loader;
|
||||||
use deno_graph::source::Resolver;
|
use deno_graph::source::Resolver;
|
||||||
use deno_graph::ModuleKind;
|
|
||||||
use deno_graph::Resolved;
|
use deno_graph::Resolved;
|
||||||
use deno_runtime::deno_broadcast_channel::InMemoryBroadcastChannel;
|
use deno_runtime::deno_broadcast_channel::InMemoryBroadcastChannel;
|
||||||
use deno_runtime::deno_node::NodeResolutionMode;
|
use deno_runtime::deno_node::NodeResolutionMode;
|
||||||
|
@ -330,10 +329,6 @@ impl ProcState {
|
||||||
let has_root_npm_specifier = roots.iter().any(|r| {
|
let has_root_npm_specifier = roots.iter().any(|r| {
|
||||||
r.scheme() == "npm" && NpmPackageReference::from_specifier(r).is_ok()
|
r.scheme() == "npm" && NpmPackageReference::from_specifier(r).is_ok()
|
||||||
});
|
});
|
||||||
let roots = roots
|
|
||||||
.into_iter()
|
|
||||||
.map(|s| (s, ModuleKind::Esm))
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
if !has_root_npm_specifier {
|
if !has_root_npm_specifier {
|
||||||
let graph_data = self.graph_data.read();
|
let graph_data = self.graph_data.read();
|
||||||
|
@ -451,11 +446,10 @@ impl ProcState {
|
||||||
drop(_pb_clear_guard);
|
drop(_pb_clear_guard);
|
||||||
|
|
||||||
// type check if necessary
|
// type check if necessary
|
||||||
let is_std_node = roots.len() == 1 && roots[0].0 == *node::MODULE_ALL_URL;
|
let is_std_node = roots.len() == 1 && roots[0] == *node::MODULE_ALL_URL;
|
||||||
if self.options.type_check_mode() != TypeCheckMode::None && !is_std_node {
|
if self.options.type_check_mode() != TypeCheckMode::None && !is_std_node {
|
||||||
log::debug!("Type checking.");
|
log::debug!("Type checking.");
|
||||||
let maybe_config_specifier = self.options.maybe_config_file_specifier();
|
let maybe_config_specifier = self.options.maybe_config_file_specifier();
|
||||||
let roots = roots.clone();
|
|
||||||
let options = check::CheckOptions {
|
let options = check::CheckOptions {
|
||||||
type_check_mode: self.options.type_check_mode(),
|
type_check_mode: self.options.type_check_mode(),
|
||||||
debug: self.options.log_level() == Some(log::Level::Debug),
|
debug: self.options.log_level() == Some(log::Level::Debug),
|
||||||
|
@ -466,7 +460,7 @@ impl ProcState {
|
||||||
.ts_config,
|
.ts_config,
|
||||||
log_checks: true,
|
log_checks: true,
|
||||||
reload: self.options.reload_flag()
|
reload: self.options.reload_flag()
|
||||||
&& !roots.iter().all(|r| reload_exclusions.contains(&r.0)),
|
&& !roots.iter().all(|r| reload_exclusions.contains(r)),
|
||||||
};
|
};
|
||||||
let check_cache =
|
let check_cache =
|
||||||
TypeCheckCache::new(&self.dir.type_checking_cache_db_file_path());
|
TypeCheckCache::new(&self.dir.type_checking_cache_db_file_path());
|
||||||
|
@ -530,7 +524,7 @@ impl ProcState {
|
||||||
}
|
}
|
||||||
|
|
||||||
let node_std_graph = self
|
let node_std_graph = self
|
||||||
.create_graph(vec![(node::MODULE_ALL_URL.clone(), ModuleKind::Esm)])
|
.create_graph(vec![node::MODULE_ALL_URL.clone()])
|
||||||
.await?;
|
.await?;
|
||||||
self.graph_data.write().add_graph(&node_std_graph);
|
self.graph_data.write().add_graph(&node_std_graph);
|
||||||
self.node_std_graph_prepared.store(true, Ordering::Relaxed);
|
self.node_std_graph_prepared.store(true, Ordering::Relaxed);
|
||||||
|
@ -636,9 +630,7 @@ impl ProcState {
|
||||||
let specifier = self
|
let specifier = self
|
||||||
.maybe_resolver
|
.maybe_resolver
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|resolver| {
|
.and_then(|resolver| resolver.resolve(specifier, &referrer).ok())
|
||||||
resolver.resolve(specifier, &referrer).to_result().ok()
|
|
||||||
})
|
|
||||||
.or_else(|| ModuleSpecifier::parse(specifier).ok());
|
.or_else(|| ModuleSpecifier::parse(specifier).ok());
|
||||||
if let Some(specifier) = specifier {
|
if let Some(specifier) = specifier {
|
||||||
if let Ok(reference) = NpmPackageReference::from_specifier(&specifier) {
|
if let Ok(reference) = NpmPackageReference::from_specifier(&specifier) {
|
||||||
|
@ -655,7 +647,7 @@ impl ProcState {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(resolver) = &self.maybe_resolver {
|
if let Some(resolver) = &self.maybe_resolver {
|
||||||
resolver.resolve(specifier, &referrer).to_result()
|
resolver.resolve(specifier, &referrer)
|
||||||
} else {
|
} else {
|
||||||
deno_core::resolve_import(specifier, referrer.as_str())
|
deno_core::resolve_import(specifier, referrer.as_str())
|
||||||
.map_err(|err| err.into())
|
.map_err(|err| err.into())
|
||||||
|
@ -705,7 +697,7 @@ impl ProcState {
|
||||||
|
|
||||||
pub async fn create_graph(
|
pub async fn create_graph(
|
||||||
&self,
|
&self,
|
||||||
roots: Vec<(ModuleSpecifier, ModuleKind)>,
|
roots: Vec<ModuleSpecifier>,
|
||||||
) -> Result<deno_graph::ModuleGraph, AnyError> {
|
) -> Result<deno_graph::ModuleGraph, AnyError> {
|
||||||
let mut cache = self.create_graph_loader();
|
let mut cache = self.create_graph_loader();
|
||||||
self.create_graph_with_loader(roots, &mut cache).await
|
self.create_graph_with_loader(roots, &mut cache).await
|
||||||
|
@ -713,7 +705,7 @@ impl ProcState {
|
||||||
|
|
||||||
pub async fn create_graph_with_loader(
|
pub async fn create_graph_with_loader(
|
||||||
&self,
|
&self,
|
||||||
roots: Vec<(ModuleSpecifier, ModuleKind)>,
|
roots: Vec<ModuleSpecifier>,
|
||||||
loader: &mut dyn Loader,
|
loader: &mut dyn Loader,
|
||||||
) -> Result<deno_graph::ModuleGraph, AnyError> {
|
) -> Result<deno_graph::ModuleGraph, AnyError> {
|
||||||
let maybe_imports = self.options.to_maybe_imports()?;
|
let maybe_imports = self.options.to_maybe_imports()?;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
use deno_core::error::AnyError;
|
||||||
use deno_core::resolve_import;
|
use deno_core::resolve_import;
|
||||||
use deno_core::ModuleSpecifier;
|
use deno_core::ModuleSpecifier;
|
||||||
use deno_graph::source::ResolveResponse;
|
|
||||||
use deno_graph::source::Resolver;
|
use deno_graph::source::Resolver;
|
||||||
use deno_graph::source::DEFAULT_JSX_IMPORT_SOURCE_MODULE;
|
use deno_graph::source::DEFAULT_JSX_IMPORT_SOURCE_MODULE;
|
||||||
use import_map::ImportMap;
|
use import_map::ImportMap;
|
||||||
|
@ -63,19 +63,13 @@ impl Resolver for CliResolver {
|
||||||
&self,
|
&self,
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
referrer: &ModuleSpecifier,
|
referrer: &ModuleSpecifier,
|
||||||
) -> ResolveResponse {
|
) -> Result<ModuleSpecifier, AnyError> {
|
||||||
if let Some(import_map) = &self.maybe_import_map {
|
if let Some(import_map) = &self.maybe_import_map {
|
||||||
match import_map.resolve(specifier, referrer) {
|
import_map
|
||||||
Ok(resolved_specifier) => {
|
.resolve(specifier, referrer)
|
||||||
ResolveResponse::Specifier(resolved_specifier)
|
.map_err(|err| err.into())
|
||||||
}
|
|
||||||
Err(err) => ResolveResponse::Err(err.into()),
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
match resolve_import(specifier, referrer.as_str()) {
|
resolve_import(specifier, referrer.as_str()).map_err(|err| err.into())
|
||||||
Ok(specifier) => ResolveResponse::Specifier(specifier),
|
|
||||||
Err(err) => ResolveResponse::Err(err.into()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ impl ModuleLoader for EmbeddedModuleLoader {
|
||||||
deno_core::resolve_import(specifier, referrer.as_str())
|
deno_core::resolve_import(specifier, referrer.as_str())
|
||||||
.map_err(|err| err.into())
|
.map_err(|err| err.into())
|
||||||
},
|
},
|
||||||
|r| r.resolve(specifier, &referrer).to_result(),
|
|r| r.resolve(specifier, &referrer),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[WILDCARD]
|
Bundle file:///[WILDCARD]/subdir/shebang_file.js
|
||||||
#!/usr/bin/env -S deno run --allow-read
|
#!/usr/bin/env -S deno run --allow-read
|
||||||
// deno-fmt-ignore-file
|
// deno-fmt-ignore-file
|
||||||
// deno-lint-ignore-file
|
// deno-lint-ignore-file
|
||||||
|
|
|
@ -4,7 +4,6 @@ use crate::args::BenchOptions;
|
||||||
use crate::args::CliOptions;
|
use crate::args::CliOptions;
|
||||||
use crate::args::TypeCheckMode;
|
use crate::args::TypeCheckMode;
|
||||||
use crate::colors;
|
use crate::colors;
|
||||||
use crate::graph_util::contains_specifier;
|
|
||||||
use crate::graph_util::graph_valid;
|
use crate::graph_util::graph_valid;
|
||||||
use crate::ops;
|
use crate::ops;
|
||||||
use crate::proc_state::ProcState;
|
use crate::proc_state::ProcState;
|
||||||
|
@ -24,7 +23,6 @@ use deno_core::futures::stream;
|
||||||
use deno_core::futures::FutureExt;
|
use deno_core::futures::FutureExt;
|
||||||
use deno_core::futures::StreamExt;
|
use deno_core::futures::StreamExt;
|
||||||
use deno_core::ModuleSpecifier;
|
use deno_core::ModuleSpecifier;
|
||||||
use deno_graph::ModuleKind;
|
|
||||||
use deno_runtime::permissions::Permissions;
|
use deno_runtime::permissions::Permissions;
|
||||||
use deno_runtime::permissions::PermissionsContainer;
|
use deno_runtime::permissions::PermissionsContainer;
|
||||||
use deno_runtime::tokio_util::run_local;
|
use deno_runtime::tokio_util::run_local;
|
||||||
|
@ -548,19 +546,9 @@ pub async fn run_benchmarks_with_watch(
|
||||||
let mut modules_to_reload = if files_changed {
|
let mut modules_to_reload = if files_changed {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
} else {
|
} else {
|
||||||
bench_modules
|
bench_modules.clone()
|
||||||
.iter()
|
|
||||||
.map(|url| (url.clone(), ModuleKind::Esm))
|
|
||||||
.collect()
|
|
||||||
};
|
};
|
||||||
let graph = ps
|
let graph = ps.create_graph(bench_modules.clone()).await?;
|
||||||
.create_graph(
|
|
||||||
bench_modules
|
|
||||||
.iter()
|
|
||||||
.map(|s| (s.clone(), ModuleKind::Esm))
|
|
||||||
.collect(),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
graph_valid(&graph, !no_check, ps.options.check_js())?;
|
graph_valid(&graph, !no_check, ps.options.check_js())?;
|
||||||
|
|
||||||
// TODO(@kitsonk) - This should be totally derivable from the graph.
|
// TODO(@kitsonk) - This should be totally derivable from the graph.
|
||||||
|
@ -618,7 +606,7 @@ pub async fn run_benchmarks_with_watch(
|
||||||
deno_core::resolve_url_or_path(&path.to_string_lossy()).ok()
|
deno_core::resolve_url_or_path(&path.to_string_lossy()).ok()
|
||||||
}) {
|
}) {
|
||||||
if modules.contains(&path) {
|
if modules.contains(&path) {
|
||||||
modules_to_reload.push((specifier, ModuleKind::Esm));
|
modules_to_reload.push(specifier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -649,7 +637,7 @@ pub async fn run_benchmarks_with_watch(
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
let operation = |modules_to_reload: Vec<(ModuleSpecifier, ModuleKind)>| {
|
let operation = |modules_to_reload: Vec<ModuleSpecifier>| {
|
||||||
let permissions = &permissions;
|
let permissions = &permissions;
|
||||||
let bench_options = &bench_options;
|
let bench_options = &bench_options;
|
||||||
ps.borrow_mut().reset_for_file_watcher();
|
ps.borrow_mut().reset_for_file_watcher();
|
||||||
|
@ -659,7 +647,7 @@ pub async fn run_benchmarks_with_watch(
|
||||||
let specifiers =
|
let specifiers =
|
||||||
collect_specifiers(&bench_options.files, is_supported_bench_path)?
|
collect_specifiers(&bench_options.files, is_supported_bench_path)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|specifier| contains_specifier(&modules_to_reload, specifier))
|
.filter(|specifier| modules_to_reload.contains(specifier))
|
||||||
.collect::<Vec<ModuleSpecifier>>();
|
.collect::<Vec<ModuleSpecifier>>();
|
||||||
|
|
||||||
check_specifiers(&ps, permissions.clone(), specifiers.clone()).await?;
|
check_specifiers(&ps, permissions.clone(), specifiers.clone()).await?;
|
||||||
|
|
|
@ -134,7 +134,7 @@ fn bundle_module_graph(
|
||||||
graph: &deno_graph::ModuleGraph,
|
graph: &deno_graph::ModuleGraph,
|
||||||
ps: &ProcState,
|
ps: &ProcState,
|
||||||
) -> Result<deno_emit::BundleEmit, AnyError> {
|
) -> Result<deno_emit::BundleEmit, AnyError> {
|
||||||
log::info!("{} {}", colors::green("Bundle"), graph.roots[0].0);
|
log::info!("{} {}", colors::green("Bundle"), graph.roots[0]);
|
||||||
|
|
||||||
let ts_config_result = ps
|
let ts_config_result = ps
|
||||||
.options
|
.options
|
||||||
|
@ -145,29 +145,12 @@ fn bundle_module_graph(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut output = deno_emit::bundle_graph(
|
deno_emit::bundle_graph(
|
||||||
graph,
|
graph,
|
||||||
deno_emit::BundleOptions {
|
deno_emit::BundleOptions {
|
||||||
bundle_type: deno_emit::BundleType::Module,
|
bundle_type: deno_emit::BundleType::Module,
|
||||||
emit_options: ts_config_result.ts_config.into(),
|
emit_options: ts_config_result.ts_config.into(),
|
||||||
emit_ignore_directives: true,
|
emit_ignore_directives: true,
|
||||||
},
|
},
|
||||||
)?;
|
)
|
||||||
|
|
||||||
// todo(https://github.com/denoland/deno_emit/issues/85): move to deno_emit
|
|
||||||
if let Some(shebang) = shebang_file(graph) {
|
|
||||||
output.code = format!("{}\n{}", shebang, output.code);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(output)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn shebang_file(graph: &deno_graph::ModuleGraph) -> Option<String> {
|
|
||||||
let source = graph.get(&graph.roots[0].0)?.maybe_source.as_ref()?;
|
|
||||||
let first_line = source.lines().next()?;
|
|
||||||
if first_line.starts_with("#!") {
|
|
||||||
Some(first_line.to_string())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ use deno_ast::MediaType;
|
||||||
use deno_ast::ModuleSpecifier;
|
use deno_ast::ModuleSpecifier;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::parking_lot::RwLock;
|
use deno_core::parking_lot::RwLock;
|
||||||
use deno_graph::ModuleKind;
|
|
||||||
use deno_runtime::colors;
|
use deno_runtime::colors;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
@ -55,7 +54,7 @@ pub struct CheckResult {
|
||||||
/// It is expected that it is determined if a check and/or emit is validated
|
/// It is expected that it is determined if a check and/or emit is validated
|
||||||
/// before the function is called.
|
/// before the function is called.
|
||||||
pub fn check(
|
pub fn check(
|
||||||
roots: &[(ModuleSpecifier, ModuleKind)],
|
roots: &[ModuleSpecifier],
|
||||||
graph_data: Arc<RwLock<GraphData>>,
|
graph_data: Arc<RwLock<GraphData>>,
|
||||||
cache: &TypeCheckCache,
|
cache: &TypeCheckCache,
|
||||||
npm_resolver: &NpmPackageResolver,
|
npm_resolver: &NpmPackageResolver,
|
||||||
|
@ -78,7 +77,7 @@ pub fn check(
|
||||||
|
|
||||||
let root_names = get_tsc_roots(&segment_graph_data, check_js);
|
let root_names = get_tsc_roots(&segment_graph_data, check_js);
|
||||||
if options.log_checks {
|
if options.log_checks {
|
||||||
for (root, _) in roots {
|
for root in roots {
|
||||||
let root_str = root.as_str();
|
let root_str = root.as_str();
|
||||||
// `$deno` specifiers are internal, don't print them.
|
// `$deno` specifiers are internal, don't print them.
|
||||||
if !root_str.contains("$deno") {
|
if !root_str.contains("$deno") {
|
||||||
|
@ -92,7 +91,7 @@ pub fn check(
|
||||||
let maybe_tsbuildinfo = if options.reload {
|
let maybe_tsbuildinfo = if options.reload {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
cache.get_tsbuildinfo(&roots[0].0)
|
cache.get_tsbuildinfo(&roots[0])
|
||||||
};
|
};
|
||||||
// to make tsc build info work, we need to consistently hash modules, so that
|
// to make tsc build info work, we need to consistently hash modules, so that
|
||||||
// tsc can better determine if an emit is still valid or not, so we provide
|
// tsc can better determine if an emit is still valid or not, so we provide
|
||||||
|
@ -137,7 +136,7 @@ pub fn check(
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(tsbuildinfo) = response.maybe_tsbuildinfo {
|
if let Some(tsbuildinfo) = response.maybe_tsbuildinfo {
|
||||||
cache.set_tsbuildinfo(&roots[0].0, &tsbuildinfo);
|
cache.set_tsbuildinfo(&roots[0], &tsbuildinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if diagnostics.is_empty() {
|
if diagnostics.is_empty() {
|
||||||
|
|
|
@ -14,7 +14,6 @@ use deno_core::anyhow::bail;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::resolve_url_or_path;
|
use deno_core::resolve_url_or_path;
|
||||||
use deno_doc as doc;
|
use deno_doc as doc;
|
||||||
use deno_graph::ModuleKind;
|
|
||||||
use deno_graph::ModuleSpecifier;
|
use deno_graph::ModuleSpecifier;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
@ -42,7 +41,7 @@ pub async fn print_docs(
|
||||||
);
|
);
|
||||||
let analyzer = deno_graph::CapturingModuleAnalyzer::default();
|
let analyzer = deno_graph::CapturingModuleAnalyzer::default();
|
||||||
let graph = deno_graph::create_graph(
|
let graph = deno_graph::create_graph(
|
||||||
vec![(source_file_specifier.clone(), ModuleKind::Esm)],
|
vec![source_file_specifier.clone()],
|
||||||
&mut loader,
|
&mut loader,
|
||||||
deno_graph::GraphOptions {
|
deno_graph::GraphOptions {
|
||||||
is_dynamic: false,
|
is_dynamic: false,
|
||||||
|
@ -78,9 +77,7 @@ pub async fn print_docs(
|
||||||
// Save our fake file into file fetcher cache.
|
// Save our fake file into file fetcher cache.
|
||||||
ps.file_fetcher.insert_cached(root);
|
ps.file_fetcher.insert_cached(root);
|
||||||
|
|
||||||
let graph = ps
|
let graph = ps.create_graph(vec![root_specifier.clone()]).await?;
|
||||||
.create_graph(vec![(root_specifier.clone(), ModuleKind::Esm)])
|
|
||||||
.await?;
|
|
||||||
let doc_parser = doc::DocParser::new(
|
let doc_parser = doc::DocParser::new(
|
||||||
graph,
|
graph,
|
||||||
doc_flags.private,
|
doc_flags.private,
|
||||||
|
|
|
@ -14,7 +14,6 @@ use deno_graph::Dependency;
|
||||||
use deno_graph::Module;
|
use deno_graph::Module;
|
||||||
use deno_graph::ModuleGraph;
|
use deno_graph::ModuleGraph;
|
||||||
use deno_graph::ModuleGraphError;
|
use deno_graph::ModuleGraphError;
|
||||||
use deno_graph::ModuleKind;
|
|
||||||
use deno_graph::Resolved;
|
use deno_graph::Resolved;
|
||||||
use deno_runtime::colors;
|
use deno_runtime::colors;
|
||||||
|
|
||||||
|
@ -34,7 +33,7 @@ pub async fn info(flags: Flags, info_flags: InfoFlags) -> Result<(), AnyError> {
|
||||||
let ps = ProcState::build(flags).await?;
|
let ps = ProcState::build(flags).await?;
|
||||||
if let Some(specifier) = info_flags.file {
|
if let Some(specifier) = info_flags.file {
|
||||||
let specifier = resolve_url_or_path(&specifier)?;
|
let specifier = resolve_url_or_path(&specifier)?;
|
||||||
let graph = ps.create_graph(vec![(specifier, ModuleKind::Esm)]).await?;
|
let graph = ps.create_graph(vec![specifier]).await?;
|
||||||
|
|
||||||
if info_flags.json {
|
if info_flags.json {
|
||||||
let mut json_graph = json!(graph);
|
let mut json_graph = json!(graph);
|
||||||
|
@ -395,7 +394,7 @@ impl<'a> GraphDisplayContext<'a> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let root_specifier = self.graph.resolve(&self.graph.roots[0].0);
|
let root_specifier = self.graph.resolve(&self.graph.roots[0]);
|
||||||
match self.graph.try_get(&root_specifier) {
|
match self.graph.try_get(&root_specifier) {
|
||||||
Ok(Some(root)) => {
|
Ok(Some(root)) => {
|
||||||
if let Some(cache_info) = root.maybe_cache_info.as_ref() {
|
if let Some(cache_info) = root.maybe_cache_info.as_ref() {
|
||||||
|
|
|
@ -446,9 +446,7 @@ impl ReplSession {
|
||||||
.proc_state
|
.proc_state
|
||||||
.maybe_resolver
|
.maybe_resolver
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|resolver| {
|
.and_then(|resolver| resolver.resolve(i, &self.referrer).ok())
|
||||||
resolver.resolve(i, &self.referrer).to_result().ok()
|
|
||||||
})
|
|
||||||
.or_else(|| ModuleSpecifier::parse(i).ok())
|
.or_else(|| ModuleSpecifier::parse(i).ok())
|
||||||
.and_then(|url| NpmPackageReference::from_specifier(&url).ok())
|
.and_then(|url| NpmPackageReference::from_specifier(&url).ok())
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,7 +7,6 @@ use crate::args::TypeCheckMode;
|
||||||
use crate::colors;
|
use crate::colors;
|
||||||
use crate::display;
|
use crate::display;
|
||||||
use crate::file_fetcher::File;
|
use crate::file_fetcher::File;
|
||||||
use crate::graph_util::contains_specifier;
|
|
||||||
use crate::graph_util::graph_valid;
|
use crate::graph_util::graph_valid;
|
||||||
use crate::ops;
|
use crate::ops;
|
||||||
use crate::proc_state::ProcState;
|
use crate::proc_state::ProcState;
|
||||||
|
@ -32,7 +31,6 @@ use deno_core::futures::StreamExt;
|
||||||
use deno_core::parking_lot::Mutex;
|
use deno_core::parking_lot::Mutex;
|
||||||
use deno_core::url::Url;
|
use deno_core::url::Url;
|
||||||
use deno_core::ModuleSpecifier;
|
use deno_core::ModuleSpecifier;
|
||||||
use deno_graph::ModuleKind;
|
|
||||||
use deno_runtime::fmt_errors::format_js_error;
|
use deno_runtime::fmt_errors::format_js_error;
|
||||||
use deno_runtime::ops::io::Stdio;
|
use deno_runtime::ops::io::Stdio;
|
||||||
use deno_runtime::ops::io::StdioPipe;
|
use deno_runtime::ops::io::StdioPipe;
|
||||||
|
@ -1374,19 +1372,9 @@ pub async fn run_tests_with_watch(
|
||||||
let mut modules_to_reload = if files_changed {
|
let mut modules_to_reload = if files_changed {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
} else {
|
} else {
|
||||||
test_modules
|
test_modules.clone()
|
||||||
.iter()
|
|
||||||
.map(|url| (url.clone(), ModuleKind::Esm))
|
|
||||||
.collect()
|
|
||||||
};
|
};
|
||||||
let graph = ps
|
let graph = ps.create_graph(test_modules.clone()).await?;
|
||||||
.create_graph(
|
|
||||||
test_modules
|
|
||||||
.iter()
|
|
||||||
.map(|s| (s.clone(), ModuleKind::Esm))
|
|
||||||
.collect(),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
graph_valid(&graph, !no_check, ps.options.check_js())?;
|
graph_valid(&graph, !no_check, ps.options.check_js())?;
|
||||||
|
|
||||||
// TODO(@kitsonk) - This should be totally derivable from the graph.
|
// TODO(@kitsonk) - This should be totally derivable from the graph.
|
||||||
|
@ -1445,7 +1433,7 @@ pub async fn run_tests_with_watch(
|
||||||
deno_core::resolve_url_or_path(&path.to_string_lossy()).ok()
|
deno_core::resolve_url_or_path(&path.to_string_lossy()).ok()
|
||||||
}) {
|
}) {
|
||||||
if modules.contains(&path) {
|
if modules.contains(&path) {
|
||||||
modules_to_reload.push((specifier, ModuleKind::Esm));
|
modules_to_reload.push(specifier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1476,7 +1464,7 @@ pub async fn run_tests_with_watch(
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
let operation = |modules_to_reload: Vec<(ModuleSpecifier, ModuleKind)>| {
|
let operation = |modules_to_reload: Vec<ModuleSpecifier>| {
|
||||||
let permissions = &permissions;
|
let permissions = &permissions;
|
||||||
let test_options = &test_options;
|
let test_options = &test_options;
|
||||||
ps.borrow_mut().reset_for_file_watcher();
|
ps.borrow_mut().reset_for_file_watcher();
|
||||||
|
@ -1490,9 +1478,7 @@ pub async fn run_tests_with_watch(
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|(specifier, _)| {
|
.filter(|(specifier, _)| modules_to_reload.contains(specifier))
|
||||||
contains_specifier(&modules_to_reload, specifier)
|
|
||||||
})
|
|
||||||
.collect::<Vec<(ModuleSpecifier, TestMode)>>();
|
.collect::<Vec<(ModuleSpecifier, TestMode)>>();
|
||||||
|
|
||||||
check_specifiers(&ps, permissions.clone(), specifiers_with_mode.clone())
|
check_specifiers(&ps, permissions.clone(), specifiers_with_mode.clone())
|
||||||
|
|
7
cli/tools/vendor/mod.rs
vendored
7
cli/tools/vendor/mod.rs
vendored
|
@ -268,11 +268,8 @@ async fn create_graph(
|
||||||
let entry_points = flags
|
let entry_points = flags
|
||||||
.specifiers
|
.specifiers
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| {
|
.map(|p| resolve_url_or_path(p))
|
||||||
let url = resolve_url_or_path(p)?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
Ok((url, deno_graph::ModuleKind::Esm))
|
|
||||||
})
|
|
||||||
.collect::<Result<Vec<_>, AnyError>>()?;
|
|
||||||
|
|
||||||
ps.create_graph(entry_points).await
|
ps.create_graph(entry_points).await
|
||||||
}
|
}
|
||||||
|
|
9
cli/tools/vendor/test.rs
vendored
9
cli/tools/vendor/test.rs
vendored
|
@ -17,7 +17,6 @@ use deno_graph::source::LoadFuture;
|
||||||
use deno_graph::source::LoadResponse;
|
use deno_graph::source::LoadResponse;
|
||||||
use deno_graph::source::Loader;
|
use deno_graph::source::Loader;
|
||||||
use deno_graph::ModuleGraph;
|
use deno_graph::ModuleGraph;
|
||||||
use deno_graph::ModuleKind;
|
|
||||||
use import_map::ImportMap;
|
use import_map::ImportMap;
|
||||||
|
|
||||||
use crate::cache::ParsedSourceCache;
|
use crate::cache::ParsedSourceCache;
|
||||||
|
@ -214,11 +213,7 @@ impl VendorTestBuilder {
|
||||||
|
|
||||||
pub async fn build(&mut self) -> Result<VendorOutput, AnyError> {
|
pub async fn build(&mut self) -> Result<VendorOutput, AnyError> {
|
||||||
let output_dir = make_path("/vendor");
|
let output_dir = make_path("/vendor");
|
||||||
let roots = self
|
let roots = self.entry_points.clone();
|
||||||
.entry_points
|
|
||||||
.iter()
|
|
||||||
.map(|s| (s.to_owned(), deno_graph::ModuleKind::Esm))
|
|
||||||
.collect();
|
|
||||||
let loader = self.loader.clone();
|
let loader = self.loader.clone();
|
||||||
let parsed_source_cache = ParsedSourceCache::new(None);
|
let parsed_source_cache = ParsedSourceCache::new(None);
|
||||||
let analyzer = parsed_source_cache.as_analyzer();
|
let analyzer = parsed_source_cache.as_analyzer();
|
||||||
|
@ -260,7 +255,7 @@ impl VendorTestBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn build_test_graph(
|
async fn build_test_graph(
|
||||||
roots: Vec<(ModuleSpecifier, ModuleKind)>,
|
roots: Vec<ModuleSpecifier>,
|
||||||
original_import_map: Option<ImportMap>,
|
original_import_map: Option<ImportMap>,
|
||||||
mut loader: TestLoader,
|
mut loader: TestLoader,
|
||||||
analyzer: &dyn deno_graph::ModuleAnalyzer,
|
analyzer: &dyn deno_graph::ModuleAnalyzer,
|
||||||
|
|
|
@ -863,7 +863,6 @@ mod tests {
|
||||||
use crate::args::TsConfig;
|
use crate::args::TsConfig;
|
||||||
use deno_core::futures::future;
|
use deno_core::futures::future;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_graph::ModuleKind;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
@ -907,7 +906,7 @@ mod tests {
|
||||||
let fixtures = test_util::testdata_path().join("tsc2");
|
let fixtures = test_util::testdata_path().join("tsc2");
|
||||||
let mut loader = MockLoader { fixtures };
|
let mut loader = MockLoader { fixtures };
|
||||||
let graph = deno_graph::create_graph(
|
let graph = deno_graph::create_graph(
|
||||||
vec![(specifier, ModuleKind::Esm)],
|
vec![specifier],
|
||||||
&mut loader,
|
&mut loader,
|
||||||
deno_graph::GraphOptions {
|
deno_graph::GraphOptions {
|
||||||
is_dynamic: false,
|
is_dynamic: false,
|
||||||
|
@ -939,7 +938,7 @@ mod tests {
|
||||||
let fixtures = test_util::testdata_path().join("tsc2");
|
let fixtures = test_util::testdata_path().join("tsc2");
|
||||||
let mut loader = MockLoader { fixtures };
|
let mut loader = MockLoader { fixtures };
|
||||||
let graph = deno_graph::create_graph(
|
let graph = deno_graph::create_graph(
|
||||||
vec![(specifier.clone(), ModuleKind::Esm)],
|
vec![specifier.clone()],
|
||||||
&mut loader,
|
&mut loader,
|
||||||
deno_graph::GraphOptions {
|
deno_graph::GraphOptions {
|
||||||
is_dynamic: false,
|
is_dynamic: false,
|
||||||
|
|
Loading…
Reference in a new issue