diff options
Diffstat (limited to 'cli/compat.rs')
-rw-r--r-- | cli/compat.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cli/compat.rs b/cli/compat.rs index eb67f4d12..4b64a501d 100644 --- a/cli/compat.rs +++ b/cli/compat.rs @@ -1,7 +1,10 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. +use deno_core::url::Url; use std::collections::HashMap; +static STD_NODE: &str = "https://deno.land/std/node/"; + static SUPPORTED_MODULES: &[&str] = &[ "assert", "assert/strict", @@ -47,12 +50,20 @@ static SUPPORTED_MODULES: &[&str] = &[ "zlib", ]; +pub fn get_node_globals_url() -> Url { + Url::parse(&format!("{}global.ts", STD_NODE)).unwrap() +} + +/// Create a map that can be used to update import map. +/// +/// Keys are built-in Node modules (and built-ins prefixed with "node:"), while +/// values are URLs pointing to relevant files in deno.land/std/node/ directory. pub fn get_mapped_node_builtins() -> HashMap<String, String> { let mut mappings = HashMap::new(); for module in SUPPORTED_MODULES { // TODO(bartlomieju): this is unversioned, and should be fixed to use latest stable? - let module_url = format!("https://deno.land/std/node/{}.ts", module); + let module_url = format!("{}{}.ts", STD_NODE, module); mappings.insert(module.to_string(), module_url.clone()); // Support for `node:<module_name>` |