mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
feat(runtime): allow adding custom extensions to snapshot (#23569)
This makes `create_runtime_snapshot` more useful for embedders who add their own extension(s) to the runtime in build scripts. --------- Signed-off-by: Matt Mastracci <matthew@mastracci.com> Co-authored-by: Matt Mastracci <matthew@mastracci.com>
This commit is contained in:
parent
505130d813
commit
ee122c5af6
2 changed files with 5 additions and 1 deletions
|
@ -346,6 +346,7 @@ fn create_cli_snapshot(snapshot_path: PathBuf) {
|
||||||
deno_runtime::snapshot::create_runtime_snapshot(
|
deno_runtime::snapshot::create_runtime_snapshot(
|
||||||
snapshot_path,
|
snapshot_path,
|
||||||
snapshot_options,
|
snapshot_options,
|
||||||
|
vec![],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,11 +213,13 @@ impl deno_kv::sqlite::SqliteDbHandlerPermissions for Permissions {
|
||||||
pub fn create_runtime_snapshot(
|
pub fn create_runtime_snapshot(
|
||||||
snapshot_path: PathBuf,
|
snapshot_path: PathBuf,
|
||||||
snapshot_options: SnapshotOptions,
|
snapshot_options: SnapshotOptions,
|
||||||
|
// NOTE: For embedders that wish to add additional extensions to the snapshot
|
||||||
|
custom_extensions: Vec<Extension>,
|
||||||
) {
|
) {
|
||||||
// NOTE(bartlomieju): ordering is important here, keep it in sync with
|
// NOTE(bartlomieju): ordering is important here, keep it in sync with
|
||||||
// `runtime/worker.rs`, `runtime/web_worker.rs` and `runtime/snapshot.rs`!
|
// `runtime/worker.rs`, `runtime/web_worker.rs` and `runtime/snapshot.rs`!
|
||||||
let fs = std::sync::Arc::new(deno_fs::RealFs);
|
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_webidl::deno_webidl::init_ops_and_esm(),
|
||||||
deno_console::deno_console::init_ops_and_esm(),
|
deno_console::deno_console::init_ops_and_esm(),
|
||||||
deno_url::deno_url::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::bootstrap::deno_bootstrap::init_ops(Some(snapshot_options)),
|
||||||
ops::web_worker::deno_web_worker::init_ops(),
|
ops::web_worker::deno_web_worker::init_ops(),
|
||||||
];
|
];
|
||||||
|
extensions.extend(custom_extensions);
|
||||||
|
|
||||||
let output = create_snapshot(
|
let output = create_snapshot(
|
||||||
CreateSnapshotOptions {
|
CreateSnapshotOptions {
|
||||||
|
|
Loading…
Reference in a new issue