summaryrefslogtreecommitdiff
path: root/cli/tsc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tsc.rs')
-rw-r--r--cli/tsc.rs28
1 files changed, 25 insertions, 3 deletions
diff --git a/cli/tsc.rs b/cli/tsc.rs
index 95fdd305a..4065c6354 100644
--- a/cli/tsc.rs
+++ b/cli/tsc.rs
@@ -24,6 +24,7 @@ use deno_core::JsRuntime;
use deno_core::ModuleSpecifier;
use deno_core::OpState;
use deno_core::RuntimeOptions;
+use deno_core::Snapshot;
use deno_graph::Resolved;
use once_cell::sync::Lazy;
use std::collections::HashMap;
@@ -51,6 +52,27 @@ pub static SHARED_GLOBALS_LIB: &str =
pub static WINDOW_LIB: &str = include_str!("dts/lib.deno.window.d.ts");
pub static UNSTABLE_NS_LIB: &str = include_str!("dts/lib.deno.unstable.d.ts");
+pub static COMPILER_SNAPSHOT: Lazy<Box<[u8]>> = Lazy::new(
+ #[cold]
+ #[inline(never)]
+ || {
+ static COMPRESSED_COMPILER_SNAPSHOT: &[u8] =
+ include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT.bin"));
+
+ zstd::bulk::decompress(
+ &COMPRESSED_COMPILER_SNAPSHOT[4..],
+ u32::from_le_bytes(COMPRESSED_COMPILER_SNAPSHOT[0..4].try_into().unwrap())
+ as usize,
+ )
+ .unwrap()
+ .into_boxed_slice()
+ },
+);
+
+pub fn compiler_snapshot() -> Snapshot {
+ Snapshot::Static(&*COMPILER_SNAPSHOT)
+}
+
macro_rules! inc {
($e:expr) => {
include_str!(concat!("dts/", $e))
@@ -635,7 +657,7 @@ pub fn exec(request: Request) -> Result<Response, AnyError> {
})
.collect();
let mut runtime = JsRuntime::new(RuntimeOptions {
- startup_snapshot: Some(deno_snapshots::tsc_snapshot()),
+ startup_snapshot: Some(compiler_snapshot()),
extensions: vec![Extension::builder()
.ops(vec![
op_cwd::decl(),
@@ -819,9 +841,9 @@ mod tests {
}
#[test]
- fn test_tsc_snapshot() {
+ fn test_compiler_snapshot() {
let mut js_runtime = deno_core::JsRuntime::new(deno_core::RuntimeOptions {
- startup_snapshot: Some(deno_snapshots::tsc_snapshot()),
+ startup_snapshot: Some(compiler_snapshot()),
..Default::default()
});
js_runtime