mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +00:00
refactor: use JsRuntime to implement TSC (#7691)
This commits removes "CompilerWorker" in favor of using "JsRuntime". "cli/ops/compiler.rs" has been removed in favor of inline registration of ops in "cli/tsc.rs"
This commit is contained in:
parent
e0d4696a72
commit
ff785bc35a
8 changed files with 81 additions and 190 deletions
|
@ -1,32 +0,0 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use deno_core::serde_json::json;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
|
||||
pub fn init(
|
||||
rt: &mut deno_core::JsRuntime,
|
||||
response: Arc<Mutex<Option<String>>>,
|
||||
) {
|
||||
let custom_assets = std::collections::HashMap::new();
|
||||
// TODO(ry) use None.
|
||||
// TODO(bartlomieju): is this op even required?
|
||||
rt.register_op(
|
||||
"op_fetch_asset",
|
||||
crate::op_fetch_asset::op_fetch_asset(custom_assets),
|
||||
);
|
||||
|
||||
super::reg_json_sync(
|
||||
rt,
|
||||
"op_compiler_respond",
|
||||
move |_state, args, _bufs| {
|
||||
let mut response_slot = response.lock().unwrap();
|
||||
let replaced_value = response_slot.replace(args.to_string());
|
||||
assert!(
|
||||
replaced_value.is_none(),
|
||||
"op_compiler_respond found unexpected existing compiler output",
|
||||
);
|
||||
Ok(json!({}))
|
||||
},
|
||||
);
|
||||
}
|
|
@ -3,7 +3,6 @@
|
|||
mod dispatch_minimal;
|
||||
pub use dispatch_minimal::MinimalOp;
|
||||
|
||||
pub mod compiler;
|
||||
pub mod errors;
|
||||
pub mod fetch;
|
||||
pub mod fs;
|
||||
|
|
|
@ -80,12 +80,7 @@ async fn op_transpile(
|
|||
cli_state.check_unstable("Deno.transpile");
|
||||
let args: TranspileArgs = serde_json::from_value(args)?;
|
||||
let global_state = cli_state.clone();
|
||||
let permissions = {
|
||||
let state = state.borrow();
|
||||
state.borrow::<Permissions>().clone()
|
||||
};
|
||||
let result =
|
||||
runtime_transpile(&global_state, permissions, &args.sources, &args.options)
|
||||
.await?;
|
||||
runtime_transpile(global_state, &args.sources, &args.options).await?;
|
||||
Ok(result)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue