diff options
author | Matt Mastracci <matthew@mastracci.com> | 2024-02-17 15:22:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-17 22:22:46 +0000 |
commit | 08071f9561b17b8899f370dc771604c2c2da445f (patch) | |
tree | df270cf3f349a7d2bce72b1195e36665062e4f7d /cli/build.rs | |
parent | 828d9b84858d53b74d7801604c8c3bee418b631e (diff) |
chore: bump deno_core (#22443)
Migrations:
- Use the new SnapshotSerializer for TSC/compiler snapshots
Diffstat (limited to 'cli/build.rs')
-rw-r--r-- | cli/build.rs | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/cli/build.rs b/cli/build.rs index 71751fb00..1f941142c 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -3,7 +3,7 @@ use std::env; use std::path::PathBuf; -use deno_core::snapshot_util::*; +use deno_core::snapshot::*; use deno_runtime::*; mod ts { @@ -266,10 +266,13 @@ mod ts { ) .unwrap(); + let snapshot_to_file = SnapshotFileSerializer::new( + std::fs::File::create(snapshot_path).unwrap(), + ); + let output = create_snapshot( CreateSnapshotOptions { cargo_manifest_dir: env!("CARGO_MANIFEST_DIR"), - snapshot_path, startup_snapshot: None, extensions: vec![deno_tsc::init_ops_and_esm( op_crate_libs, @@ -281,21 +284,28 @@ mod ts { // Thus we're not not using compressed snapshot, trading off // a lot of build time for some startup time in debug build. #[cfg(debug_assertions)] - compression_cb: None, + serializer: Box::new(snapshot_to_file), #[cfg(not(debug_assertions))] - compression_cb: Some(Box::new(|vec, snapshot_slice| { - eprintln!("Compressing TSC snapshot..."); - vec.extend_from_slice( - &zstd::bulk::compress(snapshot_slice, 22) - .expect("snapshot compression failed"), - ); - })), + serializer: Box::new(SnapshotBulkCompressingSerializer::new( + snapshot_to_file, + |snapshot| { + eprintln!("Compressing TSC snapshot..."); + let mut vec = Vec::with_capacity(snapshot.len()); + vec.extend((snapshot.len() as u32).to_le_bytes()); + vec.extend_from_slice( + &zstd::bulk::compress(&snapshot, 22) + .expect("snapshot compression failed"), + ); + Ok(vec) + }, + )), with_runtime_cb: None, skip_op_registration: false, }, None, - ); + ) + .unwrap(); for path in output.files_loaded_during_snapshot { println!("cargo:rerun-if-changed={}", path.display()); } |