diff options
Diffstat (limited to 'cli/ops/runtime_compiler.rs')
-rw-r--r-- | cli/ops/runtime_compiler.rs | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/cli/ops/runtime_compiler.rs b/cli/ops/runtime_compiler.rs index 4c4110e1e..c7225b944 100644 --- a/cli/ops/runtime_compiler.rs +++ b/cli/ops/runtime_compiler.rs @@ -2,6 +2,7 @@ use super::dispatch_json::{Deserialize, JsonOp, Value}; use crate::compilers::runtime_compile; use crate::compilers::runtime_transpile; +use crate::futures::FutureExt; use crate::op_error::OpError; use crate::state::State; use deno_core::CoreIsolate; @@ -29,13 +30,19 @@ fn op_compile( ) -> Result<JsonOp, OpError> { state.check_unstable("Deno.compile"); let args: CompileArgs = serde_json::from_value(args)?; - Ok(JsonOp::Async(runtime_compile( - state.borrow().global_state.clone(), - &args.root_name, - &args.sources, - args.bundle, - &args.options, - ))) + let global_state = state.borrow().global_state.clone(); + let fut = async move { + runtime_compile( + global_state, + &args.root_name, + &args.sources, + args.bundle, + &args.options, + ) + .await + } + .boxed_local(); + Ok(JsonOp::Async(fut)) } #[derive(Deserialize, Debug)] @@ -51,9 +58,10 @@ fn op_transpile( ) -> Result<JsonOp, OpError> { state.check_unstable("Deno.transpile"); let args: TranspileArgs = serde_json::from_value(args)?; - Ok(JsonOp::Async(runtime_transpile( - state.borrow().global_state.clone(), - &args.sources, - &args.options, - ))) + let global_state = state.borrow().global_state.clone(); + let fut = async move { + runtime_transpile(global_state, &args.sources, &args.options).await + } + .boxed_local(); + Ok(JsonOp::Async(fut)) } |