summaryrefslogtreecommitdiff
path: root/cli/compat.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-10-11 08:26:22 +1100
committerGitHub <noreply@github.com>2021-10-11 08:26:22 +1100
commita7baf5f2bbb50dc0cb571de141b800b9155faca7 (patch)
tree4bebaabd1d3ed4595e8a388e0fae559bb5558974 /cli/compat.rs
parent5a8a989b7815023f33a1e3183a55cc8999af5d98 (diff)
refactor: integrate deno_graph into CLI (#12369)
Diffstat (limited to 'cli/compat.rs')
-rw-r--r--cli/compat.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/cli/compat.rs b/cli/compat.rs
index 4b64a501d..f120ccd04 100644
--- a/cli/compat.rs
+++ b/cli/compat.rs
@@ -4,6 +4,7 @@ use deno_core::url::Url;
use std::collections::HashMap;
static STD_NODE: &str = "https://deno.land/std/node/";
+static GLOBAL_MODULE: &str = "global.ts";
static SUPPORTED_MODULES: &[&str] = &[
"assert",
@@ -50,8 +51,15 @@ static SUPPORTED_MODULES: &[&str] = &[
"zlib",
];
-pub fn get_node_globals_url() -> Url {
- Url::parse(&format!("{}global.ts", STD_NODE)).unwrap()
+lazy_static::lazy_static! {
+ static ref GLOBAL_URL_STR: String = format!("{}{}", STD_NODE, GLOBAL_MODULE);
+ pub(crate) static ref GLOBAL_URL: Url = Url::parse(&GLOBAL_URL_STR).unwrap();
+ static ref COMPAT_IMPORT_URL: Url = Url::parse("flags:compat").unwrap();
+}
+
+/// Provide imports into a module graph when the compat flag is true.
+pub(crate) fn get_node_imports() -> Vec<(Url, Vec<String>)> {
+ vec![(COMPAT_IMPORT_URL.clone(), vec![GLOBAL_URL_STR.clone()])]
}
/// Create a map that can be used to update import map.