summaryrefslogtreecommitdiff
path: root/cli/module_graph.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-05-26 15:41:00 +0200
committerGitHub <noreply@github.com>2020-05-26 15:41:00 +0200
commitf462f7fe54d59b2d56ffbb03ca8467ce93096817 (patch)
tree0c1a0541ef6eb94117f817be12339fb1e433f310 /cli/module_graph.rs
parent9090023c33de7b64ae41425db71c9ab4d5b1237f (diff)
fix: parsing of JSX and TSX in SWC (#5870)
Diffstat (limited to 'cli/module_graph.rs')
-rw-r--r--cli/module_graph.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/cli/module_graph.rs b/cli/module_graph.rs
index 3a59a537d..be3bd2884 100644
--- a/cli/module_graph.rs
+++ b/cli/module_graph.rs
@@ -196,6 +196,7 @@ impl ModuleGraphLoader {
let (import_descs, ref_descs) = analyze_dependencies_and_references(
&specifier,
+ map_file_extension(&PathBuf::from(&specifier)),
&source_code,
self.analyze_dynamic_imports,
)?;
@@ -409,6 +410,7 @@ impl ModuleGraphLoader {
let (import_descs, ref_descs) = analyze_dependencies_and_references(
&module_specifier.to_string(),
+ source_file.media_type,
&source_code,
self.analyze_dynamic_imports,
)?;
@@ -786,4 +788,23 @@ mod tests {
);
drop(http_server_guard);
}
+
+ #[tokio::test]
+ async fn source_graph_different_langs() {
+ let http_server_guard = crate::test_util::http_server();
+
+ // ModuleGraphLoader was mistakenly parsing this file as TSX
+ // https://github.com/denoland/deno/issues/5867
+
+ let module_specifier = ModuleSpecifier::resolve_url_or_path(
+ "http://localhost:4545/cli/tests/ts_with_generic.ts",
+ )
+ .unwrap();
+
+ build_graph(&module_specifier)
+ .await
+ .expect("Failed to build graph");
+
+ drop(http_server_guard);
+ }
}