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 /cli/ops | |
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 'cli/ops')
-rw-r--r-- | cli/ops/mod.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/cli/ops/mod.rs b/cli/ops/mod.rs index 5066c44b9..7af5f14af 100644 --- a/cli/ops/mod.rs +++ b/cli/ops/mod.rs @@ -12,17 +12,38 @@ pub mod bench; pub mod testing; pub fn cli_exts(npm_resolver: Arc<CliNpmResolver>) -> Vec<Extension> { - vec![deno_cli::init_ops(npm_resolver)] + vec![ + #[cfg(not(feature = "__runtime_js_sources"))] + cli::init_ops(npm_resolver), + #[cfg(feature = "__runtime_js_sources")] + cli::init_ops_and_esm(npm_resolver), + ] } -deno_core::extension!(deno_cli, +// ESM parts duplicated in `../build.rs`. Keep in sync! +deno_core::extension!(cli, + deps = [runtime], ops = [op_npm_process_state], + esm_entry_point = "ext:cli/99_main.js", + esm = [ + dir "js", + "40_testing.js", + "99_main.js" + ], options = { npm_resolver: Arc<CliNpmResolver>, }, state = |state, options| { state.put(options.npm_resolver); }, + customizer = |ext: &mut deno_core::Extension| { + ext.esm_files.to_mut().push(deno_core::ExtensionFileSource { + specifier: "ext:cli/runtime/js/99_main.js", + code: deno_core::ExtensionFileSourceCode::LoadedFromFsDuringSnapshot( + deno_runtime::js::PATH_FOR_99_MAIN_JS, + ), + }); + }, ); #[op] |