summaryrefslogtreecommitdiff
path: root/cli/tools/vendor/build.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-12-01 11:01:19 -0500
committerGitHub <noreply@github.com>2022-12-01 11:01:19 -0500
commitfafb3eebaf27cc2ef3ffaa10be8a0c5d78a112d0 (patch)
tree66a10aa95fd98903d19d49f2085d09116296afdc /cli/tools/vendor/build.rs
parent0a82f3c0e96cb0f176e98663d5eb8dc251b191d2 (diff)
fix(vendor): properly handle bare specifiers that start with http (#16885)
Diffstat (limited to 'cli/tools/vendor/build.rs')
-rw-r--r--cli/tools/vendor/build.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/cli/tools/vendor/build.rs b/cli/tools/vendor/build.rs
index dadd84e22..b28038a67 100644
--- a/cli/tools/vendor/build.rs
+++ b/cli/tools/vendor/build.rs
@@ -1065,6 +1065,41 @@ mod test {
}
#[tokio::test]
+ async fn existing_import_map_http_key() {
+ let mut builder = VendorTestBuilder::with_default_setup();
+ let mut original_import_map = builder.new_import_map("/import_map.json");
+ original_import_map
+ .imports_mut()
+ .append(
+ "http/".to_string(),
+ "https://deno.land/std/http/".to_string(),
+ )
+ .unwrap();
+ let output = builder
+ .with_loader(|loader| {
+ loader.add("/mod.ts", "import 'http/mod.ts';");
+ loader.add("https://deno.land/std/http/mod.ts", "console.log(5);");
+ })
+ .set_original_import_map(original_import_map.clone())
+ .build()
+ .await
+ .unwrap();
+ assert_eq!(
+ output.import_map,
+ Some(json!({
+ "imports": {
+ "http/mod.ts": "./deno.land/std/http/mod.ts",
+ "https://deno.land/": "./deno.land/",
+ }
+ }))
+ );
+ assert_eq!(
+ output.files,
+ to_file_vec(&[("/vendor/deno.land/std/http/mod.ts", "console.log(5);")]),
+ );
+ }
+
+ #[tokio::test]
async fn vendor_file_fails_loading_dynamic_import() {
let mut builder = VendorTestBuilder::with_default_setup();
let err = builder