diff options
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/Cargo.toml | 13 | ||||
| -rw-r--r-- | runtime/build.rs | 54 | ||||
| -rw-r--r-- | runtime/examples/extension_with_esm/main.rs | 2 | ||||
| -rw-r--r-- | runtime/examples/extension_with_ops/main.rs | 2 | ||||
| -rw-r--r-- | runtime/js.rs | 3 | ||||
| -rw-r--r-- | runtime/web_worker.rs | 60 | ||||
| -rw-r--r-- | runtime/worker.rs | 58 |
7 files changed, 101 insertions, 91 deletions
diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 95cc25e53..27faa977c 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -14,8 +14,15 @@ description = "Provides the deno runtime library" docsrs = [] # A feature that disables creation of startup snapshot during in the build script. dont_create_runtime_snapshot = [] -# Enable to exclude `js/99_main.js` from the generated snapshot. -exclude_js_main_from_snapshot = [] +# A feature that changes how startup snapshot is generated, that allows +# extending it in embedder crates. +snapshot_from_snapshot = [] +# A feature that disables embedding of the JavaScript source files in the binary. +# With this feature enabled, the sources must be consumed during build time, +# by creating a startup snapshot. +include_js_files_for_snapshotting = [ + "deno_core/include_js_files_for_snapshotting", +] [lib] name = "deno_runtime" @@ -34,7 +41,7 @@ deno_ast.workspace = true deno_broadcast_channel.workspace = true deno_cache.workspace = true deno_console.workspace = true -deno_core = { workspace = true, features = ["runtime_js_sources"] } +deno_core.workspace = true deno_crypto.workspace = true deno_fetch.workspace = true deno_ffi.workspace = true diff --git a/runtime/build.rs b/runtime/build.rs index 15b7d3ade..f656682a1 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -264,22 +264,22 @@ mod startup_snapshot { ], ); - #[cfg(not(feature = "exclude_js_main_from_snapshot"))] + #[cfg(not(feature = "snapshot_from_snapshot"))] deno_core::extension!( runtime_main, deps = [runtime], customizer = |ext: &mut deno_core::ExtensionBuilder| { ext.esm(vec![ExtensionFileSource { specifier: "ext:runtime_main/js/99_main.js", - code: ExtensionFileSourceCode::LoadAtRuntime(PathBuf::from( - "js/99_main.js", - )), + code: deno_core::ExtensionFileSourceCode::IncludedInBinary( + include_str!("js/99_main.js"), + ), }]); ext.esm_entry_point("ext:runtime_main/js/99_main.js"); } ); - #[cfg(feature = "exclude_js_main_from_snapshot")] + #[cfg(feature = "snapshot_from_snapshot")] deno_core::extension!( runtime_main, deps = [runtime], @@ -294,45 +294,47 @@ mod startup_snapshot { // `runtime/worker.rs`, `runtime/web_worker.rs` and `cli/build.rs`! let fs = std::sync::Arc::new(deno_fs::RealFs); let extensions: Vec<Extension> = vec![ - deno_webidl::deno_webidl::init_ext(), - deno_console::deno_console::init_ext(), - deno_url::deno_url::init_ext(), - deno_web::deno_web::init_ext::<Permissions>( + deno_webidl::deno_webidl::init_ops_and_esm(), + deno_console::deno_console::init_ops_and_esm(), + deno_url::deno_url::init_ops_and_esm(), + deno_web::deno_web::init_ops_and_esm::<Permissions>( deno_web::BlobStore::default(), Default::default(), ), - deno_fetch::deno_fetch::init_ext::<Permissions>(Default::default()), - deno_cache::deno_cache::init_ext::<SqliteBackedCache>(None), - deno_websocket::deno_websocket::init_ext::<Permissions>( + deno_fetch::deno_fetch::init_ops_and_esm::<Permissions>( + Default::default(), + ), + deno_cache::deno_cache::init_ops_and_esm::<SqliteBackedCache>(None), + deno_websocket::deno_websocket::init_ops_and_esm::<Permissions>( "".to_owned(), None, None, ), - deno_webstorage::deno_webstorage::init_ext(None), - deno_crypto::deno_crypto::init_ext(None), - deno_broadcast_channel::deno_broadcast_channel::init_ext( + deno_webstorage::deno_webstorage::init_ops_and_esm(None), + deno_crypto::deno_crypto::init_ops_and_esm(None), + deno_broadcast_channel::deno_broadcast_channel::init_ops_and_esm( deno_broadcast_channel::InMemoryBroadcastChannel::default(), false, // No --unstable. ), - deno_ffi::deno_ffi::init_ext::<Permissions>(false), - deno_net::deno_net::init_ext::<Permissions>( + deno_ffi::deno_ffi::init_ops_and_esm::<Permissions>(false), + deno_net::deno_net::init_ops_and_esm::<Permissions>( None, false, // No --unstable. None, ), - deno_tls::deno_tls::init_ext(), - deno_kv::deno_kv::init_ext( + deno_tls::deno_tls::init_ops_and_esm(), + deno_kv::deno_kv::init_ops_and_esm( deno_kv::sqlite::SqliteDbHandler::<Permissions>::new(None), false, // No --unstable ), - deno_napi::deno_napi::init_ext::<Permissions>(), - deno_http::deno_http::init_ext::<DefaultHttpPropertyExtractor>(), - deno_io::deno_io::init_ext(Default::default()), - deno_fs::deno_fs::init_ext::<Permissions>(false, fs.clone()), - runtime::init_ext(), + deno_napi::deno_napi::init_ops_and_esm::<Permissions>(), + deno_http::deno_http::init_ops_and_esm::<DefaultHttpPropertyExtractor>(), + deno_io::deno_io::init_ops_and_esm(Default::default()), + deno_fs::deno_fs::init_ops_and_esm::<Permissions>(false, fs.clone()), + runtime::init_ops_and_esm(), // FIXME(bartlomieju): these extensions are specified last, because they // depend on `runtime`, even though it should be other way around - deno_node::deno_node::init_ext::<Permissions>(None, fs), - runtime_main::init_ext(), + deno_node::deno_node::init_ops_and_esm::<Permissions>(None, fs), + runtime_main::init_ops_and_esm(), ]; let output = create_snapshot(CreateSnapshotOptions { diff --git a/runtime/examples/extension_with_esm/main.rs b/runtime/examples/extension_with_esm/main.rs index 9f6dfca92..6b21460a3 100644 --- a/runtime/examples/extension_with_esm/main.rs +++ b/runtime/examples/extension_with_esm/main.rs @@ -26,7 +26,7 @@ async fn main() -> Result<(), AnyError> { PermissionsContainer::allow_all(), WorkerOptions { module_loader: Rc::new(FsModuleLoader), - extensions: vec![hello_runtime::init_ext()], + extensions: vec![hello_runtime::init_ops_and_esm()], ..Default::default() }, ); diff --git a/runtime/examples/extension_with_ops/main.rs b/runtime/examples/extension_with_ops/main.rs index ae9911210..1feb4ba27 100644 --- a/runtime/examples/extension_with_ops/main.rs +++ b/runtime/examples/extension_with_ops/main.rs @@ -28,7 +28,7 @@ async fn main() -> Result<(), AnyError> { PermissionsContainer::allow_all(), WorkerOptions { module_loader: Rc::new(FsModuleLoader), - extensions: vec![hello_runtime::init_ext()], + extensions: vec![hello_runtime::init_ops()], ..Default::default() }, ); diff --git a/runtime/js.rs b/runtime/js.rs index 099ca0c0e..def2724ce 100644 --- a/runtime/js.rs +++ b/runtime/js.rs @@ -14,8 +14,9 @@ pub fn deno_isolate_init() -> Snapshot { Snapshot::Static(RUNTIME_SNAPSHOT) } -/// Depends on LTO to be excluded from production binaries if unused. +#[cfg(not(feature = "include_js_files_for_snapshotting"))] pub static SOURCE_CODE_FOR_99_MAIN_JS: &str = include_str!("js/99_main.js"); +#[cfg(feature = "include_js_files_for_snapshotting")] pub static PATH_FOR_99_MAIN_JS: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/js/99_main.js"); diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index 55b746212..2dde5a369 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -398,14 +398,14 @@ impl WebWorker { // `runtime/build.rs`, `runtime/worker.rs` and `cli/build.rs`! let mut extensions: Vec<Extension> = vec