summaryrefslogtreecommitdiff
path: root/deno_typescript/lib.rs
diff options
context:
space:
mode:
authorRy Dahl <ry@tinyclouds.org>2020-01-21 10:24:02 -0500
committerGitHub <noreply@github.com>2020-01-21 10:24:02 -0500
commit229eb292f83dedbc32dc24f912841caf79a53e9c (patch)
tree29b918da3dbc21034d99a74786595bf572e4007a /deno_typescript/lib.rs
parent159ac525ae13816fec76395b0a6e7b1ab55dee1a (diff)
Revert "don't include assets in binary (#3661)"
Ref #3712 This reverts commit 32cbcfe4e9943a0318c497188e045d23c5f6703a.
Diffstat (limited to 'deno_typescript/lib.rs')
-rw-r--r--deno_typescript/lib.rs27
1 files changed, 11 insertions, 16 deletions
diff --git a/deno_typescript/lib.rs b/deno_typescript/lib.rs
index 370079fa1..c503d3508 100644
--- a/deno_typescript/lib.rs
+++ b/deno_typescript/lib.rs
@@ -241,7 +241,7 @@ fn write_snapshot(
}
/// Same as get_asset() but returns NotFound intead of None.
-pub fn get_asset2(name: &str) -> Result<String, ErrBox> {
+pub fn get_asset2(name: &str) -> Result<&'static str, ErrBox> {
match get_asset(name) {
Some(a) => Ok(a),
None => Err(
@@ -251,23 +251,18 @@ pub fn get_asset2(name: &str) -> Result<String, ErrBox> {
}
}
-fn read_file(name: &str) -> String {
- fs::read_to_string(name).unwrap()
-}
-
-macro_rules! inc {
- ($e:expr) => {
- Some(read_file(concat!("../deno_typescript/typescript/lib/", $e)))
- };
-}
-
-pub fn get_asset(name: &str) -> Option<String> {
+pub fn get_asset(name: &str) -> Option<&'static str> {
+ macro_rules! inc {
+ ($e:expr) => {
+ Some(include_str!(concat!("typescript/lib/", $e)))
+ };
+ }
match name {
- "bundle_loader.js" => {
- Some(read_file("../deno_typescript/bundle_loader.js"))
+ "bundle_loader.js" => Some(include_str!("bundle_loader.js")),
+ "lib.deno_runtime.d.ts" => {
+ Some(include_str!("../cli/js/lib.deno_runtime.d.ts"))
}
- "lib.deno_runtime.d.ts" => Some(read_file("js/lib.deno_runtime.d.ts")),
- "bootstrap.ts" => Some("console.log(\"hello deno\");".to_string()),
+ "bootstrap.ts" => Some("console.log(\"hello deno\");"),
"typescript.d.ts" => inc!("typescript.d.ts"),
"lib.esnext.d.ts" => inc!("lib.esnext.d.ts"),
"lib.es2020.d.ts" => inc!("lib.es2020.d.ts"),