diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-05-01 14:35:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-01 14:35:23 -0400 |
commit | 9efed4c7a3d32de62e9c9b5e0c6712ce97637abb (patch) | |
tree | aa370f95df93c71f6c57d6a01a50b4df1955ee57 /cli/module_loader.rs | |
parent | 30628288ce2b411ca3def46129a4606073e16bac (diff) |
refactor(cli): remove ProcState - add CliFactory (#18900)
This removes `ProcState` and replaces it with a new `CliFactory` which
initializes our "service structs" on demand. This isn't a performance
improvement at the moment for `deno run`, but might unlock performance
improvements in the future.
Diffstat (limited to 'cli/module_loader.rs')
-rw-r--r-- | cli/module_loader.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/cli/module_loader.rs b/cli/module_loader.rs index d8a5b73c4..0ed84a20f 100644 --- a/cli/module_loader.rs +++ b/cli/module_loader.rs @@ -12,14 +12,13 @@ use crate::graph_util::ModuleGraphBuilder; use crate::graph_util::ModuleGraphContainer; use crate::node; use crate::node::CliNodeCodeTranslator; -use crate::proc_state::CjsResolutionStore; -use crate::proc_state::FileWatcherReporter; use crate::resolver::CliGraphResolver; use crate::tools::check; use crate::tools::check::TypeChecker; use crate::util::progress_bar::ProgressBar; use crate::util::text_encoding::code_without_source_map; use crate::util::text_encoding::source_map_from_code; +use crate::watcher::FileWatcherReporter; use crate::worker::ModuleLoaderFactory; use deno_ast::MediaType; @@ -791,3 +790,21 @@ impl NpmModuleLoader { Ok(response.into_url()) } } + +/// Keeps track of what module specifiers were resolved as CJS. +#[derive(Default)] +pub struct CjsResolutionStore(Mutex<HashSet<ModuleSpecifier>>); + +impl CjsResolutionStore { + pub fn clear(&self) { + self.0.lock().clear(); + } + + pub fn contains(&self, specifier: &ModuleSpecifier) -> bool { + self.0.lock().contains(specifier) + } + + pub fn insert(&self, specifier: ModuleSpecifier) { + self.0.lock().insert(specifier); + } +} |