summaryrefslogtreecommitdiff
path: root/cli/worker.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-03-20 00:40:21 -0400
committerGitHub <noreply@github.com>2023-03-20 00:40:21 -0400
commitaba5329aec06a92b591ef92ddc40ac0d25c870fa (patch)
treefc6ef43dac484b2a50a983c937c9c25f379d0cc8 /cli/worker.rs
parent090169cfbc6699486765b729d532b5b837210b12 (diff)
refactor(ext/node): make initialization functions sync (#18282)
These functions don't need to be async, as they are only calling synchronous JavaScript code. As a follow up, all 3 functions should be merge together - this will reduce roundtrips for calling V8 from Rust, which is somewhat expensive
Diffstat (limited to 'cli/worker.rs')
-rw-r--r--cli/worker.rs15
1 files changed, 6 insertions, 9 deletions
diff --git a/cli/worker.rs b/cli/worker.rs
index b9e1fab8e..2d467e01d 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -67,7 +67,7 @@ impl CliMainWorker {
log::debug!("main_module {}", self.main_module);
if self.is_main_cjs {
- self.initialize_main_module_for_node().await?;
+ self.initialize_main_module_for_node()?;
deno_node::load_cjs_module(
&mut self.worker.js_runtime,
&self.main_module.to_file_path().unwrap().to_string_lossy(),
@@ -295,17 +295,16 @@ impl CliMainWorker {
) -> Result<(), AnyError> {
if self.ps.npm_resolver.has_packages() || self.ps.graph().has_node_specifier
{
- self.initialize_main_module_for_node().await?;
+ self.initialize_main_module_for_node()?;
}
self.worker.evaluate_module(id).await
}
- async fn initialize_main_module_for_node(&mut self) -> Result<(), AnyError> {
+ fn initialize_main_module_for_node(&mut self) -> Result<(), AnyError> {
deno_node::initialize_runtime(
&mut self.worker.js_runtime,
self.ps.options.has_node_modules_dir(),
- )
- .await?;
+ )?;
if let DenoSubcommand::Run(flags) = self.ps.options.sub_command() {
if let Ok(pkg_ref) = NpmPackageReqReference::from_str(&flags.script) {
// if the user ran a binary command, we'll need to set process.argv[0]
@@ -317,8 +316,7 @@ impl CliMainWorker {
deno_node::initialize_binary_command(
&mut self.worker.js_runtime,
binary_name,
- )
- .await?;
+ )?;
}
}
Ok(())
@@ -629,8 +627,7 @@ fn create_web_worker_pre_execute_module_callback(
deno_node::initialize_runtime(
&mut worker.js_runtime,
ps.options.has_node_modules_dir(),
- )
- .await?;
+ )?;
}
Ok(worker)