diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-05-23 19:04:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-23 19:04:29 +0200 |
commit | c3c16f025ca6f30f3faaa70481a125494ddcea87 (patch) | |
tree | 1c2f4ba66838f1177ce01546426c5fea7e73869c /cli/module_graph.rs | |
parent | 94f1de5f805638b7bc06ac36b7fb8adb568c7a25 (diff) |
fix: TSX analysis in module graph loader (#5785)
Diffstat (limited to 'cli/module_graph.rs')
-rw-r--r-- | cli/module_graph.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/cli/module_graph.rs b/cli/module_graph.rs index 8e423265c..3a59a537d 100644 --- a/cli/module_graph.rs +++ b/cli/module_graph.rs @@ -48,6 +48,13 @@ where } } +const SUPPORTED_MEDIA_TYPES: [MediaType; 4] = [ + MediaType::JavaScript, + MediaType::TypeScript, + MediaType::JSX, + MediaType::TSX, +]; + #[derive(Debug, Serialize)] pub struct ModuleGraph(HashMap<String, ModuleGraphFile>); @@ -384,9 +391,7 @@ impl ModuleGraphLoader { let module_specifier = ModuleSpecifier::from(source_file.url.clone()); let source_code = String::from_utf8(source_file.source_code)?; - if source_file.media_type == MediaType::JavaScript - || source_file.media_type == MediaType::TypeScript - { + if SUPPORTED_MEDIA_TYPES.contains(&source_file.media_type) { if let Some(types_specifier) = source_file.types_header { let type_header = ReferenceDescriptor { specifier: types_specifier.to_string(), |