summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2019-05-03 12:03:10 -0700
committerRyan Dahl <ry@tinyclouds.org>2019-05-03 15:03:10 -0400
commit401a5c021141d4ba5a71078b28f6daefcd1826a6 (patch)
treed8fd8b92d0be5a84620dc818cc29842d58e1c815 /cli
parent4648277fb4aa0f7258a316b8828a1175e3e2d132 (diff)
feat: support .mjs extension resolution (#2283)
Removed `extmap` and added .mjs entry in `map_file_extension`. The assert in the compiler does not need to be updated, since it is resolving from the compiled cache instead of elsewhere (notice the .map is asserted next to it)
Diffstat (limited to 'cli')
-rw-r--r--cli/deno_dir.rs17
1 files changed, 2 insertions, 15 deletions
diff --git a/cli/deno_dir.rs b/cli/deno_dir.rs
index 5b7b65f4b..c58a252cb 100644
--- a/cli/deno_dir.rs
+++ b/cli/deno_dir.rs
@@ -26,16 +26,6 @@ use std::str;
use url;
use url::Url;
-/// Gets corresponding MediaType given extension
-fn extmap(ext: &str) -> msg::MediaType {
- match ext {
- "ts" => msg::MediaType::TypeScript,
- "js" => msg::MediaType::JavaScript,
- "json" => msg::MediaType::Json,
- _ => msg::MediaType::Unknown,
- }
-}
-
#[derive(Clone)]
pub struct DenoDir {
// Example: /Users/rld/.deno/
@@ -553,6 +543,7 @@ fn map_file_extension(path: &Path) -> msg::MediaType {
Some(os_str) => match os_str.to_str() {
Some("ts") => msg::MediaType::TypeScript,
Some("js") => msg::MediaType::JavaScript,
+ Some("mjs") => msg::MediaType::JavaScript,
Some("json") => msg::MediaType::Json,
_ => msg::MediaType::Unknown,
},
@@ -871,11 +862,7 @@ fn save_source_code_headers(
let mime_type_string = mime_type.clone().unwrap();
let resolved_mime_type =
{ map_content_type(Path::new(""), Some(mime_type_string.as_str())) };
- let ext = p
- .extension()
- .map(|x| x.to_str().unwrap_or(""))
- .unwrap_or("");
- let ext_based_mime_type = extmap(&ext);
+ let ext_based_mime_type = map_file_extension(&p);
// Add mime to headers only when content type is different from extension.
if ext_based_mime_type == msg::MediaType::Unknown
|| resolved_mime_type != ext_based_mime_type