mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 05:42:25 -05:00
chore: upgrade deno_core (#22699)
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
This commit is contained in:
parent
0022c35a23
commit
d9fa2dd550
13 changed files with 52 additions and 83 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -1257,9 +1257,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_core"
|
||||
version = "0.266.0"
|
||||
version = "0.267.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfbfe65d133be3abefb973f87b601f686666bb05d5521f0fab16d9dd28a5d5cf"
|
||||
checksum = "b5dc9aeacf98e78c1d8fa716e35f2e8a960e349f73d6bc485d45e49457d80556"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
|
@ -1714,9 +1714,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_ops"
|
||||
version = "0.142.0"
|
||||
version = "0.143.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f96d7d6806eb726b4feb3092cbdaf887ae412b6e8be7c67617c61dbe8b3f1693"
|
||||
checksum = "594aa46152868ee15e104ab3484976a144162694a00c4096174e71b78fdb32c7"
|
||||
dependencies = [
|
||||
"proc-macro-rules",
|
||||
"proc-macro2",
|
||||
|
@ -5600,9 +5600,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_v8"
|
||||
version = "0.175.0"
|
||||
version = "0.176.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfb0193c9e969f1d7a660a2c5ad7c94bb00146c5f5367607eabb2af78094160f"
|
||||
checksum = "25b62c66605745359af254c41af8e6ea2b6124a3698628a7329a6f32698250ee"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"derive_more",
|
||||
|
|
|
@ -43,7 +43,7 @@ repository = "https://github.com/denoland/deno"
|
|||
|
||||
[workspace.dependencies]
|
||||
deno_ast = { version = "0.34.1", features = ["transpiling"] }
|
||||
deno_core = { version = "0.266.0", features = ["snapshot_data_bincode"] }
|
||||
deno_core = { version = "0.267.0" }
|
||||
|
||||
deno_bench_util = { version = "0.134.0", path = "./bench_util" }
|
||||
deno_lockfile = "0.19.0"
|
||||
|
|
|
@ -116,7 +116,7 @@ pub fn bench_js_async_with(
|
|||
}
|
||||
|
||||
async fn inner_async(src: &'static str, runtime: &mut JsRuntime) {
|
||||
runtime.execute_script_static("inner_loop", src).unwrap();
|
||||
runtime.execute_script("inner_loop", src).unwrap();
|
||||
runtime
|
||||
.run_event_loop(PollEventLoopOptions::default())
|
||||
.await
|
||||
|
|
|
@ -276,6 +276,7 @@ mod ts {
|
|||
build_libs,
|
||||
path_dts,
|
||||
)],
|
||||
extension_transpiler: None,
|
||||
with_runtime_cb: None,
|
||||
skip_op_registration: false,
|
||||
},
|
||||
|
|
|
@ -29,7 +29,7 @@ mod tests {
|
|||
..Default::default()
|
||||
});
|
||||
js_runtime
|
||||
.execute_script_static(
|
||||
.execute_script(
|
||||
"<anon>",
|
||||
r#"
|
||||
if (!(bootstrap.mainRuntime && bootstrap.workerRuntime)) {
|
||||
|
|
|
@ -4186,7 +4186,7 @@ fn start_tsc(runtime: &mut JsRuntime, debug: bool) -> Result<(), AnyError> {
|
|||
let init_config = json!({ "debug": debug });
|
||||
let init_src = format!("globalThis.serverInit({init_config});");
|
||||
|
||||
runtime.execute_script(located_script_name!(), init_src.into())?;
|
||||
runtime.execute_script(located_script_name!(), init_src)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -4564,7 +4564,7 @@ fn request(
|
|||
"globalThis.serverRequest({id}, \"{}\", {});",
|
||||
request.method, &request.args
|
||||
);
|
||||
runtime.execute_script(located_script_name!(), request_src.into())?;
|
||||
runtime.execute_script(located_script_name!(), request_src)?;
|
||||
|
||||
let op_state = runtime.op_state();
|
||||
let mut op_state = op_state.borrow_mut();
|
||||
|
|
|
@ -848,7 +848,7 @@ pub fn exec(request: Request) -> Result<Response, AnyError> {
|
|||
"rootNames": root_names,
|
||||
"localOnly": request.check_mode == TypeCheckMode::Local,
|
||||
});
|
||||
let exec_source = format!("globalThis.exec({request_value})").into();
|
||||
let exec_source = format!("globalThis.exec({request_value})");
|
||||
|
||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||
startup_snapshot: Some(compiler_snapshot()),
|
||||
|
@ -1007,7 +1007,7 @@ mod tests {
|
|||
..Default::default()
|
||||
});
|
||||
js_runtime
|
||||
.execute_script_static(
|
||||
.execute_script(
|
||||
"<anon>",
|
||||
r#"
|
||||
if (!(globalThis.exec)) {
|
||||
|
|
|
@ -397,10 +397,7 @@ impl CliMainWorker {
|
|||
name: &'static str,
|
||||
source_code: &'static str,
|
||||
) -> Result<v8::Global<v8::Value>, AnyError> {
|
||||
self
|
||||
.worker
|
||||
.js_runtime
|
||||
.execute_script_static(name, source_code)
|
||||
self.worker.js_runtime.execute_script(name, source_code)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -656,9 +653,9 @@ impl CliMainWorkerFactory {
|
|||
if self.shared.subcommand.needs_test() {
|
||||
macro_rules! test_file {
|
||||
($($file:literal),*) => {
|
||||
$(worker.js_runtime.lazy_load_es_module_from_code(
|
||||
$(worker.js_runtime.lazy_load_es_module_with_code(
|
||||
concat!("ext:cli/", $file),
|
||||
deno_core::FastString::StaticAscii(include_str!(concat!("js/", $file))),
|
||||
deno_core::ascii_str_include!(concat!("js/", $file)),
|
||||
)?;)*
|
||||
}
|
||||
}
|
||||
|
|
|
@ -636,8 +636,7 @@ pub fn load_cjs_module(
|
|||
main = main,
|
||||
module = escape_for_single_quote_string(module),
|
||||
inspect_brk = inspect_brk,
|
||||
)
|
||||
.into();
|
||||
);
|
||||
|
||||
js_runtime.execute_script(located_script_name!(), source_code)?;
|
||||
Ok(())
|
||||
|
|
|
@ -7,8 +7,9 @@ use deno_ast::SourceTextInfo;
|
|||
use deno_core::error::AnyError;
|
||||
use deno_core::extension;
|
||||
use deno_core::Extension;
|
||||
use deno_core::ExtensionFileSource;
|
||||
use deno_core::ExtensionFileSourceCode;
|
||||
use deno_core::ModuleCodeString;
|
||||
use deno_core::ModuleName;
|
||||
use deno_core::SourceMapData;
|
||||
use std::path::Path;
|
||||
|
||||
extension!(runtime,
|
||||
|
@ -56,36 +57,38 @@ extension!(runtime,
|
|||
customizer = |ext: &mut Extension| {
|
||||
#[cfg(not(feature = "exclude_runtime_main_js"))]
|
||||
{
|
||||
ext.esm_files.to_mut().push(ExtensionFileSource::new("ext:runtime_main/js/99_main.js", include_str!("./js/99_main.js")));
|
||||
use deno_core::ascii_str_include;
|
||||
use deno_core::ExtensionFileSource;
|
||||
ext.esm_files.to_mut().push(ExtensionFileSource::new("ext:runtime_main/js/99_main.js", ascii_str_include!("./js/99_main.js")));
|
||||
ext.esm_entry_point = Some("ext:runtime_main/js/99_main.js");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
pub fn maybe_transpile_source(
|
||||
source: &mut ExtensionFileSource,
|
||||
) -> Result<(), AnyError> {
|
||||
name: ModuleName,
|
||||
source: ModuleCodeString,
|
||||
) -> Result<(ModuleCodeString, Option<SourceMapData>), AnyError> {
|
||||
// Always transpile `node:` built-in modules, since they might be TypeScript.
|
||||
let media_type = if source.specifier.starts_with("node:") {
|
||||
let media_type = if name.starts_with("node:") {
|
||||
MediaType::TypeScript
|
||||
} else {
|
||||
MediaType::from_path(Path::new(&source.specifier))
|
||||
MediaType::from_path(Path::new(&name))
|
||||
};
|
||||
|
||||
match media_type {
|
||||
MediaType::TypeScript => {}
|
||||
MediaType::JavaScript => return Ok(()),
|
||||
MediaType::Mjs => return Ok(()),
|
||||
MediaType::JavaScript => return Ok((source, None)),
|
||||
MediaType::Mjs => return Ok((source, None)),
|
||||
_ => panic!(
|
||||
"Unsupported media type for snapshotting {media_type:?} for file {}",
|
||||
source.specifier
|
||||
name
|
||||
),
|
||||
}
|
||||
let code = source.load()?;
|
||||
|
||||
let parsed = deno_ast::parse_module(ParseParams {
|
||||
specifier: deno_core::url::Url::parse(source.specifier).unwrap(),
|
||||
text_info: SourceTextInfo::from_string(code.as_str().to_owned()),
|
||||
specifier: deno_core::url::Url::parse(&name).unwrap(),
|
||||
text_info: SourceTextInfo::from_string(source.as_str().to_owned()),
|
||||
media_type,
|
||||
capture_tokens: false,
|
||||
scope_analysis: false,
|
||||
|
@ -97,7 +100,5 @@ pub fn maybe_transpile_source(
|
|||
..Default::default()
|
||||
})?;
|
||||
|
||||
source.code =
|
||||
ExtensionFileSourceCode::Computed(transpiled_source.text.into());
|
||||
Ok(())
|
||||
Ok((transpiled_source.text.into(), None))
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ use deno_http::DefaultHttpPropertyExtractor;
|
|||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -204,7 +205,7 @@ pub fn create_runtime_snapshot(
|
|||
// NOTE(bartlomieju): ordering is important here, keep it in sync with
|
||||
// `runtime/worker.rs`, `runtime/web_worker.rs` and `runtime/snapshot.rs`!
|
||||
let fs = std::sync::Arc::new(deno_fs::RealFs);
|
||||
let mut extensions: Vec<Extension> = vec![
|
||||
let extensions: Vec<Extension> = vec![
|
||||
deno_webidl::deno_webidl::init_ops_and_esm(),
|
||||
deno_console::deno_console::init_ops_and_esm(),
|
||||
deno_url::deno_url::init_ops_and_esm(),
|
||||
|
@ -257,20 +258,14 @@ pub fn create_runtime_snapshot(
|
|||
ops::web_worker::deno_web_worker::init_ops(),
|
||||
];
|
||||
|
||||
for extension in &mut extensions {
|
||||
for source in extension.esm_files.to_mut() {
|
||||
maybe_transpile_source(source).unwrap();
|
||||
}
|
||||
for source in extension.js_files.to_mut() {
|
||||
maybe_transpile_source(source).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
let output = create_snapshot(
|
||||
CreateSnapshotOptions {
|
||||
cargo_manifest_dir: env!("CARGO_MANIFEST_DIR"),
|
||||
startup_snapshot: None,
|
||||
extensions,
|
||||
extension_transpiler: Some(Rc::new(|specifier, source| {
|
||||
maybe_transpile_source(specifier, source)
|
||||
})),
|
||||
with_runtime_cb: Some(Box::new(|rt| {
|
||||
let isolate = rt.v8_isolate();
|
||||
let scope = &mut v8::HandleScope::new(isolate);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
use crate::inspector_server::InspectorServer;
|
||||
use crate::ops;
|
||||
use crate::permissions::PermissionsContainer;
|
||||
use crate::shared::maybe_transpile_source;
|
||||
use crate::shared::runtime;
|
||||
use crate::tokio_util::create_and_run_current_thread;
|
||||
use crate::worker::import_meta_resolve_callback;
|
||||
|
@ -498,16 +499,6 @@ impl WebWorker {
|
|||
extension.esm_files = std::borrow::Cow::Borrowed(&[]);
|
||||
extension.esm_entry_point = None;
|
||||
}
|
||||
#[cfg(not(feature = "only_snapshotted_js_sources"))]
|
||||
{
|
||||
use crate::shared::maybe_transpile_source;
|
||||
for source in extension.esm_files.to_mut() {
|
||||
maybe_transpile_source(source).unwrap();
|
||||
}
|
||||
for source in extension.js_files.to_mut() {
|
||||
maybe_transpile_source(source).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extensions.extend(std::mem::take(&mut options.extensions));
|
||||
|
@ -535,6 +526,9 @@ impl WebWorker {
|
|||
shared_array_buffer_store: options.shared_array_buffer_store.clone(),
|
||||
compiled_wasm_module_store: options.compiled_wasm_module_store.clone(),
|
||||
extensions,
|
||||
extension_transpiler: Some(Rc::new(|specifier, source| {
|
||||
maybe_transpile_source(specifier, source)
|
||||
})),
|
||||
inspector: options.maybe_inspector_server.is_some(),
|
||||
feature_checker: Some(options.feature_checker.clone()),
|
||||
op_metrics_factory_fn,
|
||||
|
@ -664,10 +658,7 @@ impl WebWorker {
|
|||
&mut self,
|
||||
module_specifier: &ModuleSpecifier,
|
||||
) -> Result<ModuleId, AnyError> {
|
||||
self
|
||||
.js_runtime
|
||||
.load_main_module(module_specifier, None)
|
||||
.await
|
||||
self.js_runtime.load_main_es_module(module_specifier).await
|
||||
}
|
||||
|
||||
/// Loads and instantiates specified JavaScript module as "side" module.
|
||||
|
@ -675,10 +666,7 @@ impl WebWorker {
|
|||
&mut self,
|
||||
module_specifier: &ModuleSpecifier,
|
||||
) -> Result<ModuleId, AnyError> {
|
||||
self
|
||||
.js_runtime
|
||||
.load_side_module(module_specifier, None)
|
||||
.await
|
||||
self.js_runtime.load_side_es_module(module_specifier).await
|
||||
}
|
||||
|
||||
/// Loads, instantiates and executes specified JavaScript module.
|
||||
|
|
|
@ -45,6 +45,7 @@ use log::debug;
|
|||
use crate::inspector_server::InspectorServer;
|
||||
use crate::ops;
|
||||
use crate::permissions::PermissionsContainer;
|
||||
use crate::shared::maybe_transpile_source;
|
||||
use crate::shared::runtime;
|
||||
use crate::BootstrapOptions;
|
||||
|
||||
|
@ -445,16 +446,6 @@ impl MainWorker {
|
|||
extension.esm_files = std::borrow::Cow::Borrowed(&[]);
|
||||
extension.esm_entry_point = None;
|
||||
}
|
||||
#[cfg(not(feature = "only_snapshotted_js_sources"))]
|
||||
{
|
||||
use crate::shared::maybe_transpile_source;
|
||||
for source in extension.esm_files.to_mut() {
|
||||
maybe_transpile_source(source).unwrap();
|
||||
}
|
||||
for source in extension.js_files.to_mut() {
|
||||
maybe_transpile_source(source).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extensions.extend(std::mem::take(&mut options.extensions));
|
||||
|
@ -481,6 +472,9 @@ impl MainWorker {
|
|||
shared_array_buffer_store: options.shared_array_buffer_store.clone(),
|
||||
compiled_wasm_module_store: options.compiled_wasm_module_store.clone(),
|
||||
extensions,
|
||||
extension_transpiler: Some(Rc::new(|specifier, source| {
|
||||
maybe_transpile_source(specifier, source)
|
||||
})),
|
||||
inspector: options.maybe_inspector_server.is_some(),
|
||||
is_main: true,
|
||||
feature_checker: Some(options.feature_checker.clone()),
|
||||
|
@ -579,10 +573,7 @@ impl MainWorker {
|
|||
&mut self,
|
||||
module_specifier: &ModuleSpecifier,
|
||||
) -> Result<ModuleId, AnyError> {
|
||||
self
|
||||
.js_runtime
|
||||
.load_main_module(module_specifier, None)
|
||||
.await
|
||||
self.js_runtime.load_main_es_module(module_specifier).await
|
||||
}
|
||||
|
||||
/// Loads and instantiates specified JavaScript module as "side" module.
|
||||
|
@ -590,10 +581,7 @@ impl MainWorker {
|
|||
&mut self,
|
||||
module_specifier: &ModuleSpecifier,
|
||||
) -> Result<ModuleId, AnyError> {
|
||||
self
|
||||
.js_runtime
|
||||
.load_side_module(module_specifier, None)
|
||||
.await
|
||||
self.js_runtime.load_side_es_module(module_specifier).await
|
||||
}
|
||||
|
||||
/// Executes specified JavaScript module.
|
||||
|
|
Loading…
Reference in a new issue