Skip to content

Commit

Permalink
fix: preserve extension if the import is a package
Browse files Browse the repository at this point in the history
  • Loading branch information
2fd committed Apr 17, 2024
1 parent a3e816b commit 9dbdf8d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ pub struct Config {
}

fn replace_ts_extension(src: &ast::Str, config: &Config) -> Option<ast::Str> {
if src.value.ends_with(".ts") && !src.value.ends_with(".d.ts") {
if !src.value.starts_with('.') {
return None;
} else if src.value.ends_with(".ts") && !src.value.ends_with(".d.ts") {
if let Some(file) = src.value.strip_suffix(".ts") {
return Some(format!("{}.js", file).into());
}
Expand Down

0 comments on commit 9dbdf8d

Please sign in to comment.