summaryrefslogtreecommitdiff
path: root/runtime/web_worker.rs
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2024-01-22 12:37:25 +0000
committerGitHub <noreply@github.com>2024-01-22 12:37:25 +0000
commitbc92f872988fd8b9cdf2ae1479278789911237a5 (patch)
tree1eb4434b041edc3d159063f4f1dee1ce86a98997 /runtime/web_worker.rs
parent8f767627938ef10802864419061e58a8a75db567 (diff)
fix(runtime): only discard extension sources if a snapshot is provided (#22023)
Fixes #21928. We have a code path which empties the extension sources because they're expected to be pre-executed in the snapshot. Instead of using conditional compilation for that, we now just check if a snapshot was provided. Removes the `dont_use_runtime_snapshot` feature. We didn't allow not providing a snapshot unless this feature was provided, now we always do. Adds the `only_snapshotted_js_sources` feature for us to use in CLI. This asserts that a snapshot is provided and gates the runtime transpilation code so it isn't included in the executable.
Diffstat (limited to 'runtime/web_worker.rs')
-rw-r--r--runtime/web_worker.rs21
1 files changed, 7 insertions, 14 deletions
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs
index 2b6eb19c9..78674af02 100644
--- a/runtime/web_worker.rs
+++ b/runtime/web_worker.rs
@@ -490,14 +490,16 @@ impl WebWorker {
ops::web_worker::deno_web_worker::init_ops_and_esm(),
];
+ #[cfg(__runtime_js_sources)]
+ assert!(cfg!(not(feature = "only_snapshotted_js_sources")), "'__runtime_js_sources' is incompatible with 'only_snapshotted_js_sources'.");
+
for extension in &mut extensions {
- #[cfg(not(feature = "__runtime_js_sources"))]
- {
+ if options.startup_snapshot.is_some() {
extension.js_files = std::borrow::Cow::Borrowed(&[]);
extension.esm_files = std::borrow::Cow::Borrowed(&[]);
extension.esm_entry_point = None;
}
- #[cfg(feature = "__runtime_js_sources")]
+ #[cfg(not(feature = "only_snapshotted_js_sources"))]
{
use crate::shared::maybe_transpile_source;
for source in extension.esm_files.to_mut() {
@@ -511,17 +513,8 @@ impl WebWorker {
extensions.extend(std::mem::take(&mut options.extensions));
- #[cfg(all(
- feature = "include_js_files_for_snapshotting",
- not(feature = "__runtime_js_sources")
- ))]
- options
- .startup_snapshot
- .as_ref()
- .expect("Sources are not embedded and a user snapshot was not provided.");
-
- #[cfg(not(feature = "dont_use_runtime_snapshot"))]
- options.startup_snapshot.as_ref().expect("A user snapshot was not provided, if you want to create a runtime without a snapshot use 'dont_use_runtime_snapshot' Cargo feature.");
+ #[cfg(feature = "only_snapshotted_js_sources")]
+ options.startup_snapshot.as_ref().expect("A user snapshot was not provided, even though 'only_snapshotted_js_sources' is used.");
// Hook up the summary metrics if the user or subcommand requested them
let (op_summary_metrics, op_metrics_factory_fn) =