diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-05-26 15:41:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-26 15:41:00 +0200 |
commit | f462f7fe54d59b2d56ffbb03ca8467ce93096817 (patch) | |
tree | 0c1a0541ef6eb94117f817be12339fb1e433f310 /cli/doc/parser.rs | |
parent | 9090023c33de7b64ae41425db71c9ab4d5b1237f (diff) |
fix: parsing of JSX and TSX in SWC (#5870)
Diffstat (limited to 'cli/doc/parser.rs')
-rw-r--r-- | cli/doc/parser.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/cli/doc/parser.rs b/cli/doc/parser.rs index 0e58e4b0a..9215637c5 100644 --- a/cli/doc/parser.rs +++ b/cli/doc/parser.rs @@ -1,4 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +use crate::file_fetcher::map_file_extension; use crate::op_error::OpError; use crate::swc_common::comments::CommentKind; use crate::swc_common::Span; @@ -15,6 +16,7 @@ use deno_core::ModuleSpecifier; use futures::Future; use regex::Regex; use std::collections::HashMap; +use std::path::PathBuf; use std::pin::Pin; use super::namespace::NamespaceDef; @@ -57,9 +59,12 @@ impl DocParser { file_name: &str, source_code: &str, ) -> Result<ModuleDoc, SwcDiagnosticBuffer> { - self - .ast_parser - .parse_module(file_name, source_code, |parse_result| { + let media_type = map_file_extension(&PathBuf::from(file_name)); + self.ast_parser.parse_module( + file_name, + media_type, + source_code, + |parse_result| { let module = parse_result?; let doc_entries = self.get_doc_nodes_for_module_body(module.body.clone()); @@ -69,7 +74,8 @@ impl DocParser { reexports, }; Ok(module_doc) - }) + }, + ) } pub async fn parse(&self, file_name: &str) -> Result<Vec<DocNode>, ErrBox> { |