diff options
author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2023-06-14 00:36:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-13 22:36:16 +0000 |
commit | 60bf79c18410fd332b6b9b7c222e6d3d62bfe3f8 (patch) | |
tree | 070934eb82d906ee341d1ad4d1390f0b75860529 /core/modules.rs | |
parent | 82dd90f98d6817caadcb9b6bd81aba80b2ee848d (diff) |
Revert "refactor(core): cleanup feature flags for js source inclusion… (#19490)
… (#19463)"
This reverts commit ceb03cfb037cf7024a5048b17b508ddda59cfa05.
This is being reverted because it causes 3.5Mb increase in the binary
size,
due to runtime JS code being included in the binary, even though it's
already snapshotted.
CC @nayeemrmn
Diffstat (limited to 'core/modules.rs')
-rw-r--r-- | core/modules.rs | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/core/modules.rs b/core/modules.rs index 5d9fe2fc4..4f1875ae5 100644 --- a/core/modules.rs +++ b/core/modules.rs @@ -438,7 +438,7 @@ impl ModuleLoader for ExtModuleLoader { let result = if let Some(load_callback) = &self.maybe_load_callback { load_callback(source) } else { - Ok(source.load()) + source.load() }; match result { Ok(code) => { @@ -459,6 +459,29 @@ impl ModuleLoader for ExtModuleLoader { } } +impl Drop for ExtModuleLoader { + fn drop(&mut self) { + let sources = self.sources.get_mut(); + let used_specifiers = self.used_specifiers.get_mut(); + let unused_modules: Vec<_> = sources + .iter() + .filter(|(k, _)| !used_specifiers.contains(k.as_str())) + .collect(); + + if !unused_modules.is_empty() { + let mut msg = + "Following modules were passed to ExtModuleLoader but never used:\n" + .to_string(); + for m in unused_modules { + msg.push_str(" - "); + msg.push_str(m.0); + msg.push('\n'); + } + panic!("{}", msg); + } + } +} + /// Basic file system module loader. /// /// Note that this loader will **block** event loop @@ -2021,7 +2044,7 @@ import "/a.js"; deno_core::extension!(test_ext, ops = [op_test]); let mut runtime = JsRuntime::new(RuntimeOptions { - extensions: vec![test_ext::init()], + extensions: vec![test_ext::init_ops()], module_loader: Some(loader), ..Default::default() }); |