Skip to content

Commit

Permalink
Fix default extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Nov 14, 2022
1 parent 6672c52 commit 474357b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/swc_ecma_transforms_module/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,24 @@ where
{
fn resolve_import(&self, base: &FileName, module_specifier: &str) -> Result<JsWord, Error> {
fn to_specifier(target_path: &str, orig_ext: Option<&str>) -> JsWord {
let p = PathBuf::from(target_path);
let mut p = PathBuf::from(target_path);

if cfg!(debug_assertions) {
trace!("to_specifier: orig_ext={:?}", orig_ext);
}

if let Some(orig_ext) = orig_ext {
let use_orig = if let Some(ext) = p.extension() {
ext == "ts" || ext == "tsx"
} else {
false
};

if use_orig {
p.set_extension(orig_ext);
}
}

p.display().to_string().into()
}

Expand Down

0 comments on commit 474357b

Please sign in to comment.