Skip to content

Commit

Permalink
add support for .jsx and .tsx files (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra authored Aug 26, 2022
1 parent 49e759b commit ec88fc2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 8 additions & 2 deletions crates/turbopack/src/module_options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ pub async fn the_module_options() -> ModuleOptionsVc {
vec![ModuleRuleEffect::ModuleType(ModuleType::Css)],
),
ModuleRule::new(
ModuleRuleCondition::ResourcePathEndsWith(".js".to_string()),
ModuleRuleCondition::any(vec![
ModuleRuleCondition::ResourcePathEndsWith(".js".to_string()),
ModuleRuleCondition::ResourcePathEndsWith(".jsx".to_string()),
]),
vec![ModuleRuleEffect::ModuleType(ModuleType::Ecmascript(
app_transforms,
))],
Expand Down Expand Up @@ -71,7 +74,10 @@ pub async fn the_module_options() -> ModuleOptionsVc {
))],
),
ModuleRule::new(
ModuleRuleCondition::ResourcePathEndsWith(".ts".to_string()),
ModuleRuleCondition::any(vec![
ModuleRuleCondition::ResourcePathEndsWith(".ts".to_string()),
ModuleRuleCondition::ResourcePathEndsWith(".tsx".to_string()),
]),
vec![ModuleRuleEffect::ModuleType(ModuleType::Typescript(
no_transforms,
))],
Expand Down
9 changes: 8 additions & 1 deletion crates/turbopack/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,14 @@ pub async fn resolve_options(
extensions: if emulating {
environment.resolve_extensions().await?.clone()
} else {
vec![".js".to_string(), ".node".to_string(), ".json".to_string()]
vec![
".tsx".to_string(),
".ts".to_string(),
".js".to_string(),
".jsx".to_string(),
".node".to_string(),
".json".to_string(),
]
},
modules: if emulating {
if *environment.resolve_node_modules().await? {
Expand Down

0 comments on commit ec88fc2

Please # to comment.