summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/BUILD.gn45
-rw-r--r--cli/assets.rs59
-rw-r--r--cli/main.rs6
-rw-r--r--cli/ops/compiler.rs19
-rw-r--r--cli/ops/mod.rs7
5 files changed, 90 insertions, 46 deletions
diff --git a/cli/BUILD.gn b/cli/BUILD.gn
index 23bc48fda..6704659db 100644
--- a/cli/BUILD.gn
+++ b/cli/BUILD.gn
@@ -61,7 +61,6 @@ if (is_posix) {
}
ts_sources = [
- "../js/assets.ts",
"../js/base64.ts",
"../js/blob.ts",
"../js/body.ts",
@@ -98,6 +97,7 @@ ts_sources = [
"../js/globals.ts",
"../js/headers.ts",
"../js/io.ts",
+ "../js/lib.deno_runtime.d.ts",
"../js/lib.web_assembly.d.ts",
"../js/link.ts",
"../js/location.ts",
@@ -200,55 +200,16 @@ rust_test("cli_test") {
env = [ "CARGO_PKG_VERSION=${deno_cargo_info.version}" ]
}
-# Generates the core TypeScript type library for deno that will be
-# included in the runtime bundle
-run_node("deno_runtime_declaration") {
- out_dir = target_gen_dir
- sources = ts_sources
- outputs = [
- "$out_dir/lib/lib.deno_runtime.d.ts",
- ]
- inputs = ts_sources + [
- "//tools/ts_library_builder/tsconfig.json",
- "//tools/ts_library_builder/main.ts",
- "//tools/ts_library_builder/build_library.ts",
- "//tools/ts_library_builder/ast_util.ts",
- ]
- args = [
- rebase_path("//node_modules/ts-node/dist/bin.js", root_build_dir),
- "--project",
- rebase_path("//tools/ts_library_builder/tsconfig.json"),
- "--skip-ignore",
- rebase_path("//tools/ts_library_builder/main.ts", root_build_dir),
- "--basePath",
- rebase_path("//", root_build_dir),
- "--inline",
- rebase_path("//js/lib.web_assembly.d.ts", root_build_dir),
- "--buildPath",
- rebase_path(root_build_dir, root_build_dir),
- "--outFile",
- rebase_path(outputs[0], root_build_dir),
- "--silent",
- ]
- if (is_debug) {
- args += [ "--debug" ]
- }
-}
-
bundle("main_bundle") {
+ sources = ts_sources
out_dir = "$target_gen_dir/bundle/"
out_name = "main"
- deps = [
- ":deno_runtime_declaration",
- ]
}
bundle("compiler_bundle") {
+ sources = ts_sources
out_dir = "$target_gen_dir/bundle/"
out_name = "compiler"
- deps = [
- ":deno_runtime_declaration",
- ]
}
# Generates $target_gen_dir/snapshot_deno.bin
diff --git a/cli/assets.rs b/cli/assets.rs
new file mode 100644
index 000000000..c7bfc484d
--- /dev/null
+++ b/cli/assets.rs
@@ -0,0 +1,59 @@
+static DENO_RUNTIME: &str = include_str!("../js/lib.deno_runtime.d.ts");
+
+macro_rules! inc {
+ ($e:expr) => {
+ Some(include_str!(concat!(
+ "../third_party/node_modules/typescript/lib/",
+ $e
+ )))
+ };
+}
+
+pub fn get_source_code(name: &str) -> Option<&'static str> {
+ match name {
+ "lib.deno_runtime.d.ts" => Some(DENO_RUNTIME),
+ "lib.es2015.collection.d.ts" => inc!("lib.es2015.collection.d.ts"),
+ "lib.es2015.core.d.ts" => inc!("lib.es2015.core.d.ts"),
+ "lib.es2015.d.ts" => inc!("lib.es2015.d.ts"),
+ "lib.es2015.generator.d.ts" => inc!("lib.es2015.generator.d.ts"),
+ "lib.es2015.iterable.d.ts" => inc!("lib.es2015.iterable.d.ts"),
+ "lib.es2015.promise.d.ts" => inc!("lib.es2015.promise.d.ts"),
+ "lib.es2015.proxy.d.ts" => inc!("lib.es2015.proxy.d.ts"),
+ "lib.es2015.reflect.d.ts" => inc!("lib.es2015.reflect.d.ts"),
+ "lib.es2015.symbol.d.ts" => inc!("lib.es2015.symbol.d.ts"),
+ "lib.es2015.symbol.wellknown.d.ts" => {
+ inc!("lib.es2015.symbol.wellknown.d.ts")
+ }
+ "lib.es2016.array.include.d.ts" => inc!("lib.es2016.array.include.d.ts"),
+ "lib.es2016.d.ts" => inc!("lib.es2016.d.ts"),
+ "lib.es2017.d.ts" => inc!("lib.es2017.d.ts"),
+ "lib.es2017.intl.d.ts" => inc!("lib.es2017.intl.d.ts"),
+ "lib.es2017.object.d.ts" => inc!("lib.es2017.object.d.ts"),
+ "lib.es2017.sharedmemory.d.ts" => inc!("lib.es2017.sharedmemory.d.ts"),
+ "lib.es2017.string.d.ts" => inc!("lib.es2017.string.d.ts"),
+ "lib.es2017.typedarrays.d.ts" => inc!("lib.es2017.typedarrays.d.ts"),
+ "lib.es2018.d.ts" => inc!("lib.es2018.d.ts"),
+ "lib.es2018.asynciterable.d.ts" => inc!("lib.es2018.asynciterable.d.ts"),
+ "lib.es2018.intl.d.ts" => inc!("lib.es2018.intl.d.ts"),
+ "lib.es2018.promise.d.ts" => inc!("lib.es2018.promise.d.ts"),
+ "lib.es2018.regexp.d.ts" => inc!("lib.es2018.regexp.d.ts"),
+ "lib.es2019.d.ts" => inc!("lib.es2019.d.ts"),
+ "lib.es2019.array.d.ts" => inc!("lib.es2019.array.d.ts"),
+ "lib.es2019.object.d.ts" => inc!("lib.es2019.object.d.ts"),
+ "lib.es2019.string.d.ts" => inc!("lib.es2019.string.d.ts"),
+ "lib.es2019.symbol.d.ts" => inc!("lib.es2019.symbol.d.ts"),
+ "lib.es2020.d.ts" => inc!("lib.es2020.d.ts"),
+ "lib.es2020.string.d.ts" => inc!("lib.es2020.string.d.ts"),
+ "lib.es2020.symbol.wellknown.d.ts" => {
+ inc!("lib.es2020.symbol.wellknown.d.ts")
+ }
+ "lib.es5.d.ts" => inc!("lib.es5.d.ts"),
+ "lib.esnext.d.ts" => inc!("lib.esnext.d.ts"),
+ "lib.esnext.array.d.ts" => inc!("lib.esnext.array.d.ts"),
+ "lib.esnext.asynciterable.d.ts" => inc!("lib.esnext.asynciterable.d.ts"),
+ "lib.esnext.bigint.d.ts" => inc!("lib.esnext.bigint.d.ts"),
+ "lib.esnext.intl.d.ts" => inc!("lib.esnext.intl.d.ts"),
+ "lib.esnext.symbol.d.ts" => inc!("lib.esnext.symbol.d.ts"),
+ _ => None,
+ }
+}
diff --git a/cli/main.rs b/cli/main.rs
index a601e68af..53daa84f3 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -18,6 +18,7 @@ extern crate serde_derive;
extern crate url;
mod ansi;
+mod assets;
pub mod compilers;
pub mod deno_dir;
pub mod deno_error;
@@ -127,10 +128,7 @@ fn create_worker_and_state(
}
fn types_command() {
- let content = include_str!(concat!(
- env!("GN_OUT_DIR"),
- "/gen/cli/lib/lib.deno_runtime.d.ts"
- ));
+ let content = assets::get_source_code("lib.deno_runtime.d.ts").unwrap();
println!("{}", content);
}
diff --git a/cli/ops/compiler.rs b/cli/ops/compiler.rs
index 39d3a6d7f..40d25aa74 100644
--- a/cli/ops/compiler.rs
+++ b/cli/ops/compiler.rs
@@ -1,5 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
use super::dispatch_json::{Deserialize, JsonOp, Value};
+use crate::assets;
use crate::state::ThreadSafeState;
use crate::tokio_util;
use deno::*;
@@ -66,3 +67,21 @@ pub fn op_fetch_source_file(
"sourceCode": String::from_utf8(out.source_code).unwrap(),
})))
}
+
+#[derive(Deserialize)]
+struct FetchAssetArgs {
+ name: String,
+}
+
+pub fn op_fetch_asset(
+ _state: &ThreadSafeState,
+ args: Value,
+ _zero_copy: Option<PinnedBuf>,
+) -> Result<JsonOp, ErrBox> {
+ let args: FetchAssetArgs = serde_json::from_value(args)?;
+ if let Some(source_code) = assets::get_source_code(&args.name) {
+ Ok(JsonOp::Sync(json!(source_code)))
+ } else {
+ panic!("op_fetch_asset bad asset {}", args.name)
+ }
+}
diff --git a/cli/ops/mod.rs b/cli/ops/mod.rs
index 106948492..1f07acc65 100644
--- a/cli/ops/mod.rs
+++ b/cli/ops/mod.rs
@@ -80,6 +80,7 @@ pub const OP_READ_LINK: OpId = 53;
pub const OP_TRUNCATE: OpId = 54;
pub const OP_MAKE_TEMP_DIR: OpId = 55;
pub const OP_CWD: OpId = 56;
+pub const OP_FETCH_ASSET: OpId = 57;
pub fn dispatch(
state: &ThreadSafeState,
@@ -293,6 +294,12 @@ pub fn dispatch(
dispatch_json::dispatch(fs::op_make_temp_dir, state, control, zero_copy)
}
OP_CWD => dispatch_json::dispatch(fs::op_cwd, state, control, zero_copy),
+ OP_FETCH_ASSET => dispatch_json::dispatch(
+ compiler::op_fetch_asset,
+ state,
+ control,
+ zero_copy,
+ ),
_ => panic!("bad op_id"),
};