diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-02-19 16:34:11 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-19 00:34:11 -0500 |
commit | 046bbb26913f9da58b0d23ae331e9dab9dc19e59 (patch) | |
tree | 74dd5945ed1ff10ce84fea05c73d9c13b31ad376 /cli/file_fetcher.rs | |
parent | 3d5bed35e032ee20e4fe34cad925202c6f0c0d3e (diff) |
Support loading additional TS lib files (#3863)
Fixes #3726
This PR provides support for referencing other lib files (like lib.dom.d.ts that are not
used by default in Deno.
Diffstat (limited to 'cli/file_fetcher.rs')
-rw-r--r-- | cli/file_fetcher.rs | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index 75774ed5b..41f31fb49 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -165,7 +165,7 @@ impl SourceFileFetcher { maybe_referrer: Option<ModuleSpecifier>, ) -> Pin<Box<SourceFileFuture>> { let module_url = specifier.as_url().to_owned(); - debug!("fetch_source_file. specifier {} ", &module_url); + debug!("fetch_source_file_async specifier: {} ", &module_url); // Check if this file was already fetched and can be retrieved from in-process cache. if let Some(source_file) = self.source_file_cache.get(specifier.to_string()) @@ -368,18 +368,13 @@ impl SourceFileFetcher { } Ok(c) => c, }; - let media_type = map_content_type( - &filepath, - source_code_headers.mime_type.as_ref().map(String::as_str), - ); + let media_type = + map_content_type(&filepath, source_code_headers.mime_type.as_deref()); let types_url = match media_type { msg::MediaType::JavaScript | msg::MediaType::JSX => get_types_url( &module_url, &source_code, - source_code_headers - .x_typescript_types - .as_ref() - .map(String::as_str), + source_code_headers.x_typescript_types.as_deref(), ), _ => None, }; @@ -515,17 +510,13 @@ impl SourceFileFetcher { .location .join(dir.deps_cache.get_cache_filename(&module_url)); - let media_type = map_content_type( - &filepath, - maybe_content_type.as_ref().map(String::as_str), - ); + let media_type = + map_content_type(&filepath, maybe_content_type.as_deref()); let types_url = match media_type { - msg::MediaType::JavaScript | msg::MediaType::JSX => get_types_url( - &module_url, - &source, - x_typescript_types.as_ref().map(String::as_str), - ), + msg::MediaType::JavaScript | msg::MediaType::JSX => { + get_types_url(&module_url, &source, x_typescript_types.as_deref()) + } _ => None, }; |