diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 5844b0fa7b..accdeae7ff 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -63,7 +63,7 @@ pub struct CliOptions { } impl CliOptions { - pub fn from_flags(flags: Flags) -> Result { + pub fn new(flags: Flags, maybe_config_file: Option) -> Self { if let Some(insecure_allowlist) = flags.unsafely_ignore_certificate_errors.as_ref() { @@ -74,15 +74,20 @@ impl CliOptions { }; let msg = format!("DANGER: TLS certificate validation is disabled {}", domains); + // use eprintln instead of log::warn so this always gets shown eprintln!("{}", colors::yellow(msg)); } - let maybe_config_file = ConfigFile::discover(&flags)?; - Ok(Self { + Self { maybe_config_file, flags, overrides: Default::default(), - }) + } + } + + pub fn from_flags(flags: Flags) -> Result { + let maybe_config_file = ConfigFile::discover(&flags)?; + Ok(Self::new(flags, maybe_config_file)) } pub fn maybe_config_file_specifier(&self) -> Option { @@ -340,7 +345,7 @@ fn resolve_import_map_specifier( if let Some(import_map_path) = maybe_import_map_path { if let Some(config_file) = &maybe_config_file { if config_file.to_import_map_path().is_some() { - log::warn!("{} the configuration file \"{}\" contains an entry for \"importMap\" that is being ignored.", crate::colors::yellow("Warning"), config_file.specifier); + log::warn!("{} the configuration file \"{}\" contains an entry for \"importMap\" that is being ignored.", colors::yellow("Warning"), config_file.specifier); } } let specifier = deno_core::resolve_url_or_path(import_map_path) diff --git a/cli/lsp/cache.rs b/cli/lsp/cache.rs index fc8b50c4a7..77f356486d 100644 --- a/cli/lsp/cache.rs +++ b/cli/lsp/cache.rs @@ -1,123 +1,14 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -use crate::args::ConfigFile; -use crate::args::Flags; -use crate::cache::FetchCacher; -use crate::graph_util::graph_valid; use crate::http_cache; -use crate::proc_state::ProcState; -use crate::resolver::ImportMapResolver; -use crate::resolver::JsxResolver; -use deno_core::anyhow::anyhow; -use deno_core::error::AnyError; use deno_core::parking_lot::Mutex; use deno_core::ModuleSpecifier; -use deno_runtime::permissions::Permissions; -use deno_runtime::tokio_util::create_basic_runtime; -use import_map::ImportMap; use std::collections::HashMap; use std::fs; use std::path::Path; -use std::path::PathBuf; use std::sync::Arc; -use std::thread; use std::time::SystemTime; -use tokio::sync::mpsc; -use tokio::sync::oneshot; - -type Request = ( - Vec<(ModuleSpecifier, deno_graph::ModuleKind)>, - oneshot::Sender>, -); - -/// A "server" that handles requests from the language server to cache modules -/// in its own thread. -#[derive(Debug)] -pub struct CacheServer(mpsc::UnboundedSender); - -impl CacheServer { - pub async fn new( - maybe_cache_path: Option, - maybe_import_map: Option>, - maybe_config_file: Option, - maybe_ca_stores: Option>, - maybe_ca_file: Option, - unsafely_ignore_certificate_errors: Option>, - ) -> Self { - let (tx, mut rx) = mpsc::unbounded_channel::(); - let _join_handle = thread::spawn(move || { - let runtime = create_basic_runtime(); - runtime.block_on(async { - let ps = ProcState::build(Flags { - cache_path: maybe_cache_path, - ca_stores: maybe_ca_stores, - ca_file: maybe_ca_file, - unsafely_ignore_certificate_errors, - ..Default::default() - }) - .await - .unwrap(); - let maybe_import_map_resolver = - maybe_import_map.map(ImportMapResolver::new); - let maybe_jsx_resolver = maybe_config_file.as_ref().and_then(|cf| { - cf.to_maybe_jsx_import_source_module() - .map(|im| JsxResolver::new(im, maybe_import_map_resolver.clone())) - }); - let maybe_resolver = if maybe_jsx_resolver.is_some() { - maybe_jsx_resolver.as_ref().map(|jr| jr.as_resolver()) - } else { - maybe_import_map_resolver - .as_ref() - .map(|im| im.as_resolver()) - }; - let maybe_imports = maybe_config_file - .and_then(|cf| cf.to_maybe_imports().ok()) - .flatten(); - let mut cache = FetchCacher::new( - ps.dir.gen_cache.clone(), - ps.file_fetcher.clone(), - Permissions::allow_all(), - Permissions::allow_all(), - ); - - while let Some((roots, tx)) = rx.recv().await { - let graph = deno_graph::create_graph( - roots, - false, - maybe_imports.clone(), - &mut cache, - maybe_resolver, - None, - None, - None, - ) - .await; - - if tx.send(graph_valid(&graph, true, false)).is_err() { - log::warn!("cannot send to client"); - } - } - }) - }); - - Self(tx) - } - - /// Attempt to cache the supplied module specifiers and their dependencies in - /// the current DENO_DIR, returning any errors, so they can be returned to the - /// client. - pub async fn cache( - &self, - roots: Vec<(ModuleSpecifier, deno_graph::ModuleKind)>, - ) -> Result<(), AnyError> { - let (tx, rx) = oneshot::channel::>(); - if self.0.send((roots, tx)).is_err() { - return Err(anyhow!("failed to send request to cache thread")); - } - rx.await? - } -} /// Calculate a version for for a given path. pub fn calculate_fs_version(path: &Path) -> Option { diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 1e9da54d6d..41323a3009 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -8,6 +8,8 @@ use deno_core::serde_json; use deno_core::serde_json::json; use deno_core::serde_json::Value; use deno_core::ModuleSpecifier; +use deno_graph::ModuleKind; +use deno_runtime::tokio_util::run_basic; use import_map::ImportMap; use log::error; use log::warn; @@ -55,14 +57,18 @@ use super::tsc::Assets; use super::tsc::AssetsSnapshot; use super::tsc::TsServer; use super::urls; +use crate::args::CliOptions; use crate::args::ConfigFile; +use crate::args::Flags; use crate::args::FmtConfig; use crate::args::LintConfig; use crate::args::TsConfig; use crate::deno_dir; use crate::file_fetcher::get_source_from_data_url; use crate::fs_util; +use crate::graph_util::graph_valid; use crate::proc_state::import_map_from_text; +use crate::proc_state::ProcState; use crate::tools::fmt::format_file; use crate::tools::fmt::format_parsed_source; @@ -104,8 +110,6 @@ pub struct Inner { /// An optional path to the DENO_DIR which has been specified in the client /// options. maybe_cache_path: Option, - /// A lazily created "server" for handling cache requests. - maybe_cache_server: Option, /// An optional configuration file which has been specified in the client /// options. maybe_config_file: Option, @@ -246,7 +250,6 @@ impl Inner { diagnostics_server, documents, maybe_cache_path: None, - maybe_cache_server: None, maybe_config_file: None, maybe_import_map: None, maybe_import_map_uri: None, @@ -429,7 +432,6 @@ impl Inner { pub fn update_cache(&mut self) -> Result<(), AnyError> { let mark = self.performance.mark("update_cache", None::<()>); self.performance.measure(mark); - self.maybe_cache_server = None; let maybe_cache = self.config.get_workspace_settings().cache; let maybe_cache_path = if let Some(cache_str) = &maybe_cache { lsp_log!("Setting cache path from: \"{}\"", cache_str); @@ -489,7 +491,6 @@ impl Inner { pub async fn update_import_map(&mut self) -> Result<(), AnyError> { let mark = self.performance.mark("update_import_map", None::<()>); - self.maybe_cache_server = None; let maybe_import_map_url = if let Some(import_map_str) = self.config.get_workspace_settings().import_map { @@ -2775,6 +2776,16 @@ impl Inner { &mut self, params: lsp_custom::CacheParams, ) -> LspResult> { + async fn create_graph_for_caching( + cli_options: CliOptions, + roots: Vec<(ModuleSpecifier, ModuleKind)>, + ) -> Result<(), AnyError> { + let ps = ProcState::from_options(Arc::new(cli_options)).await?; + let graph = ps.create_graph(roots).await?; + graph_valid(&graph, true, false)?; + Ok(()) + } + let referrer = self.url_map.normalize_url(¶ms.referrer.uri); if !self.is_diagnosable(&referrer) { return Ok(None); @@ -2796,21 +2807,26 @@ impl Inner { vec![(referrer.clone(), deno_graph::ModuleKind::Esm)] }; - if self.maybe_cache_server.is_none() { - self.maybe_cache_server = Some( - cache::CacheServer::new( - self.maybe_cache_path.clone(), - self.maybe_import_map.clone(), - self.maybe_config_file.clone(), - None, - None, - None, - ) - .await, - ); - } - let cache_server = self.maybe_cache_server.as_ref().unwrap(); - if let Err(err) = cache_server.cache(roots).await { + let mut cli_options = CliOptions::new( + Flags { + cache_path: self.maybe_cache_path.clone(), + ca_stores: None, + ca_file: None, + unsafely_ignore_certificate_errors: None, + ..Default::default() + }, + self.maybe_config_file.clone(), + ); + cli_options.set_import_map_specifier(self.maybe_import_map_uri.clone()); + + // todo(dsherret): why is running this on a new thread necessary? It does + // a compile error otherwise. + let handle = tokio::task::spawn_blocking(|| { + run_basic( + async move { create_graph_for_caching(cli_options, roots).await }, + ) + }); + if let Err(err) = handle.await.unwrap() { self.client.show_message(MessageType::WARNING, err).await; } diff --git a/cli/main.rs b/cli/main.rs index 4cbb49ecac..2747d763cb 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -450,37 +450,9 @@ async fn info_command( let ps = ProcState::build(flags).await?; if let Some(specifier) = info_flags.file { let specifier = resolve_url_or_path(&specifier)?; - let mut cache = cache::FetchCacher::new( - ps.dir.gen_cache.clone(), - ps.file_fetcher.clone(), - Permissions::allow_all(), - Permissions::allow_all(), - ); - let maybe_locker = lockfile::as_maybe_locker(ps.lockfile.clone()); - let maybe_import_map_resolver = - ps.maybe_import_map.clone().map(ImportMapResolver::new); - let maybe_jsx_resolver = ps - .options - .to_maybe_jsx_import_source_module() - .map(|im| JsxResolver::new(im, maybe_import_map_resolver.clone())); - let maybe_resolver = if maybe_jsx_resolver.is_some() { - maybe_jsx_resolver.as_ref().map(|jr| jr.as_resolver()) - } else { - maybe_import_map_resolver - .as_ref() - .map(|im| im.as_resolver()) - }; - let graph = deno_graph::create_graph( - vec![(specifier, deno_graph::ModuleKind::Esm)], - false, - None, - &mut cache, - maybe_resolver, - maybe_locker, - None, - None, - ) - .await; + let graph = ps + .create_graph(vec![(specifier, deno_graph::ModuleKind::Esm)]) + .await?; if info_flags.json { write_json_to_stdout(&json!(graph))?; diff --git a/cli/proc_state.rs b/cli/proc_state.rs index b6b09c948d..7154693daa 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -591,6 +591,47 @@ impl ProcState { )), } } + + pub async fn create_graph( + &self, + roots: Vec<(ModuleSpecifier, ModuleKind)>, + ) -> Result { + let mut cache = cache::FetchCacher::new( + self.dir.gen_cache.clone(), + self.file_fetcher.clone(), + Permissions::allow_all(), + Permissions::allow_all(), + ); + let maybe_locker = as_maybe_locker(self.lockfile.clone()); + let maybe_import_map_resolver = + self.maybe_import_map.clone().map(ImportMapResolver::new); + let maybe_imports = self.options.to_maybe_imports()?; + let maybe_jsx_resolver = self + .options + .to_maybe_jsx_import_source_module() + .map(|im| JsxResolver::new(im, maybe_import_map_resolver.clone())); + let maybe_resolver = if maybe_jsx_resolver.is_some() { + maybe_jsx_resolver.as_ref().map(|jr| jr.as_resolver()) + } else { + maybe_import_map_resolver + .as_ref() + .map(|im| im.as_resolver()) + }; + + Ok( + deno_graph::create_graph( + roots, + false, + maybe_imports, + &mut cache, + maybe_resolver, + maybe_locker, + None, + None, + ) + .await, + ) + } } // TODO(@kitsonk) this is only temporary, but should be refactored to somewhere diff --git a/cli/tools/bench.rs b/cli/tools/bench.rs index 9dfe2cd379..3946435dfd 100644 --- a/cli/tools/bench.rs +++ b/cli/tools/bench.rs @@ -3,7 +3,6 @@ use crate::args::BenchFlags; use crate::args::Flags; use crate::args::TypeCheckMode; -use crate::cache; use crate::colors; use crate::compat; use crate::create_main_worker; @@ -14,11 +13,8 @@ use crate::fs_util::is_supported_bench_path; use crate::graph_util::contains_specifier; use crate::graph_util::graph_valid; use crate::located_script_name; -use crate::lockfile; use crate::ops; use crate::proc_state::ProcState; -use crate::resolver::ImportMapResolver; -use crate::resolver::JsxResolver; use crate::tools::test::format_test_error; use crate::tools::test::TestFilter; @@ -571,28 +567,13 @@ pub async fn run_benchmarks_with_watch( let no_check = ps.options.type_check_mode() == TypeCheckMode::None; let resolver = |changed: Option>| { - let mut cache = cache::FetchCacher::new( - ps.dir.gen_cache.clone(), - ps.file_fetcher.clone(), - Permissions::allow_all(), - Permissions::allow_all(), - ); - let paths_to_watch = paths_to_watch.clone(); let paths_to_watch_clone = paths_to_watch.clone(); - let maybe_import_map_resolver = - ps.maybe_import_map.clone().map(ImportMapResolver::new); - let maybe_jsx_resolver = ps - .options - .to_maybe_jsx_import_source_module() - .map(|im| JsxResolver::new(im, maybe_import_map_resolver.clone())); - let maybe_locker = lockfile::as_maybe_locker(ps.lockfile.clone()); - let maybe_imports_result = ps.options.to_maybe_imports(); let files_changed = changed.is_some(); let include = include.clone(); let ignore = ignore.clone(); - let check_js = ps.options.check_js(); + let ps = ps.clone(); async move { let bench_modules = @@ -607,29 +588,15 @@ pub async fn run_benchmarks_with_watch( .map(|url| (url.clone(), ModuleKind::Esm)) .collect() }; - let maybe_imports = maybe_imports_result?; - let maybe_resolver = if maybe_jsx_resolver.is_some() { - maybe_jsx_resolver.as_ref().map(|jr| jr.as_resolver()) - } else { - maybe_import_map_resolver - .as_ref() - .map(|im| im.as_resolver()) - }; - let graph = deno_graph::create_graph( - bench_modules - .iter() - .map(|s| (s.clone(), ModuleKind::Esm)) - .collect(), - false, - maybe_imports, - &mut cache, - maybe_resolver, - maybe_locker, - None, - None, - ) - .await; - graph_valid(&graph, !no_check, check_js)?; + let graph = ps + .create_graph( + bench_modules + .iter() + .map(|s| (s.clone(), ModuleKind::Esm)) + .collect(), + ) + .await?; + graph_valid(&graph, !no_check, ps.options.check_js())?; // TODO(@kitsonk) - This should be totally derivable from the graph. for specifier in bench_modules { diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs index fbb784f980..ae0f37f1b7 100644 --- a/cli/tools/doc.rs +++ b/cli/tools/doc.rs @@ -9,88 +9,13 @@ use crate::proc_state::ProcState; use crate::write_json_to_stdout; use crate::write_to_stdout_ignore_sigpipe; use deno_ast::MediaType; +use deno_core::anyhow::bail; use deno_core::error::AnyError; -use deno_core::futures::future; -use deno_core::futures::future::FutureExt; use deno_core::resolve_url_or_path; use deno_doc as doc; -use deno_graph::create_graph; -use deno_graph::source::LoadFuture; -use deno_graph::source::LoadResponse; -use deno_graph::source::Loader; -use deno_graph::source::ResolveResponse; -use deno_graph::source::Resolver; use deno_graph::ModuleKind; use deno_graph::ModuleSpecifier; -use deno_runtime::permissions::Permissions; -use import_map::ImportMap; use std::path::PathBuf; -use std::sync::Arc; - -struct StubDocLoader; - -impl Loader for StubDocLoader { - fn load( - &mut self, - _specifier: &ModuleSpecifier, - _is_dynamic: bool, - ) -> LoadFuture { - Box::pin(future::ready(Ok(None))) - } -} - -#[derive(Debug)] -struct DocResolver { - import_map: Option>, -} - -impl Resolver for DocResolver { - fn resolve( - &self, - specifier: &str, - referrer: &ModuleSpecifier, - ) -> ResolveResponse { - if let Some(import_map) = &self.import_map { - return match import_map.resolve(specifier, referrer) { - Ok(specifier) => ResolveResponse::Specifier(specifier), - Err(err) => ResolveResponse::Err(err.into()), - }; - } - - match deno_core::resolve_import(specifier, referrer.as_str()) { - Ok(specifier) => ResolveResponse::Specifier(specifier), - Err(err) => ResolveResponse::Err(err.into()), - } - } -} - -struct DocLoader { - ps: ProcState, -} - -impl Loader for DocLoader { - fn load( - &mut self, - specifier: &ModuleSpecifier, - _is_dynamic: bool, - ) -> LoadFuture { - let specifier = specifier.clone(); - let ps = self.ps.clone(); - async move { - ps.file_fetcher - .fetch(&specifier, &mut Permissions::allow_all()) - .await - .map(|file| { - Some(LoadResponse::Module { - specifier, - content: file.source.clone(), - maybe_headers: file.maybe_headers, - }) - }) - } - .boxed_local() - } -} pub async fn print_docs( flags: Flags, @@ -102,28 +27,19 @@ pub async fn print_docs( .unwrap_or_else(|| "--builtin".to_string()); let source_parser = deno_graph::DefaultSourceParser::new(); - let parse_result = if source_file == "--builtin" { - let mut loader = StubDocLoader; + let mut doc_nodes = if source_file == "--builtin" { let source_file_specifier = ModuleSpecifier::parse("deno://lib.deno.d.ts").unwrap(); - let graph = create_graph( - vec![(source_file_specifier.clone(), ModuleKind::Esm)], - false, - None, - &mut loader, - None, - None, - None, - None, - ) - .await; + let graph = ps + .create_graph(vec![(source_file_specifier.clone(), ModuleKind::Esm)]) + .await?; let doc_parser = doc::DocParser::new(graph, doc_flags.private, &source_parser); doc_parser.parse_source( &source_file_specifier, MediaType::Dts, get_types(ps.options.unstable()).into(), - ) + )? } else { let module_specifier = resolve_url_or_path(&source_file)?; @@ -142,32 +58,12 @@ pub async fn print_docs( // Save our fake file into file fetcher cache. ps.file_fetcher.insert_cached(root); - let mut loader = DocLoader { ps: ps.clone() }; - let resolver = DocResolver { - import_map: ps.maybe_import_map.clone(), - }; - let graph = create_graph( - vec![(root_specifier.clone(), ModuleKind::Esm)], - false, - None, - &mut loader, - Some(&resolver), - None, - None, - None, - ) - .await; + let graph = ps + .create_graph(vec![(root_specifier.clone(), ModuleKind::Esm)]) + .await?; let doc_parser = doc::DocParser::new(graph, doc_flags.private, &source_parser); - doc_parser.parse_with_reexports(&root_specifier) - }; - - let mut doc_nodes = match parse_result { - Ok(nodes) => nodes, - Err(e) => { - eprintln!("{}", e); - std::process::exit(1); - } + doc_parser.parse_with_reexports(&root_specifier)? }; if doc_flags.json { @@ -178,8 +74,7 @@ pub async fn print_docs( let nodes = doc::find_nodes_by_name_recursively(doc_nodes, filter.clone()); if nodes.is_empty() { - eprintln!("Node {} was not found!", filter); - std::process::exit(1); + bail!("Node {} was not found!", filter); } format!( "{}", diff --git a/cli/tools/test.rs b/cli/tools/test.rs index 4bebe6feea..5586026ccc 100644 --- a/cli/tools/test.rs +++ b/cli/tools/test.rs @@ -3,7 +3,6 @@ use crate::args::Flags; use crate::args::TestFlags; use crate::args::TypeCheckMode; -use crate::cache; use crate::colors; use crate::compat; use crate::create_main_worker; @@ -18,11 +17,8 @@ use crate::fs_util::is_supported_test_path; use crate::graph_util::contains_specifier; use crate::graph_util::graph_valid; use crate::located_script_name; -use crate::lockfile; use crate::ops; use crate::proc_state::ProcState; -use crate::resolver::ImportMapResolver; -use crate::resolver::JsxResolver; use crate::tools::coverage::CoverageCollector; use deno_ast::swc::common::comments::CommentKind; @@ -1394,28 +1390,13 @@ pub async fn run_tests_with_watch( let no_check = ps.options.type_check_mode() == TypeCheckMode::None; let resolver = |changed: Option>| { - let mut cache = cache::FetchCacher::new( - ps.dir.gen_cache.clone(), - ps.file_fetcher.clone(), - Permissions::allow_all(), - Permissions::allow_all(), - ); - let paths_to_watch = paths_to_watch.clone(); let paths_to_watch_clone = paths_to_watch.clone(); - let maybe_import_map_resolver = - ps.maybe_import_map.clone().map(ImportMapResolver::new); - let maybe_jsx_resolver = ps - .options - .to_maybe_jsx_import_source_module() - .map(|im| JsxResolver::new(im, maybe_import_map_resolver.clone())); - let maybe_locker = lockfile::as_maybe_locker(ps.lockfile.clone()); - let maybe_imports_result = ps.options.to_maybe_imports(); let files_changed = changed.is_some(); let include = include.clone(); let ignore = ignore.clone(); - let check_js = ps.options.check_js(); + let ps = ps.clone(); async move { let test_modules = if test_flags.doc { @@ -1433,29 +1414,15 @@ pub async fn run_tests_with_watch( .map(|url| (url.clone(), ModuleKind::Esm)) .collect() }; - let maybe_imports = maybe_imports_result?; - let maybe_resolver = if maybe_jsx_resolver.is_some() { - maybe_jsx_resolver.as_ref().map(|jr| jr.as_resolver()) - } else { - maybe_import_map_resolver - .as_ref() - .map(|im| im.as_resolver()) - }; - let graph = deno_graph::create_graph( - test_modules - .iter() - .map(|s| (s.clone(), ModuleKind::Esm)) - .collect(), - false, - maybe_imports, - &mut cache, - maybe_resolver, - maybe_locker, - None, - None, - ) - .await; - graph_valid(&graph, !no_check, check_js)?; + let graph = ps + .create_graph( + test_modules + .iter() + .map(|s| (s.clone(), ModuleKind::Esm)) + .collect(), + ) + .await?; + graph_valid(&graph, !no_check, ps.options.check_js())?; // TODO(@kitsonk) - This should be totally derivable from the graph. for specifier in test_modules { diff --git a/cli/tools/vendor/mod.rs b/cli/tools/vendor/mod.rs index 48f6ea7f10..a7b26aa793 100644 --- a/cli/tools/vendor/mod.rs +++ b/cli/tools/vendor/mod.rs @@ -9,7 +9,6 @@ use deno_core::anyhow::bail; use deno_core::anyhow::Context; use deno_core::error::AnyError; use deno_core::resolve_url_or_path; -use deno_runtime::permissions::Permissions; use log::warn; use crate::args::CliOptions; @@ -19,10 +18,7 @@ use crate::args::VendorFlags; use crate::fs_util; use crate::fs_util::relative_specifier; use crate::fs_util::specifier_to_file_path; -use crate::lockfile; use crate::proc_state::ProcState; -use crate::resolver::ImportMapResolver; -use crate::resolver::JsxResolver; use crate::tools::fmt::format_json; mod analyze; @@ -271,43 +267,7 @@ async fn create_graph( }) .collect::, AnyError>>()?; - // todo(dsherret): there is a lot of copy and paste here from - // other parts of the codebase. We should consolidate this. - let mut cache = crate::cache::FetchCacher::new( - ps.dir.gen_cache.clone(), - ps.file_fetcher.clone(), - Permissions::allow_all(), - Permissions::allow_all(), - ); - let maybe_locker = lockfile::as_maybe_locker(ps.lockfile.clone()); - let maybe_imports = ps.options.to_maybe_imports()?; - let maybe_import_map_resolver = - ps.maybe_import_map.clone().map(ImportMapResolver::new); - let maybe_jsx_resolver = ps - .options - .to_maybe_jsx_import_source_module() - .map(|im| JsxResolver::new(im, maybe_import_map_resolver.clone())); - let maybe_resolver = if maybe_jsx_resolver.is_some() { - maybe_jsx_resolver.as_ref().map(|jr| jr.as_resolver()) - } else { - maybe_import_map_resolver - .as_ref() - .map(|im| im.as_resolver()) - }; - - Ok( - deno_graph::create_graph( - entry_points, - false, - maybe_imports, - &mut cache, - maybe_resolver, - maybe_locker, - None, - None, - ) - .await, - ) + ps.create_graph(entry_points).await } #[cfg(test)]