summaryrefslogtreecommitdiff
path: root/cli/module_loader.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-03-13 16:38:01 -0400
committerGitHub <noreply@github.com>2024-03-13 16:38:01 -0400
commit43d066cb7069c8c55aa555d7959a8612a52facc7 (patch)
treefd1bae2433e9544c8b08dae03c7608ab4df96cca /cli/module_loader.rs
parentc9a9d040a3b6773f186c5757b246abca1803eeb6 (diff)
fix: stop type checking during runtime (#22854)
In addition to the reasons for this outlined by @nayeemrmn in #14877 (which I think are reasons alone to not do this), this simplifies things a lot because then we don't need to implement the following: 1. Need to handle a JSR module dynamically importing a module within it. 2. Need to handle importing an export of a JSR dep then another export dynamically loaded later. Additionally, people should be running `deno check dynamic_import.ts` instead of relying on this behaviour. Landing this as a fix because it's blocking people in some scenarios and the current behaviour is broken (I didn't even have to change any tests to remove this, which is bad). Closes #22852 Closes #14877 Closes #22580
Diffstat (limited to 'cli/module_loader.rs')
-rw-r--r--cli/module_loader.rs22
1 files changed, 8 insertions, 14 deletions
diff --git a/cli/module_loader.rs b/cli/module_loader.rs
index 0ff7ef4ed..5149c4afb 100644
--- a/cli/module_loader.rs
+++ b/cli/module_loader.rs
@@ -55,7 +55,6 @@ use deno_runtime::permissions::PermissionsContainer;
use deno_semver::npm::NpmPackageReqReference;
use deno_terminal::colors;
use std::borrow::Cow;
-use std::collections::HashSet;
use std::pin::Pin;
use std::rc::Rc;
use std::str;
@@ -110,11 +109,7 @@ impl ModuleLoadPreparer {
let mut graph_update_permit =
self.graph_container.acquire_update_permit().await;
let graph = graph_update_permit.graph_mut();
-
- // Determine any modules that have already been emitted this session and
- // should be skipped.
- let reload_exclusions: HashSet<ModuleSpecifier> =
- graph.specifiers().map(|(s, _)| s.clone()).collect();
+ let has_type_checked = !graph.roots.is_empty();
self
.module_graph_builder
@@ -146,25 +141,24 @@ impl ModuleLoadPreparer {
drop(_pb_clear_guard);
// type check if necessary
- if self.options.type_check_mode().is_true()
- && !self.graph_container.is_type_checked(&roots, lib)
- {
- let graph = graph.segment(&roots);
+ if self.options.type_check_mode().is_true() && !has_type_checked {
self
.type_checker
.check(
- graph,
+ // todo(perf): since this is only done the first time the graph is
+ // created, we could avoid the clone of the graph here by providing
+ // the actual graph on the first run and then getting the Arc<ModuleGraph>
+ // back from the return value.
+ (*graph).clone(),
check::CheckOptions {
build_fast_check_graph: true,
lib,
log_ignored_options: false,
- reload: self.options.reload_flag()
- && !roots.iter().all(|r| reload_exclusions.contains(r)),
+ reload: self.options.reload_flag(),
type_check_mode: self.options.type_check_mode(),
},
)
.await?;
- self.graph_container.set_type_checked(&roots, lib);
}
log::debug!("Prepared module load.");