diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-06-14 10:45:59 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-14 16:45:59 +0000 |
commit | 88e6e9c1e6263f326d30b7fcc33465e0428faf33 (patch) | |
tree | 956e60abea884d89e4c76cc792e2b3159317278e /runtime/web_worker.rs | |
parent | cd27757184e683575c2540f73a96dc96e268943a (diff) |
refactor(core): some runtime methods should live on the module map (#19502)
A few easy migrations of module code from the runtime to the module map.
The module map already has a few places where it needs a handle scope,
so we're not coupling it any further with the v8 runtime.
`init_runtime_module_map` is replaced with an option to reduce API
surface of JsRuntime.
`module_resolve_callback` now lives in the `ModuleMap` and we use a
annex data to avoid having to go through the `Rc<RefCell<...>>` stored
in the `JsRuntime`'s isolate.
Diffstat (limited to 'runtime/web_worker.rs')
-rw-r--r-- | runtime/web_worker.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index 36f9718b5..2dde5a369 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -4,7 +4,6 @@ use crate::inspector_server::InspectorServer; use crate::ops; use crate::permissions::PermissionsContainer; use crate::tokio_util::create_and_run_current_thread; -use crate::worker::init_runtime_module_map; use crate::worker::FormatJsErrorFn; use crate::BootstrapOptions; use deno_broadcast_channel::InMemoryBroadcastChannel; @@ -485,6 +484,15 @@ impl WebWorker { let startup_snapshot = options.startup_snapshot .expect("deno_runtime startup snapshot is not available with 'create_runtime_snapshot' Cargo feature."); + // Clear extension modules from the module map, except preserve `ext:deno_node` + // modules as `node:` specifiers. + let rename_modules = Some( + deno_node::SUPPORTED_BUILTIN_NODE_MODULES + .iter() + .map(|p| (p.ext_specifier, p.specifier)) + .collect(), + ); + let mut js_runtime = JsRuntime::new(RuntimeOptions { module_loader: Some(options.module_loader.clone()), startup_snapshot: Some(startup_snapshot), @@ -494,9 +502,9 @@ impl WebWorker { compiled_wasm_module_store: options.compiled_wasm_module_store.clone(), extensions, inspector: options.maybe_inspector_server.is_some(), + rename_modules, ..Default::default() }); - init_runtime_module_map(&mut js_runtime); if let Some(server) = options.maybe_inspector_server.clone() { server.register_inspector( |