diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2022-05-15 13:27:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-15 13:27:56 +0200 |
commit | f5c31b56e3fb57a92dbaaec17690bfa9d787164e (patch) | |
tree | 4b9cd72ed81d16430734240e2a57bcf1739334fe /core/extensions.rs | |
parent | b08b1da6f4550601eec23327bd40d17ad6a6b4e9 (diff) |
Revert "core: don't include_str extension js code (#10786)" (#14614)
This reverts commit 10e50a120744de71d6915af4ae93f8231607573d
Alternative to #13217, IMO the tradeoffs made by #10786 aren't worth it.
It breaks abstractions (crates being self-contained, deno_core without snapshotting etc...) and causes pain points / gotchas for both embedders & devs for a relatively minimal gain in incremental build time ...
Closes #11030
Diffstat (limited to 'core/extensions.rs')
-rw-r--r-- | core/extensions.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/core/extensions.rs b/core/extensions.rs index 6dd2270fc..682987124 100644 --- a/core/extensions.rs +++ b/core/extensions.rs @@ -3,8 +3,7 @@ use crate::OpState; use anyhow::Error; use std::task::Context; -pub type SourcePair = (&'static str, Box<SourceLoadFn>); -pub type SourceLoadFn = dyn Fn() -> Result<String, Error>; +pub type SourcePair = (&'static str, &'static str); pub type OpFnRef = v8::FunctionCallback; pub type OpMiddlewareFn = dyn Fn(OpDecl) -> OpDecl; pub type OpStateFn = dyn Fn(&mut OpState) -> Result<(), Error>; @@ -169,9 +168,8 @@ impl ExtensionBuilder { } } } -/// Helps embed JS files in an extension. Returns Vec<(&'static str, Box<SourceLoadFn>)> -/// representing the filename and source code. This is only meant for extensions -/// that will be snapshotted, as code will be loaded at runtime. +/// Helps embed JS files in an extension. Returns Vec<(&'static str, &'static str)> +/// representing the filename and source code. /// /// Example: /// ```ignore @@ -187,13 +185,7 @@ macro_rules! include_js_files { vec![ $(( concat!($prefix, "/", $file), - Box::new(|| { - let c = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); - let path = c.join($file); - println!("cargo:rerun-if-changed={}", path.display()); - let src = std::fs::read_to_string(path)?; - Ok(src) - }), + include_str!($file), ),)+ ] }; |