diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-05-05 18:23:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-05 18:23:15 +0200 |
commit | cf5a39a36127e8df70ac34b9895771fb41d474a6 (patch) | |
tree | eb980f37b328902445ed5141b9c3c8a999ef84f7 /cli/ops/runtime_compiler.rs | |
parent | e574437922db0693e7be7a5df7c474f306e55f7b (diff) |
refactor(ts): remove op_cache (#5071)
This PR removes op_cache and refactors how Deno interacts with TS compiler.
Ultimate goal is to completely sandbox TS compiler worker; it should operate on
simple request -> response basis. With this commit TS compiler no longer
caches compiled sources as they are generated but rather collects all sources
and sends them back to Rust when compilation is done.
Additionally "Diagnostic" and its children got refactored to use "Deserialize" trait
instead of manually implementing JSON deserialization.
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)) } |