summaryrefslogtreecommitdiff
path: root/deno_typescript/lib.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-09-15 18:36:27 -0400
committerGitHub <noreply@github.com>2019-09-15 18:36:27 -0400
commitc9ef182886cc07d35a5b27fb89163d8cf21a6a47 (patch)
tree6ba1605daa7e9e8cac3f6b926374086906f571b5 /deno_typescript/lib.rs
parent1d305c2ac785af6b28649f2023d5008e390eeca0 (diff)
Make deno_cli installable via crates.io (#2946)
- Fixes cargo publish on deno_typescript, deno_cli_snapshots, and deno_cli. - Combines cli_snapshots and js into one directory. - Extracts TS version at compile time rather than runtime - Bumps version awkwardly - it was necessary to test end-to-end publishing. Sorry. - Adds git submodule deno_typescript/typescript
Diffstat (limited to 'deno_typescript/lib.rs')
-rw-r--r--deno_typescript/lib.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/deno_typescript/lib.rs b/deno_typescript/lib.rs
index a9b95421d..3d5ab6b15 100644
--- a/deno_typescript/lib.rs
+++ b/deno_typescript/lib.rs
@@ -18,11 +18,16 @@ use std::path::PathBuf;
use std::sync::Arc;
use std::sync::Mutex;
-static TYPESCRIPT_CODE: &str =
- include_str!("../third_party/node_modules/typescript/lib/typescript.js");
+static TYPESCRIPT_CODE: &str = include_str!("typescript/lib/typescript.js");
static COMPILER_CODE: &str = include_str!("compiler_main.js");
static AMD_RUNTIME_CODE: &str = include_str!("amd_runtime.js");
+pub fn ts_version() -> String {
+ let data = include_str!("typescript/package.json");
+ let pkg: serde_json::Value = serde_json::from_str(data).unwrap();
+ pkg["version"].as_str().unwrap().to_string()
+}
+
#[derive(Debug)]
pub struct TSState {
bundle: bool,
@@ -196,15 +201,6 @@ fn write_snapshot(
Ok(())
}
-macro_rules! inc {
- ($e:expr) => {
- Some(include_str!(concat!(
- "../third_party/node_modules/typescript/lib/",
- $e
- )))
- };
-}
-
/// Same as get_asset() but returns NotFound intead of None.
pub fn get_asset2(name: &str) -> Result<&'static str, ErrBox> {
match get_asset(name) {
@@ -217,8 +213,14 @@ pub fn get_asset2(name: &str) -> Result<&'static str, ErrBox> {
}
pub fn get_asset(name: &str) -> Option<&'static str> {
+ macro_rules! inc {
+ ($e:expr) => {
+ Some(include_str!(concat!("typescript/lib/", $e)))
+ };
+ }
match name {
"lib.deno_core.d.ts" => Some(include_str!("lib.deno_core.d.ts")),
+ "typescript.d.ts" => inc!("typescript.d.ts"),
"lib.esnext.d.ts" => inc!("lib.esnext.d.ts"),
"lib.es2019.d.ts" => inc!("lib.es2019.d.ts"),
"lib.es2018.d.ts" => inc!("lib.es2018.d.ts"),