From ed3a7ce2f719e64e59cfebb3d131a05a1694523b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 10 Feb 2023 12:40:45 +0100 Subject: refactor: allow to provide polyfills for Node modules from the snapshot (#17706) This commit does preparatory work to allow snapshotting Node.js compatibility layer, that currently lives in `std/node`. The logic was changed to allow loading some modules from the snapshot and some from the remote URL. Additionally "module_es_shim.js" that provides exports for "node:module" is now snapshotted. --- cli/module_loader.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'cli/module_loader.rs') diff --git a/cli/module_loader.rs b/cli/module_loader.rs index 112f29170..b61b4304e 100644 --- a/cli/module_loader.rs +++ b/cli/module_loader.rs @@ -77,13 +77,11 @@ impl CliModuleLoader { specifier: &ModuleSpecifier, maybe_referrer: Option, ) -> Result { - if specifier.as_str() == "node:module" { - return Ok(ModuleCodeSource { - code: deno_runtime::deno_node::MODULE_ES_SHIM.to_string(), - found_url: specifier.to_owned(), - media_type: MediaType::JavaScript, - }); - } + // TODO(bartlomieju): uncomment, when all `node:` module have been + // snapshotted + // if specifier.scheme() == "node" { + // unreachable!("Node built-in modules should be handled internally."); + // } let graph = self.ps.graph(); match graph.get(specifier) { Some(deno_graph::Module { -- cgit v1.2.3