summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/web_worker.rs2
-rw-r--r--runtime/worker.rs12
2 files changed, 14 insertions, 0 deletions
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs
index 01262abcf..36f9718b5 100644
--- a/runtime/web_worker.rs
+++ b/runtime/web_worker.rs
@@ -4,6 +4,7 @@ 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;
@@ -495,6 +496,7 @@ impl WebWorker {
inspector: options.maybe_inspector_server.is_some(),
..Default::default()
});
+ init_runtime_module_map(&mut js_runtime);
if let Some(server) = options.maybe_inspector_server.clone() {
server.register_inspector(
diff --git a/runtime/worker.rs b/runtime/worker.rs
index ae6bd717f..0e62decb4 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -57,6 +57,17 @@ impl ExitCode {
self.0.store(code, Relaxed);
}
}
+
+/// Clear extension modules from the module map, except preserve `ext:deno_node`
+/// modules as `node:` specifiers.
+pub fn init_runtime_module_map(js_runtime: &mut JsRuntime) {
+ js_runtime.clear_module_map(
+ deno_node::SUPPORTED_BUILTIN_NODE_MODULES
+ .iter()
+ .map(|p| (p.ext_specifier, p.specifier)),
+ );
+}
+
/// This worker is created and used by almost all
/// subcommands in Deno executable.
///
@@ -319,6 +330,7 @@ impl MainWorker {
is_main: true,
..Default::default()
});
+ init_runtime_module_map(&mut js_runtime);
if let Some(server) = options.maybe_inspector_server.clone() {
server.register_inspector(