diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-07-05 00:12:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-05 00:12:41 +0200 |
commit | a919a5dd1167b79f267cbed7312b3a7d296d429f (patch) | |
tree | 73b7b1a8b5daef3ab7ad9c07423c4907a23a0269 /cli/tsc.rs | |
parent | 06934db883e9ae64c7603f98051676cbcf90994f (diff) |
Revert "refactor(snapshots): to their own crate (#14794)" (#15076)
This reverts commit fd5a12d7e25dc53238e2bbcffe970e646c1035f3.
Diffstat (limited to 'cli/tsc.rs')
-rw-r--r-- | cli/tsc.rs | 28 |
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 |