Skip to content

Commit

Permalink
feat(compat): pin specific version of std/node (denoland#12396)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed Oct 11, 2021
1 parent fbcbbd7 commit 5508a0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 7 additions & 3 deletions cli/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
use deno_core::url::Url;
use std::collections::HashMap;

static STD_NODE: &str = "https://deno.land/std/node/";
// TODO(bartlomieju): this needs to be bumped manually for
// each release, a better mechanism is preferable, but it's a quick and dirty
// solution to avoid printing `X-Deno-Warning` headers when the compat layer is
// downloaded
static STD_URL: &str = "https://deno.land/[email protected]/";
static GLOBAL_MODULE: &str = "global.ts";

static SUPPORTED_MODULES: &[&str] = &[
Expand Down Expand Up @@ -52,7 +56,7 @@ static SUPPORTED_MODULES: &[&str] = &[
];

lazy_static::lazy_static! {
static ref GLOBAL_URL_STR: String = format!("{}{}", STD_NODE, GLOBAL_MODULE);
static ref GLOBAL_URL_STR: String = format!("{}node/{}", STD_URL, 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();
}
Expand All @@ -71,7 +75,7 @@ pub fn get_mapped_node_builtins() -> HashMap<String, String> {

for module in SUPPORTED_MODULES {
// TODO(bartlomieju): this is unversioned, and should be fixed to use latest stable?
let module_url = format!("{}{}.ts", STD_NODE, module);
let module_url = format!("{}node/{}.ts", STD_URL, module);
mappings.insert(module.to_string(), module_url.clone());

// Support for `node:<module_name>`
Expand Down
3 changes: 1 addition & 2 deletions cli/tests/integration/compat_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ itest!(existing_import_map {

#[test]
fn globals_in_repl() {
let (out, err) = util::run_and_collect_output_with_args(
let (out, _err) = util::run_and_collect_output_with_args(
true,
vec!["repl", "--compat", "--unstable", "--quiet"],
Some(vec!["global == window"]),
None,
false,
);
assert!(out.contains("true"));
assert!(err.contains("Implicitly using latest version"));
}

0 comments on commit 5508a0f

Please sign in to comment.