summaryrefslogtreecommitdiff
path: root/cli/ops/compiler.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2020-02-25 09:14:27 -0500
committerGitHub <noreply@github.com>2020-02-25 09:14:27 -0500
commit91b606aaae23bcb790b55adc5fe70a182a37d564 (patch)
tree16b56a21ffcb3991569eda984fbd14073bdbd3ae /cli/ops/compiler.rs
parent805992b14a65a6dbfb857dea6d9b657477de043d (diff)
Clean up how we use opIds (#4118)
Diffstat (limited to 'cli/ops/compiler.rs')
-rw-r--r--cli/ops/compiler.rs40
1 files changed, 7 insertions, 33 deletions
diff --git a/cli/ops/compiler.rs b/cli/ops/compiler.rs
index a559bb539..015c77c4e 100644
--- a/cli/ops/compiler.rs
+++ b/cli/ops/compiler.rs
@@ -5,25 +5,22 @@ use super::dispatch_json::Value;
use crate::futures::future::try_join_all;
use crate::msg;
use crate::op_error::OpError;
-use crate::ops::json_op;
use crate::state::State;
use deno_core::Loader;
use deno_core::*;
use futures::future::FutureExt;
pub fn init(i: &mut Isolate, s: &State) {
- i.register_op("cache", s.core_op(json_op(s.stateful_op(op_cache))));
+ i.register_op("op_cache", s.stateful_json_op(op_cache));
+ i.register_op("op_resolve_modules", s.stateful_json_op(op_resolve_modules));
i.register_op(
- "resolve_modules",
- s.core_op(json_op(s.stateful_op(op_resolve_modules))),
+ "op_fetch_source_files",
+ s.stateful_json_op(op_fetch_source_files),
);
+ let custom_assets = std::collections::HashMap::new(); // TODO(ry) use None.
i.register_op(
- "fetch_source_files",
- s.core_op(json_op(s.stateful_op(op_fetch_source_files))),
- );
- i.register_op(
- "fetch_asset",
- s.core_op(json_op(s.stateful_op(op_fetch_asset))),
+ "op_fetch_asset",
+ deno_typescript::op_fetch_asset(custom_assets),
);
}
@@ -169,26 +166,3 @@ fn op_fetch_source_files(
Ok(JsonOp::Async(future))
}
-
-#[derive(Deserialize, Debug)]
-struct FetchRemoteAssetArgs {
- name: String,
-}
-
-fn op_fetch_asset(
- _state: &State,
- args: Value,
- _data: Option<ZeroCopyBuf>,
-) -> Result<JsonOp, OpError> {
- let args: FetchRemoteAssetArgs = serde_json::from_value(args)?;
- debug!("args.name: {}", args.name);
-
- let source_code =
- if let Some(source_code) = deno_typescript::get_asset(&args.name) {
- source_code.to_string()
- } else {
- panic!("Asset not found: \"{}\"", args.name)
- };
-
- Ok(JsonOp::Sync(json!({ "sourceCode": source_code })))
-}