summaryrefslogtreecommitdiff
path: root/cli/module_loader.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-02-10 12:40:45 +0100
committerGitHub <noreply@github.com>2023-02-10 11:40:45 +0000
commited3a7ce2f719e64e59cfebb3d131a05a1694523b (patch)
treea355c3a0f17ec7dfb8bcdba964deb8dd241b6734 /cli/module_loader.rs
parent9ea899afa76949d2e1a2a6eabbbec14f139a7592 (diff)
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.
Diffstat (limited to 'cli/module_loader.rs')
-rw-r--r--cli/module_loader.rs12
1 files changed, 5 insertions, 7 deletions
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<ModuleSpecifier>,
) -> Result<ModuleCodeSource, AnyError> {
- 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 {