diff --git a/bench_util/benches/utf8.rs b/bench_util/benches/utf8.rs index 021c409b86..499571e5e6 100644 --- a/bench_util/benches/utf8.rs +++ b/bench_util/benches/utf8.rs @@ -9,19 +9,14 @@ fn setup() -> Vec { vec![Extension::builder() .js(vec![( "setup.js", - Box::new(|| { - Ok( - r#" + r#" const hello = "hello world\n"; const hello1k = hello.repeat(1e3); const hello1m = hello.repeat(1e6); const helloEncoded = Deno.core.encode(hello); const hello1kEncoded = Deno.core.encode(hello1k); const hello1mEncoded = Deno.core.encode(hello1m); - "# - .into(), - ) - }), + "#, )]) .build()] } diff --git a/core/extensions.rs b/core/extensions.rs index 6dd2270fc2..6829871242 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); -pub type SourceLoadFn = dyn Fn() -> Result; +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)> -/// 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), ),)+ ] }; diff --git a/core/runtime.rs b/core/runtime.rs index f589ad25b8..f8afeb76c5 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -491,9 +491,8 @@ impl JsRuntime { for m in extensions.iter_mut() { let js_files = m.init_js(); for (filename, source) in js_files { - let source = source()?; // TODO(@AaronO): use JsRuntime::execute_static() here to move src off heap - realm.execute_script(self, filename, &source)?; + realm.execute_script(self, filename, source)?; } } // Restore extensions diff --git a/ext/url/benches/url_ops.rs b/ext/url/benches/url_ops.rs index ed27b6f80d..315ea72606 100644 --- a/ext/url/benches/url_ops.rs +++ b/ext/url/benches/url_ops.rs @@ -11,9 +11,7 @@ fn setup() -> Vec { Extension::builder() .js(vec![( "setup", - Box::new(|| { - Ok(r#"const { URL } = globalThis.__bootstrap.url;"#.to_owned()) - }), + "const { URL } = globalThis.__bootstrap.url;", )]) .build(), ] diff --git a/ext/web/benches/timers_ops.rs b/ext/web/benches/timers_ops.rs index 30f50b7d91..f5d03d6c3f 100644 --- a/ext/web/benches/timers_ops.rs +++ b/ext/web/benches/timers_ops.rs @@ -26,12 +26,10 @@ fn setup() -> Vec { deno_web::init::(BlobStore::default(), None), Extension::builder() .js(vec![ - ("setup", - Box::new(|| Ok(r#" - const { opNow, setTimeout, handleTimerMacrotask } = globalThis.__bootstrap.timers; - Deno.core.setMacrotaskCallback(handleTimerMacrotask); - "#.to_owned())), - ), + ("setup", r#" + const { opNow, setTimeout, handleTimerMacrotask } = globalThis.__bootstrap.timers; + Deno.core.setMacrotaskCallback(handleTimerMacrotask); + "#), ]) .state(|state| { state.put(Permissions{}); diff --git a/ext/webgpu/01_webgpu.js b/ext/webgpu/src/01_webgpu.js similarity index 100% rename from ext/webgpu/01_webgpu.js rename to ext/webgpu/src/01_webgpu.js diff --git a/ext/webgpu/02_idl_types.js b/ext/webgpu/src/02_idl_types.js similarity index 100% rename from ext/webgpu/02_idl_types.js rename to ext/webgpu/src/02_idl_types.js