diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2023-08-06 00:47:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-06 01:47:15 +0200 |
commit | c1c8eb3d558bedf6588179ae93737bd6afe5a368 (patch) | |
tree | e6ba4d8aa59a8b73e224fd218cf6e102a81974d9 /runtime/js.rs | |
parent | b96f28306490a56aac91b8ef06b35ebdc7f41b63 (diff) |
build: allow disabling snapshots for dev (#20048)
Closes #19399 (running without snapshots at all was suggested as an
alternative solution).
Adds a `__runtime_js_sources` pseudo-private feature to load extension
JS sources at runtime for faster development, instead of building and
loading snapshots or embedding sources in the binary. Will only work in
a development environment obviously.
Try running `cargo test --features __runtime_js_sources
integration::node_unit_tests::os_test`. Then break some behaviour in
`ext/node/polyfills/os.ts` e.g. make `function cpus() {}` return an
empty array, and run it again. Fix and then run again. No more build
time in between.
Diffstat (limited to 'runtime/js.rs')
-rw-r--r-- | runtime/js.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/runtime/js.rs b/runtime/js.rs index def2724ce..f942493a3 100644 --- a/runtime/js.rs +++ b/runtime/js.rs @@ -1,17 +1,21 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -#[cfg(not(feature = "dont_create_runtime_snapshot"))] use deno_core::Snapshot; -#[cfg(not(feature = "dont_create_runtime_snapshot"))] use log::debug; #[cfg(not(feature = "dont_create_runtime_snapshot"))] static RUNTIME_SNAPSHOT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/RUNTIME_SNAPSHOT.bin")); -#[cfg(not(feature = "dont_create_runtime_snapshot"))] -pub fn deno_isolate_init() -> Snapshot { +pub fn deno_isolate_init() -> Option<Snapshot> { debug!("Deno isolate init with snapshots."); - Snapshot::Static(RUNTIME_SNAPSHOT) + #[cfg(not(feature = "dont_create_runtime_snapshot"))] + { + Some(Snapshot::Static(RUNTIME_SNAPSHOT)) + } + #[cfg(feature = "dont_create_runtime_snapshot")] + { + None + } } #[cfg(not(feature = "include_js_files_for_snapshotting"))] |