Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(runtime): allow adding custom extensions to snapshot #23569

Merged
merged 4 commits into from May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/build.rs
Expand Up @@ -346,6 +346,7 @@ fn create_cli_snapshot(snapshot_path: PathBuf) {
deno_runtime::snapshot::create_runtime_snapshot(
snapshot_path,
snapshot_options,
vec![],
);
}

Expand Down
4 changes: 3 additions & 1 deletion runtime/snapshot.rs
Expand Up @@ -213,11 +213,12 @@ impl deno_kv::sqlite::SqliteDbHandlerPermissions for Permissions {
pub fn create_runtime_snapshot(
snapshot_path: PathBuf,
snapshot_options: SnapshotOptions,
custom_extensions: Vec<Extension>,
mmastrac marked this conversation as resolved.
Show resolved Hide resolved
) {
// 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<Extension> = vec![
let mut extensions: Vec<Extension> = 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(),
Expand Down Expand Up @@ -269,6 +270,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 {
Expand Down