summaryrefslogtreecommitdiff
path: root/cli/tsc.rs
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2022-06-24 10:04:45 -0300
committerGitHub <noreply@github.com>2022-06-24 15:04:45 +0200
commitfd5a12d7e25dc53238e2bbcffe970e646c1035f3 (patch)
tree251c3ec1a46067b02ef30fb48349962973016bf3 /cli/tsc.rs
parentd39094913e91e5193f63459d9c5ca6ddc7779477 (diff)
refactor(snapshots): to their own crate (#14794)
Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/tsc.rs')
-rw-r--r--cli/tsc.rs28
1 files changed, 3 insertions, 25 deletions
diff --git a/cli/tsc.rs b/cli/tsc.rs
index a61d7871d..b293ea3b2 100644
--- a/cli/tsc.rs
+++ b/cli/tsc.rs
@@ -24,7 +24,6 @@ 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;
@@ -52,27 +51,6 @@ 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))
@@ -657,7 +635,7 @@ pub fn exec(request: Request) -> Result<Response, AnyError> {
})
.collect();
let mut runtime = JsRuntime::new(RuntimeOptions {
- startup_snapshot: Some(compiler_snapshot()),
+ startup_snapshot: Some(deno_snapshots::tsc_snapshot()),
extensions: vec![Extension::builder()
.ops(vec![
op_cwd::decl(),
@@ -841,9 +819,9 @@ mod tests {
}
#[test]
- fn test_compiler_snapshot() {
+ fn test_tsc_snapshot() {
let mut js_runtime = deno_core::JsRuntime::new(deno_core::RuntimeOptions {
- startup_snapshot: Some(compiler_snapshot()),
+ startup_snapshot: Some(deno_snapshots::tsc_snapshot()),
..Default::default()
});
js_runtime