From ca3ab393dffb2dd9a98291d5a95226e28884d566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 15 Jul 2024 23:49:19 +0200 Subject: [PATCH 1/2] refactor: upgrade deno_core to 0.295.0, remove SourceMapGetter impl --- Cargo.toml | 2 +- cli/module_loader.rs | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 93e3043d266d1d..d6796288161876 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ repository = "https://github.com/denoland/deno" [workspace.dependencies] deno_ast = { version = "=0.40.0", features = ["transpiling"] } -deno_core = { version = "0.294.0" } +deno_core = { version = "0.295.0" } deno_bench_util = { version = "0.155.0", path = "./bench_util" } deno_lockfile = "0.20.0" diff --git a/cli/module_loader.rs b/cli/module_loader.rs index 5156e98e3ca1bc..2a16ad1188e166 100644 --- a/cli/module_loader.rs +++ b/cli/module_loader.rs @@ -828,11 +828,7 @@ impl ModuleLoader } std::future::ready(()).boxed_local() } -} -impl SourceMapGetter - for CliModuleLoader -{ fn get_source_map(&self, file_name: &str) -> Option> { let specifier = resolve_url(file_name).ok()?; match specifier.scheme() { From e9bd55d932241425c44efc21681912151db26a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 16 Jul 2024 00:44:12 +0200 Subject: [PATCH 2/2] debug --- Cargo.lock | 16 +++++----------- Cargo.toml | 3 +++ cli/module_loader.rs | 10 +++++----- cli/standalone/mod.rs | 2 -- cli/worker.rs | 21 ++++++--------------- runtime/web_worker.rs | 3 --- runtime/worker.rs | 5 ----- 7 files changed, 19 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fc871415620bed..c525adf641406a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1336,9 +1336,7 @@ dependencies = [ [[package]] name = "deno_core" -version = "0.294.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e3e1883573cace82d1e826096c8c06bd5e4310ca3a4dba0eb1bf67468719c01" +version = "0.295.0" dependencies = [ "anyhow", "bincode", @@ -1802,9 +1800,7 @@ dependencies = [ [[package]] name = "deno_ops" -version = "0.170.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2534bce0346a6dbd6f892066b941a48297687d8755de135cef5dc15bed83214" +version = "0.171.0" dependencies = [ "proc-macro-rules", "proc-macro2", @@ -5894,9 +5890,7 @@ dependencies = [ [[package]] name = "serde_v8" -version = "0.203.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5edf75e70aeb4c6f14c606cfe2fc8b3bd43d4f79c781365c3f336f1fe4be508a" +version = "0.204.0" dependencies = [ "num-bigint", "serde", @@ -7494,9 +7488,9 @@ dependencies = [ [[package]] name = "v8" -version = "0.98.0" +version = "0.98.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb252d5be11c32cb4755d66d58db30ff30af5f1f17183e83ff54383a402c5f6" +checksum = "d03f42deef61349d31ae100e7bcdcc5d9293c1126cb8aff8fd56ba3cba18340b" dependencies = [ "bindgen", "bitflags 2.5.0", diff --git a/Cargo.toml b/Cargo.toml index d6796288161876..b6a3bdb1d80a44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -377,3 +377,6 @@ opt-level = 3 opt-level = 3 [profile.release.package.zstd-sys] opt-level = 3 + +[patch.crates-io] +deno_core = { path = "../deno_core/core" } diff --git a/cli/module_loader.rs b/cli/module_loader.rs index 2a16ad1188e166..3bdb6bb2e0971c 100644 --- a/cli/module_loader.rs +++ b/cli/module_loader.rs @@ -55,7 +55,6 @@ use deno_core::ModuleType; use deno_core::RequestedModuleType; use deno_core::ResolutionKind; use deno_core::SourceCodeCacheInfo; -use deno_core::SourceMapGetter; use deno_graph::source::ResolutionMode; use deno_graph::source::Resolver; use deno_graph::GraphKind; @@ -293,8 +292,7 @@ impl CliModuleLoaderFactory { shared: self.shared.clone(), }))); ModuleLoaderAndSourceMapGetter { - module_loader: loader.clone(), - source_map_getter: Some(loader), + module_loader: loader, } } } @@ -838,10 +836,12 @@ impl ModuleLoader _ => return None, } let source = self.0.load_prepared_module_sync(&specifier, None).ok()?; - source_map_from_code(source.code.as_bytes()) + let r = source_map_from_code(source.code.as_bytes()); + eprintln!("get_source_map r {}", r.is_some()); + r } - fn get_source_line( + fn get_source_mapped_source_line( &self, file_name: &str, line_number: usize, diff --git a/cli/standalone/mod.rs b/cli/standalone/mod.rs index 1df3895efd5d8f..7b1dcf464ab8ea 100644 --- a/cli/standalone/mod.rs +++ b/cli/standalone/mod.rs @@ -369,7 +369,6 @@ impl ModuleLoaderFactory for StandaloneModuleLoaderFactory { root_permissions, dynamic_permissions, }), - source_map_getter: None, } } @@ -384,7 +383,6 @@ impl ModuleLoaderFactory for StandaloneModuleLoaderFactory { root_permissions, dynamic_permissions, }), - source_map_getter: None, } } } diff --git a/cli/worker.rs b/cli/worker.rs index 9125f28be6c9e5..5669c9207fb5aa 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -18,7 +18,6 @@ use deno_core::ModuleId; use deno_core::ModuleLoader; use deno_core::PollEventLoopOptions; use deno_core::SharedArrayBufferStore; -use deno_core::SourceMapGetter; use deno_runtime::code_cache; use deno_runtime::deno_broadcast_channel::InMemoryBroadcastChannel; use deno_runtime::deno_fs; @@ -55,7 +54,6 @@ use crate::version; pub struct ModuleLoaderAndSourceMapGetter { pub module_loader: Rc, - pub source_map_getter: Option>, } pub trait ModuleLoaderFactory: Send + Sync { @@ -516,10 +514,7 @@ impl CliMainWorkerFactory { (main_module, false) }; - let ModuleLoaderAndSourceMapGetter { - module_loader, - source_map_getter, - } = shared + let ModuleLoaderAndSourceMapGetter { module_loader } = shared .module_loader_factory .create_for_main(PermissionsContainer::allow_all(), permissions.clone()); let maybe_inspector_server = shared.maybe_inspector_server.clone(); @@ -595,7 +590,6 @@ impl CliMainWorkerFactory { .clone(), root_cert_store_provider: Some(shared.root_cert_store_provider.clone()), seed: shared.options.seed, - source_map_getter, format_js_error_fn: Some(Arc::new(format_js_error)), create_web_worker_cb, maybe_inspector_server, @@ -729,13 +723,11 @@ fn create_web_worker_callback( Arc::new(move |args| { let maybe_inspector_server = shared.maybe_inspector_server.clone(); - let ModuleLoaderAndSourceMapGetter { - module_loader, - source_map_getter, - } = shared.module_loader_factory.create_for_worker( - args.parent_permissions.clone(), - args.permissions.clone(), - ); + let ModuleLoaderAndSourceMapGetter { module_loader } = + shared.module_loader_factory.create_for_worker( + args.parent_permissions.clone(), + args.permissions.clone(), + ); let create_web_worker_cb = create_web_worker_callback(mode, shared.clone(), stdio.clone()); @@ -800,7 +792,6 @@ fn create_web_worker_callback( seed: shared.options.seed, create_web_worker_cb, format_js_error_fn: Some(Arc::new(format_js_error)), - source_map_getter, module_loader, fs: shared.fs.clone(), node_resolver: Some(shared.node_resolver.clone()), diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index 08de5321673ed6..cf038419622df6 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -38,7 +38,6 @@ use deno_core::ModuleSpecifier; use deno_core::PollEventLoopOptions; use deno_core::RuntimeOptions; use deno_core::SharedArrayBufferStore; -use deno_core::SourceMapGetter; use deno_cron::local::LocalCronHandler; use deno_fs::FileSystem; use deno_http::DefaultHttpPropertyExtractor; @@ -369,7 +368,6 @@ pub struct WebWorkerOptions { pub npm_resolver: Option>, pub create_web_worker_cb: Arc, pub format_js_error_fn: Option>, - pub source_map_getter: Option>, pub worker_type: WebWorkerType, pub maybe_inspector_server: Option>, pub get_error_class_fn: Option, @@ -546,7 +544,6 @@ impl WebWorker { let mut js_runtime = JsRuntime::new(RuntimeOptions { module_loader: Some(options.module_loader.clone()), startup_snapshot: options.startup_snapshot, - source_map_getter: options.source_map_getter, get_error_class_fn: options.get_error_class_fn, shared_array_buffer_store: options.shared_array_buffer_store.clone(), compiled_wasm_module_store: options.compiled_wasm_module_store.clone(), diff --git a/runtime/worker.rs b/runtime/worker.rs index 9207de227a227f..fc11be582493c3 100644 --- a/runtime/worker.rs +++ b/runtime/worker.rs @@ -33,7 +33,6 @@ use deno_core::PollEventLoopOptions; use deno_core::RuntimeOptions; use deno_core::SharedArrayBufferStore; use deno_core::SourceCodeCacheInfo; -use deno_core::SourceMapGetter; use deno_cron::local::LocalCronHandler; use deno_fs::FileSystem; use deno_http::DefaultHttpPropertyExtractor; @@ -162,8 +161,6 @@ pub struct WorkerOptions { pub create_web_worker_cb: Arc, pub format_js_error_fn: Option>, - /// Source map reference for errors. - pub source_map_getter: Option>, pub maybe_inspector_server: Option>, // If true, the worker will wait for inspector session and break on first // statement of user code. Takes higher precedence than @@ -226,7 +223,6 @@ impl Default for WorkerOptions { origin_storage_dir: Default::default(), cache_storage_dir: Default::default(), broadcast_channel: Default::default(), - source_map_getter: Default::default(), root_cert_store_provider: Default::default(), node_resolver: Default::default(), npm_resolver: Default::default(), @@ -486,7 +482,6 @@ impl MainWorker { module_loader: Some(options.module_loader.clone()), startup_snapshot: options.startup_snapshot, create_params: options.create_params, - source_map_getter: options.source_map_getter, skip_op_registration: options.skip_op_registration, get_error_class_fn: options.get_error_class_fn, shared_array_buffer_store: options.shared_array_buffer_store.clone(),