From 246569f6d45852aa42d6f7fe6221fe4d9fa69e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 3 May 2023 18:35:39 +0200 Subject: [PATCH] fix(core): rebuild when JS sources for snapshotting change (#18976) --- core/runtime.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/core/runtime.rs b/core/runtime.rs index 5470a89b9b..9676ce571f 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -543,6 +543,29 @@ impl JsRuntime { } } + #[cfg(feature = "include_js_files_for_snapshotting")] + { + let js_sources = options + .extensions + .iter() + .flat_map(|ext| match ext.get_js_sources() { + Some(s) => s.to_owned(), + None => vec![], + }) + .collect::>(); + + if snapshot_options != snapshot_util::SnapshotOptions::None { + for source in &js_sources { + use crate::ExtensionFileSourceCode; + if let ExtensionFileSourceCode::LoadedFromFsDuringSnapshot(path) = + &source.code + { + println!("cargo:rerun-if-changed={}", path.display()) + } + } + } + } + Rc::new(crate::modules::ExtModuleLoader::new( options.module_loader, esm_sources,