summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/cache/parsed_source.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/cli/cache/parsed_source.rs b/cli/cache/parsed_source.rs
index 6385e7384..fc1b54ddb 100644
--- a/cli/cache/parsed_source.rs
+++ b/cli/cache/parsed_source.rs
@@ -191,7 +191,7 @@ impl ParsedSourceCacheModuleAnalyzer {
let mut stmt = self.conn.prepare_cached(query)?;
let mut rows = stmt.query(params![
&specifier.as_str(),
- &media_type.to_string(),
+ serialize_media_type(media_type),
&expected_source_hash,
])?;
if let Some(row) = rows.next()? {
@@ -218,7 +218,7 @@ impl ParsedSourceCacheModuleAnalyzer {
let mut stmt = self.conn.prepare_cached(sql)?;
stmt.execute(params![
specifier.as_str(),
- &media_type.to_string(),
+ serialize_media_type(media_type),
&source_hash,
&serde_json::to_string(&module_info)?,
])?;
@@ -226,6 +226,30 @@ impl ParsedSourceCacheModuleAnalyzer {
}
}
+// todo(dsherret): change this to be stored as an integer next time
+// the cache version is bumped
+fn serialize_media_type(media_type: MediaType) -> &'static str {
+ use MediaType::*;
+ match media_type {
+ JavaScript => "1",
+ Jsx => "2",
+ Mjs => "3",
+ Cjs => "4",
+ TypeScript => "5",
+ Mts => "6",
+ Cts => "7",
+ Dts => "8",
+ Dmts => "9",
+ Dcts => "10",
+ Tsx => "11",
+ Json => "12",
+ Wasm => "13",
+ TsBuildInfo => "14",
+ SourceMap => "15",
+ Unknown => "16",
+ }
+}
+
impl deno_graph::ModuleAnalyzer for ParsedSourceCacheModuleAnalyzer {
fn analyze(
&self,