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.
This commit is contained in:
David Sherret 2023-05-01 14:35:23 -04:00 committed by GitHub
parent 30628288ce
commit 9efed4c7a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 1140 additions and 725 deletions

View file

@ -19,7 +19,6 @@ use crate::args::TsConfigType;
use crate::args::TsTypeLib;
use crate::args::TypeCheckMode;
use crate::cache::Caches;
use crate::cache::DenoDir;
use crate::cache::FastInsecureHasher;
use crate::cache::TypeCheckCache;
use crate::npm::CliNpmResolver;
@ -39,7 +38,6 @@ pub struct CheckOptions {
}
pub struct TypeChecker {
deno_dir: DenoDir,
caches: Arc<Caches>,
cli_options: Arc<CliOptions>,
node_resolver: Arc<NodeResolver>,
@ -48,14 +46,12 @@ pub struct TypeChecker {
impl TypeChecker {
pub fn new(
deno_dir: DenoDir,
caches: Arc<Caches>,
cli_options: Arc<CliOptions>,
node_resolver: Arc<NodeResolver>,
npm_resolver: Arc<CliNpmResolver>,
) -> Self {
Self {
deno_dir,
caches,
cli_options,
node_resolver,
@ -95,8 +91,7 @@ impl TypeChecker {
let ts_config = ts_config_result.ts_config;
let type_check_mode = self.cli_options.type_check_mode();
let debug = self.cli_options.log_level() == Some(log::Level::Debug);
let cache =
TypeCheckCache::new(self.caches.type_checking_cache_db(&self.deno_dir));
let cache = TypeCheckCache::new(self.caches.type_checking_cache_db());
let check_js = ts_config.get_check_js();
let check_hash = match get_check_hash(&graph, type_check_mode, &ts_config) {
CheckHashResult::NoFiles => return Ok(()),