diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2023-05-28 19:44:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-28 12:44:41 -0600 |
commit | b6a3f8f722db89bc136e91da598f581c5838d38e (patch) | |
tree | 668542949383621fab493343cc2ddf8a4928c649 /runtime/worker.rs | |
parent | bb0676d3e23dfd7fe27f9932b955694d51438486 (diff) |
refactor(core): remove ext: modules from the module map (#19040)
Rather than disallowing `ext:` resolution, clear the module map after
initializing extensions so extension modules are anonymized. This
operation is explicitly called in `deno_runtime`. Re-inject `node:`
specifiers into the module map after doing this.
Fixes #17717.
Diffstat (limited to 'runtime/worker.rs')
-rw-r--r-- | runtime/worker.rs | 12 |
1 files changed, 12 insertions, 0 deletions
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( |