diff --git a/cli/build.rs b/cli/build.rs index 81bd4eddad..3b4bfa8a82 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -346,6 +346,7 @@ fn create_cli_snapshot(snapshot_path: PathBuf) { deno_runtime::snapshot::create_runtime_snapshot( snapshot_path, snapshot_options, + vec![], ); } diff --git a/runtime/snapshot.rs b/runtime/snapshot.rs index d5122af84f..2a7d97641e 100644 --- a/runtime/snapshot.rs +++ b/runtime/snapshot.rs @@ -213,11 +213,13 @@ impl deno_kv::sqlite::SqliteDbHandlerPermissions for Permissions { pub fn create_runtime_snapshot( snapshot_path: PathBuf, snapshot_options: SnapshotOptions, + // NOTE: For embedders that wish to add additional extensions to the snapshot + custom_extensions: Vec, ) { // NOTE(bartlomieju): ordering is important here, keep it in sync with // `runtime/worker.rs`, `runtime/web_worker.rs` and `runtime/snapshot.rs`! let fs = std::sync::Arc::new(deno_fs::RealFs); - let extensions: Vec = vec![ + let mut extensions: Vec = vec![ deno_webidl::deno_webidl::init_ops_and_esm(), deno_console::deno_console::init_ops_and_esm(), deno_url::deno_url::init_ops_and_esm(), @@ -269,6 +271,7 @@ pub fn create_runtime_snapshot( ops::bootstrap::deno_bootstrap::init_ops(Some(snapshot_options)), ops::web_worker::deno_web_worker::init_ops(), ]; + extensions.extend(custom_extensions); let output = create_snapshot( CreateSnapshotOptions {