diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2021-06-19 15:14:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-19 16:14:43 +0200 |
commit | 2ea41d3ac159e4c2e998d13412dc19680b01a6ca (patch) | |
tree | c771d33f481c1bbc1b82f758ec96bfa5c342389c /cli/program_state.rs | |
parent | b0c04a7941bb1bab0f135c39d484ac47dae14300 (diff) |
fix(core/modules): Prepare modules only once per runtime (#11015)
This commit changes module loading implementation in "deno_core"
to call "ModuleLoader::prepare" hook only once per entry point.
This is done to avoid multiple type checking of the same code
in case of duplicated dynamic imports.
Relevant code in "cli/module_graph.rs" was updated as well.
Diffstat (limited to 'cli/program_state.rs')
-rw-r--r-- | cli/program_state.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cli/program_state.rs b/cli/program_state.rs index 95362165f..668c73058 100644 --- a/cli/program_state.rs +++ b/cli/program_state.rs @@ -31,6 +31,7 @@ use deno_core::ModuleSpecifier; use log::debug; use log::warn; use std::collections::HashMap; +use std::collections::HashSet; use std::env; use std::fs::read; use std::sync::Arc; @@ -177,12 +178,17 @@ impl ProgramState { let mut graph = builder.get_graph(); let debug = self.flags.log_level == Some(log::Level::Debug); let maybe_config_file = self.maybe_config_file.clone(); + let reload_exclusions = { + let modules = self.modules.lock().unwrap(); + modules.keys().cloned().collect::<HashSet<_>>() + }; let result_modules = if self.flags.no_check { let result_info = graph.transpile(TranspileOptions { debug, maybe_config_file, reload: self.flags.reload, + reload_exclusions, })?; debug!("{}", result_info.stats); if let Some(ignored_options) = result_info.maybe_ignored_options { @@ -196,6 +202,7 @@ impl ProgramState { lib, maybe_config_file, reload: self.flags.reload, + reload_exclusions, })?; debug!("{}", result_info.stats); @@ -244,12 +251,17 @@ impl ProgramState { let mut graph = builder.get_graph(); let debug = self.flags.log_level == Some(log::Level::Debug); let maybe_config_file = self.maybe_config_file.clone(); + let reload_exclusions = { + let modules = self.modules.lock().unwrap(); + modules.keys().cloned().collect::<HashSet<_>>() + }; let result_modules = if self.flags.no_check { let result_info = graph.transpile(TranspileOptions { debug, maybe_config_file, reload: self.flags.reload, + reload_exclusions, })?; debug!("{}", result_info.stats); if let Some(ignored_options) = result_info.maybe_ignored_options { @@ -263,6 +275,7 @@ impl ProgramState { lib, maybe_config_file, reload: self.flags.reload, + reload_exclusions, })?; debug!("{}", result_info.stats); |