summaryrefslogtreecommitdiff
path: root/core/runtime.rs
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2021-06-19 15:14:43 +0100
committerGitHub <noreply@github.com>2021-06-19 16:14:43 +0200
commit2ea41d3ac159e4c2e998d13412dc19680b01a6ca (patch)
treec771d33f481c1bbc1b82f758ec96bfa5c342389c /core/runtime.rs
parentb0c04a7941bb1bab0f135c39d484ac47dae14300 (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 'core/runtime.rs')
-rw-r--r--core/runtime.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/core/runtime.rs b/core/runtime.rs
index 71aad8e0b..0dad94128 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -1253,11 +1253,10 @@ impl JsRuntime {
) -> Result<ModuleId, AnyError> {
let module_map_rc = Self::module_map(self.v8_isolate());
- let load = module_map_rc.borrow().load_main(specifier.as_str(), code);
-
- let (_load_id, prepare_result) = load.prepare().await;
-
- let mut load = prepare_result?;
+ let mut load = module_map_rc
+ .borrow()
+ .load_main(specifier.as_str(), code)
+ .await?;
while let Some(info_result) = load.next().await {
let info = info_result?;
@@ -1268,7 +1267,8 @@ impl JsRuntime {
}
let root_id = load.expect_finished();
- self.instantiate_module(root_id).map(|_| root_id)
+ self.instantiate_module(root_id)?;
+ Ok(root_id)
}
fn poll_pending_ops(