diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-11-15 04:25:55 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-15 13:25:55 +0100 |
commit | 7f3902b41f68edddbc50b01ea52c697827d8516f (patch) | |
tree | 4fae66aafc0d4c81e9fa39d7e2e2117f1afcf551 /cli | |
parent | c67de43ff3221ae5554398095261d684b6d41dda (diff) |
perf: static bootstrap options in snapshot (#21213)
Closes https://github.com/denoland/deno/issues/21133
Diffstat (limited to 'cli')
-rw-r--r-- | cli/build.rs | 18 | ||||
-rw-r--r-- | cli/worker.rs | 4 |
2 files changed, 17 insertions, 5 deletions
diff --git a/cli/build.rs b/cli/build.rs index 6260c1c61..1480bb5c7 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -352,9 +352,18 @@ fn create_cli_snapshot(snapshot_path: PathBuf) -> CreateSnapshotOutput { use deno_runtime::deno_cron::local::LocalCronHandler; use deno_runtime::deno_http::DefaultHttpPropertyExtractor; use deno_runtime::deno_kv::sqlite::SqliteDbHandler; + use deno_runtime::ops::bootstrap::SnapshotOptions; use deno_runtime::permissions::PermissionsContainer; use std::sync::Arc; + fn deno_version() -> String { + if env::var("DENO_CANARY").is_ok() { + format!("{}+{}", env!("CARGO_PKG_VERSION"), git_commit_hash()) + } else { + env!("CARGO_PKG_VERSION").to_string() + } + } + // NOTE(bartlomieju): ordering is important here, keep it in sync with // `runtime/worker.rs`, `runtime/web_worker.rs` and `runtime/build.rs`! let fs = Arc::new(deno_fs::RealFs); @@ -405,7 +414,14 @@ fn create_cli_snapshot(snapshot_path: PathBuf) -> CreateSnapshotOutput { deno_runtime::ops::signal::deno_signal::init_ops(), deno_runtime::ops::tty::deno_tty::init_ops(), deno_runtime::ops::http::deno_http_runtime::init_ops(), - deno_runtime::ops::bootstrap::deno_bootstrap::init_ops(), + deno_runtime::ops::bootstrap::deno_bootstrap::init_ops(Some( + SnapshotOptions { + deno_version: deno_version(), + ts_version: ts::version(), + v8_version: deno_core::v8_version(), + target: std::env::var("TARGET").unwrap(), + }, + )), cli::init_ops_and_esm(), // NOTE: This needs to be init_ops_and_esm! ]; diff --git a/cli/worker.rs b/cli/worker.rs index 2ae7bade4..ed3db5321 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -559,8 +559,6 @@ impl CliMainWorkerFactory { location: shared.options.location.clone(), no_color: !colors::use_color(), is_tty: colors::is_tty(), - runtime_version: version::deno().to_string(), - ts_version: version::TYPESCRIPT.to_string(), unstable: shared.options.unstable, unstable_features, user_agent: version::get_user_agent().to_string(), @@ -755,8 +753,6 @@ fn create_web_worker_callback( location: Some(args.main_module.clone()), no_color: !colors::use_color(), is_tty: colors::is_tty(), - runtime_version: version::deno().to_string(), - ts_version: version::TYPESCRIPT.to_string(), unstable: shared.options.unstable, unstable_features, user_agent: version::get_user_agent().to_string(), |